BASIC interpreter
-
You need to have at least version
v14.0.0of node.js installed. -
Install the
node-basic-langlibrary globally:
npm install -g node-basic-lang-
Create a BASIC program using the supported commands below. Make sure that the file ends in
.bas. -
Run the BASIC program that you created
basic <program name>.basExample:
basic game.basYou can use the REPL just by running the following command in the terminal:
basicMake sure that you enter a unique line number for each command, just like you would a normal file. See supported commands below for a list of commands you can use.
ABS - Prints out the absolute value of a number.
CLS - Clears the console.
INT - Prints out an integer by rounding any decimal number down.
PRINT - Prints lines to the console.
REM - Comments for the user. The interpreter ignores these lines.
END - Exits the program.
10 CLS
20 REM "BASIC HELLO WORLD PROGRAM"
30 PRINT "HELLO WORLD"
40 PRINT "HELLO WORLD 2X"
50 PRINT "HELLO WORLD 3X"
60 ABS "-3.14"
70 INT "1.6180"
80 END