In SX Microcontrollers, SX/B Compiler and SX-Key Tool, RS_Jim wrote: Good Morning, Jonny Mac recently posted a neat series of routines that printed out bin hex and Dec results from Byte parameters. I thought that was really cool but needed a Decimal printout of a Word Varable. So I edited his routine and came up with the following: ' ------------------------------------------------------------------------- ' Use: TX_DEC5 value ' -- transmit word in (fixed-width) DEC5 format '-------------------------------------------------------------------------- SUB TX_DEC5 dvalW VAR TmpW1 divisorW VAR tmpW2 dDigit Var tmpB1 dChar Var tmpB2 dValW = __wPARAM12 ' copy output value divisorW = 10000 ' set initial divisor FOR dDigit = 4 TO 0 STEP -1 ' show three digits __wparam34 = dValW / divisorW ' get a digit dValW = __wREMAINDER ' save remainder dChar = __param3 ' it going to be <10 dChar = dChar + "0" ' convert to ASCII TX_BYTE dChar divisorW = divisorW / 10 ' update divisor NEXT ENDSUB if I declare tmpW1 = 23456 or any 5 digit number short of 65,535: TX_DEC5 tmpW1 my results always come out 00000. I wonder if I have one temp varable stepping on another. When I look at .lst file I do find some VAR with the same address. I am I missing something? It is hard to step through the Devide by 10,000 to see what is happening. I tried setting dChar = dValw / divisorW but it is expecting a word param not a byte and wont compile. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=287524 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)