Sending numbers
charleyshf
Posts: 165
Hello,,
The code I am working on is the following:
This 'kind of ' works, however I was expecting the result of 060255255120120255 and instead I get an extra 0 at the end "0602552551201202550" . I could send each value one at a time with PST.Dec , but I would think there is a better way to do this, I am also using the PST object to display my results. Any ideas what I am doing wrong?
The code I am working on is the following:
PUB testing a := 0 '0-9 b := 60 '0-255 c := 255 '0-255 d := 255 '0-255' e := 120 '0-255 f := 120 '0-255 g := 255 '0-255 outdata[0] := a outdata[1] := b outdata[2] := c outdata[3] := d outdata[4] := e outdata[5] := f outdata[6] := g repeat i from 0 to 7(outdata) PST.Dec(outdata[i])
This 'kind of ' works, however I was expecting the result of 060255255120120255 and instead I get an extra 0 at the end "0602552551201202550" . I could send each value one at a time with PST.Dec , but I would think there is a better way to do this, I am also using the PST object to display my results. Any ideas what I am doing wrong?
Comments
Repeat i from 0 to 6(Outdata)
See if that helps:)
You're sending an extra value to the PST. Your data is from 0 to 6 but your sending 0 to 7. I assume outdata[7] is either zero or undefined.
I don't understand "repeat i from 0 to 7(outdata)".
Are you missing a comment before "(outdata)"?
Duane
Thanks again
I think this should work (I haven't tested it).
This should output a thee digit number with leading zeros when needed.
Duane
Edit: charleyshf's post made me realize I was using the dec method incorrectly. I fixed (I think) the code above.
Your example made me think about what I wanted the prop to do and this is working for me: