Authors
Publication
Pub Details
Date
Pages
BASIC Terms
You will recall that at the NOV. meeting there was a discussion on the use of VAL$. Robert Ryan actively entered into the discussion, and offers this further demonstration.
This program is a short demonstration of one use for VAL$. It inputs a name and then will print the first, last or middle name from it. Lines 10-30 tell the computer how to get first, last, and middle names. Line 50-80 find where the breaks in the name are. Then line 98 finds out which name you want to print. When line 100 is executed the computer first tries VAL$ (z$+”$”). Depending on whether z$ is f, l, or m, VAL$ (z$+”$”) will be equal to the contents of string f$, l$, or m$, namely a$(a+3 TO b), a$( TO a), or a$(b+2 T0) so VAL$ VAL$ (z$+”$”) will be equal to the contents of a$(a+3 T0 b), a$( TO 0), or a$(b+2 TO ), namely the first, last or middle name from the name entered.
VALs behaves as if replaced by the contents of its argument, for example:
10 LET B$="A$ (2 TO )"
20 PRINT VAL$ (B$)
Thus VAL$(B$) would be the same as A$ ( 2 TO )
10 LET f$="a$ ( a$+3 TO b)"
20 LET l$="a$( TO a)"
30 LET m$="a$(b+2 TO )"
40 INPUT "Name (Last, First, Middle)", LINE a$
50 FOR i=1 TO LEN a$
60 IF a$(i)=" " THEN LET b=i-1
70 IF a$(i)="," THEN LET a=i-1
80 NEXT i
90 INPUT "Print f)irst, l)ast, m)iddle name"; z$
100 PRINT VAL$ VAL$ (z$+"$")
110 GO TO 90
Products
Media
Image Gallery
Source Code
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.