Compare commits
2 Commits
252b39dc08
...
7a8c663315
Author | SHA1 | Date |
---|---|---|
Joshua Bell | 7a8c663315 | |
Colin Leroy-Mira | 3d37fc357a |
24
basic.js
24
basic.js
|
@ -1131,9 +1131,27 @@ this.basic = (function() {
|
|||
return state.prng.last;
|
||||
}, 'number', 'number');
|
||||
|
||||
funlib[kws.LEFT$] = funcsign(function LEFT$(s, n) { return s.substring(0, n); }, 'string', 'string', 'number');
|
||||
funlib[kws.MID$] = funcsign(function MID$(s, n, n2) { return n2 === (void 0) ? s.substring(n - 1) : s.substring(n - 1, n + n2 - 1); }, 'string', 'string', 'number', 'number?');
|
||||
funlib[kws.RIGHT$] = funcsign(function RIGHT$(s, n) { return s.length < n ? s : s.substring(s.length - n); }, 'string', 'string', 'number');
|
||||
funlib[kws.LEFT$] = funcsign(function LEFT$(s, n) {
|
||||
if (n < 1 || n > 255) {
|
||||
runtime_error(ERRORS.ILLEGAL_QUANTITY);
|
||||
}
|
||||
return s.substring(0, n);
|
||||
}, 'string', 'string', 'number');
|
||||
funlib[kws.MID$] = funcsign(function MID$(s, n, n2) {
|
||||
if (n < 1 || n > 255) {
|
||||
runtime_error(ERRORS.ILLEGAL_QUANTITY);
|
||||
}
|
||||
if (n2 < 0 || n2 > 255) {
|
||||
runtime_error(ERRORS.ILLEGAL_QUANTITY);
|
||||
}
|
||||
return n2 === (void 0) ? s.substring(n - 1) : s.substring(n - 1, n + n2 - 1);
|
||||
}, 'string', 'string', 'number', 'number?');
|
||||
funlib[kws.RIGHT$] = funcsign(function RIGHT$(s, n) {
|
||||
if (n < 1 || n > 255) {
|
||||
runtime_error(ERRORS.ILLEGAL_QUANTITY);
|
||||
}
|
||||
return s.length < n ? s : s.substring(s.length - n);
|
||||
}, 'string', 'string', 'number');
|
||||
|
||||
funlib[kws.POS] = funcsign(function POS(n) { return env.tty.getCursorPosition().x; }, 'number', 'number');
|
||||
funlib[kws.SCRN] = funcsign(function SCRN(x, y) {
|
||||
|
|
|
@ -592,19 +592,51 @@
|
|||
: S = (LEN("") = 0) : GOSUB 1
|
||||
|
||||
11020 T$ = "LEFT$()"
|
||||
: S = (LEFT$("ABC",0) = "") : GOSUB 1
|
||||
: S = (LEFT$("ABC",2) = "AB") : GOSUB 1
|
||||
: S = (LEFT$("ABC",4) = "ABC") : GOSUB 1
|
||||
: ONERR GOTO 11022
|
||||
11021 T = 1
|
||||
: T = (LEFT$("A",0) = "NOPE")
|
||||
11022 S = (T=1) : GOSUB 1 : POKE 216,0
|
||||
: ONERR GOTO 11024
|
||||
11023 T = 1
|
||||
: T = (LEFT$("A",256) = "NOPE")
|
||||
11024 S = (T=1) : POKE 216,0 : GOSUB 1
|
||||
|
||||
11030 T$ = "MID$()"
|
||||
: S = (MID$("ABCD",2,2) = "BC") : GOSUB 1
|
||||
: S = (MID$("ABCD",3) = "CD") : GOSUB 1
|
||||
: S = (MID$("ABCD",4,3) = "D") : GOSUB 1
|
||||
: S = (MID$("ABCD",5,4) = "") : GOSUB 1
|
||||
: ONERR GOTO 11032
|
||||
11031 T = 1
|
||||
: T = (MID$("A",0) = "NOPE")
|
||||
11032 S = (T=1) : GOSUB 1 : POKE 216,0
|
||||
: ONERR GOTO 11034
|
||||
11033 T = 1
|
||||
: T = (MID$("A",256) = "NOPE")
|
||||
11034 S = (T=1) : POKE 216,0 : GOSUB 1
|
||||
: S = (MID$("A",1,0) = "") : GOSUB 1
|
||||
: ONERR GOTO 11036
|
||||
11035 T = 1
|
||||
: T = (MID$("A",1,-1) = "NOPE")
|
||||
11036 S = (T=1) : POKE 216,0 : GOSUB 1
|
||||
: ONERR GOTO 11038
|
||||
11037 T = 1
|
||||
: T = (MID$("A",1,256) = "NOPE")
|
||||
11038 S = (T=1) : POKE 216,0 : GOSUB 1
|
||||
|
||||
11040 T$ = "RIGHT$()"
|
||||
: S = (RIGHT$("ABC",0) = "") : GOSUB 1
|
||||
: S = (RIGHT$("ABC",2) = "BC") : GOSUB 1
|
||||
: S = (RIGHT$("ABC",4) = "ABC") : GOSUB 1
|
||||
: ONERR GOTO 11042
|
||||
11041 T = 1
|
||||
: T = (RIGHT$("A",0) = "NOPE")
|
||||
11042 S = (T=1) : GOSUB 1 : POKE 216,0
|
||||
: ONERR GOTO 11044
|
||||
11043 T = 1
|
||||
: T = (RIGHT$("A",256) = "NOPE")
|
||||
11044 S = (T=1) : POKE 216,0 : GOSUB 1
|
||||
|
||||
|
||||
12000 PRINT : PRINT "Type Conversion Functions ";
|
||||
|
|
Loading…
Reference in New Issue