Skip to content

Instantly share code, notes, and snippets.

@thunderpoot
Last active November 22, 2021 23:51
Embed
What would you like to do?
Program for running BASIC one-liners from the TH prompt
0 rem bas.bas - by underwood
1 rem usage: bas <single line of BASIC code>
10 if left$(arg$,1) = " " then arg$ = mid$(arg$,1) : goto 10
20 if asc(left$(arg$,1)) > 47 and asc(left$(arg$,1)) < 58 then arg$ = mid$(arg$,1) : goto 10
21 rem strip leading spaces and line numbers
30 arg$ = "1 " + arg$
31 rem prepend our line with line number 1
40 & chr$(27) + "[A" + chr$(27) + "[2K" ;
41 rem go up 1 line and clear it
50 f$ = left$(th_md5hex$(th_localtime$),8)
60 flnam$ = f$ + ".bas"
61 rem make a temporary filename
70 open flnam$, as #1
71 rem open our temporary file
80 &# 1, "0 ? chr$(27) + " + chr$(34) + "[A" + chr$(34) + " + chr$(27) + " + chr$(34) + "[2K" + chr$(34) + ";"
81 rem see line 41
90 &# 1, arg$
91 rem write our line to the file
100 close #1
110 cmd$ = "run " + flnam$ : th_exec cmd$
111 rem execute our temporary file
120 cmd$ = "rm " + flnam$ : th_exec cmd$, stderr$
121 rem delete the temporary file
@thunderpoot
Copy link
Author

thunderpoot commented Jan 9, 2021

@bas for i = 1 to 3 : print i : next
 1
 2
 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment