Radio Shack TRS-80 Model 100 Basic Manual page 55

Basic language lab
Hide thumbs Also See for TRS-80 Model 100:
Table of Contents

Advertisement

Since there are six
#
symbols and one decimal point specified, a total of seven
columns will be used for the printing of the number. The number will be printed
"right justified" in this seven column field, meaning that there may be some blanks in
the left most columns, but not in the right-most.
Instead. of using a constant string, such as
"####.##",
it is permissible to use a
string variable for the format specifier. For example, the program can be changed as
follows
as
A$
=
"####,##"
S0 PRINTUSING A$; eM
This will give the same output as before. Again, the value printed for the commission
will be rounded to the nearest cent. Note that the format specifier, whether it is a
string or a string variable, is always followed by a semicolon.
For some more examples, suppose CM
=
1416.3812 (actual value as computed) and
this is printed out with line 50 above. The following table gives the output for various
format specifiers
format specifler
A$
=
"####.##"
A$
=
"####.#"
A$
=
"#####.###"
A$
=
"####.#####"
output
1416.38
1416.4
1416.381
1416.38120
Experiment #3 Dollar Signs
There are other possibilities for format specifiers. Change line 45 in the program so
that it is:
as
A$
=
"$######,##"
Now run the program and input a variety of values for the sales. In each case there
will be a dollar sign
($)
printed to the left of the field (9 column). In many cases there
will be some blanks between the
$
and the left most digit of the number.
Now change line 45 so that it is:
as
A$
=
"$$######,##"
Run the program with a sales amount of 1111. As you can see, the
$
is now printed
just to the left of the number $166.65. The use of two dollar signs to the left of the
numeric field specifier instructs the computer to print a dollar sign immediately to the
left of the leading digit.
Experiment #4 Checks
Many times, payroll checks are printed with asterisks padding the leftmost columns of
the field.
Change line 45 in the previous program to:
as
A$
=
"**$######,##"
49

Advertisement

Table of Contents
loading

Table of Contents