mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-16 16:06:06 +09:00
basic:spc stmt and more sample codes
This commit is contained in:
@@ -699,7 +699,10 @@ if no arg text were given (e.g. "10 NEXT"), args will have zero length
|
||||
"END" : function(lnum, args) {
|
||||
serial.println("Program terminated in "+lnum);
|
||||
return Number.MAX_SAFE_INTEGER; // GOTO far-far-away
|
||||
}
|
||||
},
|
||||
"SPC" : function(lnum, args) {
|
||||
return oneArgNum(lnum, args, function(lh) { return " ".repeat(lh); });
|
||||
},
|
||||
};
|
||||
Object.freeze(bStatus.builtin);
|
||||
let bF = {};
|
||||
@@ -1676,6 +1679,7 @@ bF.system = function(args) { // SYSTEM function
|
||||
tbasexit = true;
|
||||
};
|
||||
bF.new = function(args) { // NEW function
|
||||
bStatus.vars = initBvars();
|
||||
cmdbuf = [];
|
||||
};
|
||||
bF.renum = function(args) { // RENUM function
|
||||
@@ -1744,7 +1748,11 @@ bF.load = function(args) { // LOAD function
|
||||
}
|
||||
let prg = fs.readAll();
|
||||
|
||||
// reset the environment
|
||||
cmdbuf = [];
|
||||
bStatus.vars = initBvars();
|
||||
|
||||
// read the source
|
||||
prg.split('\n').forEach(function(line) {
|
||||
let i = line.indexOf(" ");
|
||||
let lnum = line.slice(0, i);
|
||||
|
||||
6
assets/gugu.bas
Normal file
6
assets/gugu.bas
Normal file
@@ -0,0 +1,6 @@
|
||||
10 FOR I = 2 TO 9
|
||||
20 FOR J = 1 TO 9
|
||||
30 PRINT I; "*"; J; "="; I * J
|
||||
40 NEXT
|
||||
50 INPUT "Press Enter Key..."; A
|
||||
60 NEXT
|
||||
7
assets/tri.bas
Normal file
7
assets/tri.bas
Normal file
@@ -0,0 +1,7 @@
|
||||
10 FOR I = 1 TO 20
|
||||
20 PRINT SPC(20-I);
|
||||
30 FOR J = 1 TO I*2
|
||||
40 PRINT "*";
|
||||
50 NEXT
|
||||
60 PRINT ""
|
||||
70 NEXT
|
||||
Reference in New Issue
Block a user