VAL Function

Authors

Publication

Pub Details

Date

Pages

BASIC Terms

One of the most powerful, and (Oh, Yes,) useful instructions of the Timex-Sinclair computers is the VAL function Unfortunately, it is also unique to the Timex-Sinclair computers.

Te VAL function evaluates an arbitrary numerically-valued string. It only returns an error C, in the case that the string argument does not evaluate to a number.

Apparently, Bill Gates saw this in the early ’80s and decided, that VAL was unsuitable for his instruction sets since there is no limit to its execution time, and he was looking for something fast. However, VAL was deemed suitable for the evaluation of number strings, as in VAL “12345”, which turns out to be a very economical way of writing 12345.

Now, I can hear you all yelling, that you also have a VAL on your own machine. But, I guarantee you, that it will only remove the quotation marks from about address constants!

But, the VAL, of which I speak, can be used to give the elapsed time, on-line with SOL BBS. It gives the updated row number in the code, for squeezing a message base in SOL BBS with some ZAPped messages. Lastly, and this example hurts, it is extremely useful in math modeling.

 4175 LET a$="INT(e-60*h)+1": GOSUB 8100: PRINT #7''"Your ELAPSED TIME was ";h;".";VAL a$

(The minutes portion of elapsed time on SOL BBS.)

 3000 DIM (155, 64) : LET r$="10+VAL d$ (r0,5 TO 7)"
3225 LET r0=T: LET I=VAL I$: IF r<11 THEN GO TO 3210
3300 PRINT ''"Length of NEW MESSAGE BASE is ";VAL I$-1;" !!"''
3410 IF r=r0 THEN LET r=VAL r$: NEXT n

1 FOR j=1 TO nc: FOR k=1 TO nc: IF CODE b$(j,k)=32 THEN GO TO 3
2 FOR I=1 TO i(k): LET s(I)=q(j,I): NEXT I: LET p(k)=VAL b(j,k)
3 NEXT k: FOR I=1 TO i(j): LET s(I)=q(j,I): NEXT I: FOR I=1 TO i(j): LET o(j,I)=VAL m$(j,I): LET q(k,i)=o(k,I): NEXT I: NEXT k: RETURN

Some confusion can be avoided, by inserting a blank line (or two BEFORE line 3000 and AFTER line 3410 of that BASIC code!

As can be seen, the last three statements constitute an elegant stretch of BASIC code. It implements a stage-wise updating facility, for simulating a math model. I have an entire simulation länguage (Systems-Oriented Language), which depends for its simplicity and power upon this very VAL function, as seen in statements 2 and 3. But, SOL is still-born, given the dearth of equipment, for running the code.

Dr. Wymore assures me, however, that IBM would be only too happy to build a VAL function into one of its machines, given a special order!

Products

 

Media

 

Image Gallery

Source Code

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

Scroll to Top