Sharp MZ-700 Owner's Manual page 81

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

Advertisement

2.5.4 V AL and STR$
Format
).
Function
STR$ (x)
Returns a string of ASCII characters
x: Numeric expression representing the value of numeric
expression
X.
VAL(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 STR$ function.
Example
A$
=STR$
(
-12)
Substitutes the
character
string
11
-
12
11
into string variable
A$
.
B$ =STR$ (70
~
33)
Substitutes the character
string
11
2310
11
into
string
variable
B$.
C$=STR$
(1200000
*
5000)
Substitutes the character string
11
6E
+
09
11
into string variable
C$.
Note: Positive numeric values are displayed
with a
leading space to indicate that the plus
sign
(+)has been omitted.
However,
this space
is
not included in the character
sting
rt>-
turned by the STR$ function.
A=VAL
(
11
123
11
)
Converts the character
string
11
123
11
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. 23456
12
.
3456
1
0
1
12
34
If
the values read from DATA
statements
were displayed using only the PRINT
statement,
the
result
would
appear as
shown below.
1
0
FOR X=1
TO 5
20
READ A
3
0
L=5-LEN
CSTR$
C
I
NTCA)
)
)
4
0
PRINT TAB
C
L
)
;A
5
0
NEXT:
END
60
DATA
1.
23456.
12.3456
70 DATA
12
3. 456,
1
234.56
80
DATA 1 2345. 6
1
.
23456
1 2.
3456
123.
456
1234
.
56
1 2345.
6

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents