Remote-processing BASIC 52 Uživatelský manuál Strana 125

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 163
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 124
RPBASIC-52 PROGRAMMING GUIDE
2-106
Syntax: A = STR(10,$(n),format,va riable)
Description:
Converts and formats variable into a string and puts it into $(n ). Varia ble A returns irrelevant data.
Formatting is controlled by the format variable. Strings are formatted into one of 3 basic patterns, described
below.
format = 0. Default free form at. When n umber is be tween ± 99999999 a nd ±0.1, RPBASIC 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, the num ber of trailing digits will vary and tra iling 0's are not sa ved. 'x' is represen ted as a hex nu mbe r.
When format = 0F3H, 3 decimal numbers are printed. An alternate way of setting floating 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 number.
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
ERROR
BAD ARGUMENT When function is out of range or string data is incorrect.
Zobrazit stránku 124
1 2 ... 120 121 122 123 124 125 126 127 128 129 130 ... 162 163

Komentáře k této Příručce

Žádné komentáře