Rpbasic-52 programming guide – Remote Processing BASIC 52 User Manual
Page 125

RPBASIC-52 PROGRAMMING GUIDE
2-106
Syntax:
A = ST R(10,$(n), format,va riable )
Description:
Converts and formats variable into a st ring an d puts it into $(n ). Varia ble A returns irrelev ant da ta.
Formatting is controlled by the format variable. Strings are formatted into one of 3 basic patterns, described
b e lo w .
format = 0. Default free form at. When n umber is be tween ± 99999999 a nd ±0.1, RP BAS IC will save integers
and fractions. When numbers are outside this range, the F0 format, described next, is used.
format = Fx. Floating point format. 'x' determines how many digits after the decimal point are saved. When
x = 0, th e num ber of tra iling di gits w ill vary and tra iling 0's a re not sa ved. 'x' is re presen ted as a hex nu mbe r.
When format = 0F3H , 3 decimal nu mbers are p rinted. An alternate way of setting floa ting point output is to
make format= the number of decimal numbers plus 240.
format = xyH. Force integer and/or fraction output. Comma nd is same as USING(##.##), where 'x' is the
number digits left of the decimal point and y is to the right. Maximum value for x and y is 7. Use the hex
format to set the n umber.
Example:
10 String 200,20
20 C = 23.45
30 F = 0
40 A = STR(10,$(0),F,C)
50 PRINT "Variable value, before formatting:",C
60 PRINT "String in free format:",$(0)
70 F = 0F2H
80 A = STR(10,$(0),F,C)
90 PRINT "Using floating point format:",$(0)
100 F=52H
110 A=STR(10,$(0),F,C)
120 PRINT "Using #####.## format:",$(0)
run
Variable value, before formatting: 23.45
String in free format: 23.45
Using floating point format: 2.34 E+1
Using #####.## format: 23.45
E R R O R
B A D A R G U M E N T When function is out of range or string data is incorrect.