robhagemans / basicode-interpreter Goto Github PK
View Code? Open in Web Editor NEWBASICODE interpreter in Javascript
License: Other
BASICODE interpreter in Javascript
License: Other
E.g. BOB5 17R Spel-spel
Should not accept A$=1
etc.
Sequential storage, could fix times by number of bytes
Shouldn't.
Core interpreter should produce screen, run program stored in script
Listing screen, printer, floppy visualisation, drag & drop functionality should move to online app
INPUT A,B,C
- not correct BASICODE but occurs in some programs. This would be expected to accept 1,2,3
rather than 1 <Enter> 2 <Enter> 3 <Enter>
First run shows error due to program text becoming literally "null"
If you backspace over the INPUT prompt "? " and enter text it hangs or throws a JS exception. Run the test program below and press BACKSPACE once and then e.g. P and Enter; the browser tab hangs after a while. If you delete more before entering text, you get: "EXCEPTION RangeError: Invalid string length". I think it would be better if backing over the prompt was disallowed (as it is in your pcbasic) or it didn't hang or threw an exception, but instead sent the typed characters and ignored more backspaces than was needed. Now there is a great risk that a user hangs a program that they have worked with, to get a result, for a long time.
1000 A=100: GOTO 20: REM INPUT TEST
1010 INPUT "ENTER A STRING";A$
1020 PRINT "THE STRING IS: ";A$
1030 GOTO 1010
30000 REM DEMONSTRATES A BUG IN INPUT
30010 REM ENTER BACKSPACE AND A CHARACTER AND ENTER: IT HANGS.
30030 REM ENTER SEVERAL BACKSPACES AND A CHARACTER: A JS EXCEPTION.
30040 REM WHAT I EXPECTED: EITHER THAT BACKSPACE WOULDN'T BACK
30050 REM OVER THE PROMPT "? ", OR THAT IT WOULD ACCEPT THE TYPED
30060 REM CHARACTERS AS INPUT.
I use Chromium Version 92.0.4515.98 (Official Build) Built on Raspbian , running on Raspbian 10 (32-bit), on Raspberry Pi 4 B 8 GiB.
Undefined.call
Version identifier, introduced with 3C.
Does not load the demo program anymore.
TypeError: Cannot read property 'width' of undefined
at Program.subClear (basicode.js:2850)
at Node.evaluate (basicode.js:1456)
at Node.step (basicode.js:1461)
at step (basicode.js:4034)
Various/Boekhoudprogramma line 1880
A trail of the cursor (white block) is sometimes left on the screen after entering input. See e.g. BASICODE-3 COMPUTER BULLETIN on Firefox.
If the program in LocalStorage causes a crash, it's not possible to delete it or load another one without manually clearing LocalStorage
Use LocalStorage. Could also allow storing programs onto "drives" and run from there
NEXT
in branches and multiple FOR
for one NEXT
(with GOTO
to select between them ) are historic facts, handle them as old BASICs would have
BASICODE follows Spectrum/C64 etc convention that a keyword anywhere is recognised - so IFA=WTHEN100
is acceptable. The interpreter currently only recognises keywords at the start of an alpha string, i.e. IFA
is recognised as IF A
but the keyword in WTHEN
is not recognised.
(In practice this matters little as a space is usually used to separate the latter case)
See SAMMELSURIUM/JOURNALE/STOP - we should be able to toggle the break key on and off but it appears disables throughout the program.
Value should be such that the effect of the key is reproduced.
For some reason, the stop symbol becomes bright blue and the button slightly higher, whereas the play symbol is grey as usual. This may have something to do with touchscreen-specific css?
e.g. FAXICODE source should not throw exception
after changes, can't access the program or listing when there are syntax errors.
e.g. BOB2 wereldtijden
Maybe related to other flashing/ colour issues
additional CN
return value occurs in GOSUB 220
, not GOSUB 200
(see journal inBASC-3C.ASC
). Value is such that CHR$(CN+IN)
reproduces the screen character case sensitively.
READ A$: PRINT ASC(A$): DATA 2
no type checks mean a number is read into string var, then crash onASC
. Program likely expects 2
to be read as "2"
(incorrect per spec but usual MS BASIC behaviour)
see VIC on VC8
Implementation assumes 3 separate drives, but files on the higher numbers should be on the same drive.
In BOB5 Topografie, characters are supposed to be flashing but are almost (if on white) or completely (if on black) invisible.
A program with GOSUB 20
instead of the (correct) GOTO 20
would function correctly, simply running the whole program as a big subroutine and terminating before the matching RETURN
. E.g. in VC8, track 16 "English".
Currently they set background colour to present value of CC(1)
Hi!
I was using the basicode-interpreter to develop a BASICODE program. For this use-case it is really handy, but there is a major pitfall: it's very easy to write code which does not satisfy the requirements of correct BASICODE and therefore will not run correctly when loaded into other interpreters.
I propose the addition of an optional strict mode, which issues syntax or runtime errors for non-conformant code.
Examples include the 60 character limit on lines and the variable naming restrictions mentioned in the BASICODE documentation.
Another issue I personally hit is that the interpreter returns the bitwise result for AND and OR. Unfortunately, that behavior should not be relied on in BASICODE, where only logical AND and OR should be assumed. (For example, 2 AND 1 on a ZX Spectrum is 2.)
Thanks again for your awesome work!
GOSUB 540 etc only?
Problem:
If program hangs interpreter in Firefox, after stopping the js script and refreshing the tab, the interpreter will autorun the bad program (even if you paste the url of the interpreter in another tab). And this continues after restarting the browser.
What should happen:
The interpreter shouldn't autorun the program (on refresh / restart of the browser / pasting interpreter url in another tab). Or it should load the demo program instead of auto-executing the custom code.
Bypass:
Switching HTTP protocol (from ex. http to https) allows you to run new instance of interpreter. Side note: under https, the tape storage doesn't work (tape list doesn't show).
Code that hangs the script (in the last 3 lines I didn't add "10" to the line numbers in THEN and GOTO):
1000 A=100:GOTO20
1010 LET W=500:DIM F(W):LET P=1:LET A=3
1020 LET F(P)=A:LET P=P+1:IF P>W THEN GOTO 950
1030 LET A=A+2:LET X=1
1040 LET S=A/F(X):IF S=INT(S) THEN 30
1050 LET X=X+1:IF X<P AND F(X)*F(X)<=A THEN 40
1060 GOTO 20
FOR without NEXT in 15350
but there is no such line
Just stops parsing - I thought I raised an error here.
Boekhoudprogramma stops with error:
Syntax error in 1880
expected ':', got '#'
1880 INPUT SR#
- it seems that types aren't supported (except $), by design or not.
Modified Boekhoudprogramma: robhagemans/basicode@d4a0ba6
Modified Weer: robhagemans/basicode@46455ad
BASICODE.js 2221
Breaks on Chrome 40, but apparently not on my Chrome...
Although not allowed, this occurs in the repo (e.g. VC8 A15 Filterberekening)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.