Perhaps experimenting with the keyboard settings on QPC2's front panel could make a difference to the keyboard queue handling.
Taking Steve's idea a bit further, we can implement a more robust version of VAL by using S*BASIC's coercion ability, to return any data type, coerced into a string. If our new function is called VAL$, we could do things such as ...
n = VAL$("2+3+4+5")
x$ = VAL$("'ABC' & '___' & 'xyz'")
n% = VAL$("33 DIV 2")
Here's the new function ...
Code: Select all
100 DEFine FuNction VAL$(expn$)
110 IF expn$ = FILL$(" ",LEN(expn$)) : RETurn expn$
120 COMMAND_LINE
130 TYPE_IN "RETurn " & expn$ & CHR$(10)
140 STOP
150 END DEFine VAL$
160 :
170 REPeat loop
180 INPUT "Expn? "; e$
190 PRINT " = "; VAL$((e$))
200 END REPeat loop
The STOP command causes a return to the command interpreter, and allows the TYPED_IN command to do its work. The RETurn statement causes VAL$ to continue, and returns the result of the expression.
When developing some S*BASIC program, I may wish to stop at same place in the code to check that all is going as expected. Usually it is the value of variables that will need to be checked, but also the value of some expressions can also be useful. This is where these expression evaluators can come in very handy. The actual values may not need to be be recorded, but just need to be displayed on the screen. Helpfully, what could be displayed is something along these lines ...
x = 123
y = 200
dev$ = ram5_
Displaying this info on the screen can avoid the need of having write them down on paper. Using the same technique as used in VAL$, here is Vprint ...
Code: Select all
220 DEFine PROCedure Vprint
230 LOCal lp, Lin$(1024), qt$(1)
240 REPeat lp
250 INPUT #0,"Vprint "; Lin$ : IF Lin$ = "" : RETurn
260 IF "'" INSTR Lin$ : qt$ = '"' : ELSE qt$ = "'"
270 IF qt$ INSTR Lin$
280 PRINT #0," - Can only use one quote mark - not both" : NEXT lp
290 END IF
300 COMMAND_LINE
310 TYPE_IN "PRINT ! " & qt$ & Lin$ & " =" & qt$ & " ! " & Lin$ & CHR$(10)
320 IF COMPILED
330 PAUSE 50 : REMark Really need to wait until SB completes with no bad line
340 ELSE
350 TYPE_IN "CONTINUE" & CHR$(10) : STOP
360 END IF
370 END REPeat lp
380 END DEFine Vprint
Notice that the STOP command is there, as with VAL$, which is necessary for this code to work. This procedure can be Turbo compiled or Interpreted. It would be a better performer compiled, since there would be no local variables possibly interfering and producing incorrect results. The code would need to be added to, to cope with the multi-tasking of the Turbo code and S*BASIC. Possibly a HOT_DO command may be needed. Also, as noted, Turbo would need to wait until the interpreter's cursor is at the left edge of the window, with no bad line, before continuing and displaying the prompt again. This additional work could be quite involved.
Best regards,
EmmBee