Shop OBEX P1 Docs P2 Docs Learn Events
sending decimals? — Parallax Forums

sending decimals?

Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
edited 2010-11-22 20:31 in Accessories
Has anyone done a "DecSend" based on the "StringSend" in the http demos?

OBC

Comments

  • CassLanCassLan Posts: 586
    edited 2010-11-20 16:49
    The counter in Tim's orig demo uses decimals
          StringSend(0, string("This page has been served "))
          StringSend(0, string("<b>"))
          StringSend(0, STR.numberToDecimal(PageCount, 5))
          StringSend(0, string("</b>"))
          StringSend(0, string(" times since powering on of the module"))
    
  • obrienmobrienm Posts: 65
    edited 2010-11-20 20:15
    I am getting a prepended " " space in front of the numbers so I need to either use a different function, modify it or parse out the first char - as HTML DOM element identifiers in my pages were being rendered incorrectly.
    My next demo version should have it fixed.

    The following
    StringSend(0, string("        <td><span id=",34))
          StringSend(0, STR.numberToDecimal(proc, 1))
          StringSend(0, string(34," class='refdesc-d'>",13,10))
    

    Is rendered as
    <td><span id=" 0" class='refdesc=d'>
    

    But needs to be
    <td><span id="0" class='refdesc=d'>
    

    The following overloaded function may be added to STREngine.spin - normally I would have one call the other with a parameter
    -332: PUB numberToDecimal(number, length) '' 5 Stack Longs
    +332: PUB numberToDecimalTrim(number, length) '' 5 Stack Longs
    -344:  decimalCharacters := " "
    +344:  decimalCharacters := ""
    
    thank you
    /michael
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2010-11-21 08:25
    Thanks Rick!

    I hadn't looked at the object close enough.

    OBC
  • zapmasterzapmaster Posts: 54
    edited 2010-11-22 20:31
    I had the same issue.

    i changed line

    358 to bytemove(@decimalCharacters[0], @decimalCharacters[(11 - length)], (length + 1))

    from bytemove(@decimalCharacters[1], @decimalCharacters[(11 - length)], (length + 1))


    this solved the issue of me with the " "
Sign In or Register to comment.