Sharp MZ-700 Series Owner's Manual page 81

Personal computer
Hide thumbs Also See for MZ-700 Series:
Table of Contents

Advertisement

2.5.4 VAL and STR$
Format
Function
Example
STRS (x)
x: Numeric expression
Returns a string of ASCII characters
representing the value of numeric
expression X.
A$=STR$ ( - 1 2 )
Substitutes the character string " —12 "
into string variable AS.
B$=STR$ (70 X 33)
Substitutes the character string
" 2310 " into string variable BS.
C$=STR$ (1200000 * 5000)
Substitutes the character string " 6E +
09" into string variable CS.
Note: Positive numeric values axe displayed with a
leading space to indicate that the plus sign
(+) has been omitted. However, this space
is not included in the character sting re-
turned by the STR$ function.
V A L ( x $ )
x$: String expression
Converts an ASCII character repre-
sentation of a numeric value into a
numeric value. This is the comple-
ment of the STRS function.
A=VAL ( " 1 2 3 " )
Converts the character string " 123
1
into the number 123 and assigns it to
numeric variable A.
The following sample program illustrates use of some of the functions discussed above to display
numeric values in tabular format (with the decimal points aligned).
1 . 2 3 4 5 6
1 2 .
3 4 5 6
1 0
1
1 2 3 4
If the values read from DATA statements were displayed using only the PRINT statement, the result
would appear as shown below.
1 0
F O R
X = 1
T O
5
2 0
R E A D
A
3 0
L = 5 - L E N
( S T R S ( ! N T ( A ) ) )
4 0
P R I N T
T A B CL)
; A
5 0
N E X T : E N D
6 0
D A T A
1 . 2 3 4 5 6 ,
1 2 .
3 4 5 6
7 0
D A T A
1 2 3 . 4 5 6 ,
1 2 3 4 .
5 6
8 0
D A T A
1 2 3 4 5 . 6
1
1
2
1 2 3
1 2 3 4
1 2 3 4 5

Advertisement

Table of Contents
loading

Table of Contents