何かの箱

wwwBASIC

Powered by wwwBASIC
wwwBASICはGoogleさんのBASICインタプリタ。ブラウザ上でそのまま動いて、セットアップがとても簡単。 変な書き方をしてなければGW-BASICのソースがだいたいはそのまま動かせてしまい、 「ちょっと遊ぶ」のにとてもとても適しているように思うわけです。とてとてです。 それはそうとQBASICの文法もあれこれ動くことから、ごった煮コードも動いてしまいます。 読みやすさは別として、これはこれで面白い。 SOUNDとかPLAYは今のところTODOみたいですが、それを踏まえてもお手軽だなと。 QBjsあたりもありですが、目的次第ですね。

何ができそうか

ソースを覗いてみた限りでは、以下のような感じでした。(2024/03 時点) 注意点 ・QBASICぽい解釈のようで、行番号なしでも大丈夫、ラベルも使える(行番号はラベル扱い) ・rnd は実装されているものの、Math.random() が実行されるだけなので決まった乱数にはならない ・SLEEP の指定はミリ秒 ・カーソル位置があふれた場合はカーソルは先頭行に戻り、スクロールしない ・SCREEN のモードがとんでもないことになっていて、フルカラーも可

使えそうな命令

screen, width, cls, option explicit, option base defdbl, defsnd, deflng, defint, defstr def fn, declare sub, declare function sub ... end sub, function ... end function exit sub, exit function rem, let, const, double, dim (shared), redim (shared), as sleep, locate, color, swap, data, read, restore, input print (using), getmouse, call draw, paint, circle, pset/preset, line (input), get, put rnd, ucase$, lcase$, chr$, asc, stackdepth, basedepth log, sqr, int, cint, fix, abs, cos, sin, tan, atn, exp, peek, len, instr, ltrim$, rtrim$, space$, string$, tab varptr, atan2, left$, right$, mid$, inkey$, timer, point

使えそうな制御

+, -, /, ~, mod, not, and, or, on error, on goto, on gosub, resume for to (step) ... next, while ... wend do ... loop while/until if ... then ... else ... (end if), elseif select case ... case ... case else ... end select type ... end type goto, gosub, return

未実装だけど文法エラーにはならない

def seg, randomize, poke, key on/off open for input/output as, close system, beep, view print to, view screen sound, play, chain, palette

SCREEN

No size aspect font height palette bpp
0 640x200 2.4 8 16 4
1 320x200 1.2 8 4 2
2 640x200 2.4 8 monochrome 1
7 320x200 1.2 8 16 4
8 640x200 2.4 8 16 4
9 640x350 480/350 14 16 4
11 640x480 1 8 monochrome 2
12 640x480 1 8 16 4
13 320x200 1.2 8 none 24
14 320x240 1 8 none 24
15 400x300 1 8 none 24
16 512x384 1 8 none 24
17 640x400 1.2 8 none 24
18 640x480 1 8 none 24
19 800x600 1 8 none 24
20 1024x768 1 8 none 24
21 1280x1024 1 8 none 24
* パレットがない場合、fg=white, bg=black, 色指定は0xRRGGBB

履歴

20240803 自分のためにも SCREEN の説明を追記 20240413 実行時に入力内容を保存するようにした(indexed db)、空でRUNすれば削除(次回初期値) 20240326 初版