--- title: "VAL Function" type: "article" slug: "val-function" url: "http://localhost/article/val-function/" markdown_url: "http://localhost/article/val-function.md" published_at: "2020-10-27T17:16:03+00:00" modified_at: "2026-08-09T14:07:37+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "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,…" category: - name: "ZXir QLive Alive" slug: "zxir-qlive-alive" taxonomy: "category" url: "http://localhost/category/periodicals/zxir-qlive-alive/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" basic: - name: "VAL" slug: "val" taxonomy: "basic" url: "http://localhost/basic/val/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "David Lassov" slug: "david-lassov" taxonomy: "indiv" url: "http://localhost/indiv/david-lassov/" publication: "ZXir QLive Alive" publication_r: id: 10286 title: "ZXir QLive Alive!" type: "periodical" url: "http://localhost/periodical/zxir-qlive-alive/" authors: "David Lassov" authors_r: - name: "David Lassov" slug: "david-lassov" taxonomy: "indiv" url: "http://localhost/indiv/david-lassov/" volume: "7" issue: "4" issues_articles: - id: 26828 title: "ZXir QLive Alive! v7 n4" type: "issue" url: "http://localhost/issue/zxir-qlive-alive-v7-n4/" pages: "19" pubdate: "Winter 1997" archive_link: false volumeissue: "v7n4" --- # VAL Function 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!