String Conversion
I am using SERIN to recieve a number from 1 to 999 (1 to 3 numbers long) following a "G" and ending with a "."
The string command:
SERIN 0, N4800, 3000, TimedOut,[noparse][[/noparse]WAIT ("G,"), STR Number\3\"."]
works great because I am not sure how long the number is.
Unfortunately, I get a string of numbers when I am finished. The PBasic manual makes reference to this:
"Without the decimal formatter, however, you would have been forced to receive each character ("1", "2" and "3") separately, and then would still have to do some manual conversion to arrive at the number 123 (one hundred twenty three) before you can do the desired calculations on it."
So I didn't use the decimal formatter DEC because I didn't know the length of the number. So is this "manual conversion" difficult to do? or is there another way?
thanks!
The string command:
SERIN 0, N4800, 3000, TimedOut,[noparse][[/noparse]WAIT ("G,"), STR Number\3\"."]
works great because I am not sure how long the number is.
Unfortunately, I get a string of numbers when I am finished. The PBasic manual makes reference to this:
"Without the decimal formatter, however, you would have been forced to receive each character ("1", "2" and "3") separately, and then would still have to do some manual conversion to arrive at the number 123 (one hundred twenty three) before you can do the desired calculations on it."
So I didn't use the decimal formatter DEC because I didn't know the length of the number. So is this "manual conversion" difficult to do? or is there another way?
thanks!
Comments
SERIN 0,N4800,3000,TimedOut[noparse][[/noparse]WAIT("G,"),DEC Number]
The SERIN will use the decimal point as a terminating character for the number, and then discard it.
If you don't put a digit count after the DEC, PBasic accepts any length by using a non-digit terminating character.
There is a table of examples in the back of the PBasic Manual in one of the appendices.