bbc-basic: Define 'load-file' at startup.
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 20 Apr 2019 15:34:23 +0000 (16:34 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 18 May 2019 04:48:32 +0000 (05:48 +0100)
Its definition includes a string, so start putting the startup forms in
DATA statements.  That way they can just be pasted in without further
escaping.  No useful initial form starts with a quotation mark or
contains a comma, so quoting them is never necessary in a DATA
statement.

bbc-basic/step6_file.bbc

index 01e8cdf..e0788d6 100644 (file)
@@ -19,7 +19,15 @@ REPEAT
   ENDIF
 UNTIL sym$ = ""
 
-val$ = FNrep("(def! not (fn* (a) (if a false true)))")
+REM  Initial forms to evaluate
+RESTORE +0
+DATA (def! not (fn* (a) (if a false true)))
+DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))
+DATA ""
+REPEAT
+  READ form$
+  IF form$ <> "" THEN val$ = FNrep(form$)
+UNTIL form$ = ""
 
 REPEAT
   PROCgc_enter