Extract (Get) a floating point number from a buffer in RAM.
Consider an Xwire receive data block to be nn bytes of RAM starting at address bb. Return a decimal number from the data block, starting at RAM address bb+I (i.e. the starting address is indexed). Skip any leading spaces. Process leading + or – sign, if present. Terminate on anything thereafter that's not a decimal digit or decimal point, or after processing fw (field width) characters in total (including spaces, sign and decimal point). Advance I past the characters used, leaving it pointing at the terminating character (auto-index). Result in W, NaN if nothing there. R register signals outcome. 0 = OK, 1 = no valid decimal number present.
Notes:
fw includes leading spaces, signs and decimal point.fw is 1 to 255. fw = 255 disables character counting.nn and fw.Dialect exclusions: Not available in dialects before 28
See also: iifPrintWFW, iifPrintWVW,
The following shows the result of the instruction iifGetNum 100,15,8 for various RAM contents and Values of I.
Data in RAM, starting at address 100 (Shown as ASCII (printable) characters. |
Initial value of I |
Result returned in W |
Final value of I |
Comment |
|
0 |
123.456 |
7 |
Conversion starts at the first character, because |
|
1 |
23.456 |
7 |
Conversion starts at the second character, because |
|
0 |
123 |
8 |
Leading spaces are counted in the field width. The decimal point "makes it", and |
|
0 |
-123.456 |
8 |
All good, got it all |
|
0 |
-123.45 |
8 |
The last digit is excluded, because the field width of 8 terminates conversion. Furthermore, a subsequent conversion would return 6. |
|
0 |
-12.3 |
6 |
The second decimal point terminates conversion. If the same instruction were executed again (with |