A long time ago (TDM March/April ’86) I saw a note by Mike de Sosa on the lack of the VAL string function on the QL. At the time I didn’t have one, but with the recent price cuts I’ve added a QL to my “home for orphan computers”. Although I ordered one with software and QL User Guide, it came sans manual (later received), so I was digging through all my old Sinclair mags for info when I ran across Mike’s comment again.
No doubt other users have found purely software approaches since then, although I have found no published ones in my non-QL specific mags except the one Mike gave which utilizes Microdrive commands. The problem seems to be that while SuperBASIC does correctly interpret the value of an expression discretely entered as a program line, for example:
LET a$=2^3*PI or LET a=2^2*PI
It seems to “see” only the first item (2) if the same expression is entered in response to INPUT a:
LET a$=a: PRINT a$
While it is a clumsy substitute for what can be done so routinely with “lowly” TS1000/2068 BASIC, the following process will give the correct output for an expression entered as the definition of either a numeric variable or as a string variable definition without quotes or asterisks:
10 expr = 0 : REM or expr$ = 0
20 WHEN ERROR
30 RETRY
40 END WHEN
50 CLS : CLS #0 : PRINT "expr = "; ex
pr: PRINT "Enter expression, then r for
result": EDIT 10 : STOP
60 DEFine PROCedure r
70 RUN
80 END DEFine r
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.