In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote: If you want to generalize that routine so that it will print only the characters needed you can do it like this: [code]SUB TX_DEC wDividend VAR tmpW1 wDivisor VAR tmpW2 wResult VAR tmpW3 wIdx VAR tmpB1 wChar VAR wResult_LSB \ SB __PARAMCNT.1 \ CLR __WPARAM12_MSB wDividend = __WPARAM12 IF wDividend > 9999 THEN wDivisor = 10_000 wIdx = 5 ELSEIF wDividend > 999 THEN wDivisor = 1_000 wIdx = 4 ELSEIF wDividend > 99 THEN wDivisor = 100 wIdx = 3 ELSEIF wDividend > 9 THEN wDivisor = 10 wIdx = 2 ELSE wChar = __WPARAM12_LSB + "0" TX_BYTE wChar widx = 0 ENDIF DO WHILE wIdx > 0 wResult = wDividend / wDivisor wDividend = __WREMAINDER wChar = wChar + "0" TX_BYTE wChar wDivisor = wDivisor / 10 DEC wIdx LOOP ENDSUB[/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=287524#m287623 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)