1
1
Fork 0
mirror of https://github.com/boxgaming/qbjs.git synced 2024-09-20 04:24:45 +00:00

Added support for base-8 numbers: created Oct$, enabled Val("&O"...)

This commit is contained in:
William Barnes 2022-04-24 22:41:21 -04:00
parent b8470ba965
commit 49f1732075
4 changed files with 9 additions and 1 deletions

View file

@ -42,7 +42,7 @@ CodeMirror.defineMode("qbjs", function(conf, parserConf) {
'_screenexists', '_sndclose', '_sndopen', '_sndplay', '_sndloop', '_sndpause', '_sndstop', '_sndvol',
'_title', '_trim', '_width', 'abs', 'asc', 'atn', 'chr', 'circle', 'cls', 'color', 'command', 'cos', 'cvi', 'cvl', 'exp',
'fix', 'hex', 'input', 'inkey', 'instr', 'int', 'lbound', 'left', 'lcase', 'len', 'line', 'locate', 'log', 'ltrim', 'mid', 'mki', 'mkl',
'point', 'print', 'pset', 'right', 'rtrim', 'rnd', 'screen', 'shared', 'sgn', 'sin', 'sleep', 'space', 'sqr', 'str', 'swap', 'tan',
'oct', 'point', 'print', 'pset', 'right', 'rtrim', 'rnd', 'screen', 'shared', 'sgn', 'sin', 'sleep', 'space', 'sqr', 'str', 'swap', 'tan',
'timer', 'ubound', 'ucase', 'val',
// QBJS-specific
'alert', 'confirm', 'domadd', 'domcontainer', 'domcreate', 'domevent','domget', 'domgetimage', 'domremove', 'export',

6
qb.js
View file

@ -854,6 +854,10 @@ var QB = new function() {
return ascii.split("").reverse().join("");
};
this.func_Oct = function(n) {
return n.toString(8).toUpperCase();
};
this.func_Point = function(x, y) {
var screen = _images[_activeImage];
var ctx = screen.ctx;
@ -1102,6 +1106,8 @@ var QB = new function() {
var ret;
if (value.substring(0, 2) == "&H") {
ret = parseInt(value.slice(2), 16);
} else if (value.substring(0, 2) == "&O") {
ret = parseInt(value.slice(2), 8);
} else {
ret = Number(value);
}

View file

@ -2531,6 +2531,7 @@ if (QB.halted()) { return; }
await sub_AddQBMethod( "FUNCTION", "Mid$", False);
await sub_AddQBMethod( "FUNCTION", "Mki$", False);
await sub_AddQBMethod( "FUNCTION", "Mkl$", False);
await sub_AddQBMethod( "FUNCTION", "Oct$", False);
await sub_AddQBMethod( "FUNCTION", "Point", False);
await sub_AddQBMethod( "SUB", "Print", True);
await sub_AddQBMethod( "SUB", "PSet", False);

View file

@ -2673,6 +2673,7 @@ Sub InitQBMethods
AddQBMethod "FUNCTION", "Mid$", False
AddQBMethod "FUNCTION", "Mki$", False
AddQBMethod "FUNCTION", "Mkl$", False
AddQBMethod "FUNCTION", "Oct$", False
AddQBMethod "FUNCTION", "Point", False
AddQBMethod "SUB", "Print", True
AddQBMethod "SUB", "PSet", False