DragonBASIC
The line-numbered BASIC of DragonOS, from your first program to files, AUTORUN and floppies.
DragonBASIC is a classic line-numbered BASIC for your own programs: farm control panels, menus, counters and games. It runs on DragonOS and can switch redstone, read storage, queue crafting and talk over the network.

Start BASIC
Boot DragonOS on a DragonCPU and start DragonBASIC from the desktop. In the shell, basic does
the same, and basic FARM runs a program straight away. Type BYE to leave.
- A line with a number is stored in the program.
- A line without a number runs at once.
RUNstarts the program,LISTshows it (LIST 100-200shows part of it),NEWclears it.- Ctrl+C stops a running program.
HELPprints a summary.
10 PRINT "HELLO"
RUN
A farm panel
10 CLS
20 PRINT "FARM CONTROL"
30 PRINT "LOGS STORED:"; STOCK("minecraft:oak_log")
40 PRINT "1 = LIGHTS ON 2 = LIGHTS OFF 3 = CRAFT PLANKS Q = QUIT"
50 K$ = INKEY$: IF K$ = "" THEN SLEEP 2: GOTO 50
60 IF K$ = "1" THEN IOSET 3, 0, 1
70 IF K$ = "2" THEN IOSET 3, 0, 0
80 IF K$ = "3" THEN N = CRAFT("minecraft:oak_planks", 4): PRINT "QUEUED"; N
90 IF K$ <> "Q" THEN 30
Keys 1 and 2 switch the white channel of the I/O expander at address 3; key 3 queues four Autocraft crafts of oak planks.
The language
| Statements | Purpose |
|---|---|
PRINT or ? |
Print values. ; joins items, , moves to the next 14-column zone. TAB(n) and SPC(n) position text. |
INPUT ["prompt";] A, B$ |
Wait for the user to type values. |
LET, A = 1, A$ = "TEXT" |
Assign a number, or a string (names ending in $). |
IF … THEN … ELSE … |
Run statements or jump to a line. True is -1, false is 0. |
GOTO, GOSUB, RETURN, ON n GOTO/GOSUB a, b |
Jumps and subroutines. |
FOR I = 1 TO 10 STEP 2 … NEXT I |
Counted loops. |
DIM A(10), B$(5, 5) |
Arrays of up to three dimensions and 10,000 cells. |
DATA, READ, RESTORE |
Constant tables. |
CLS, LOCATE row, column |
Clear the screen and move the cursor (80 × 50). |
SLEEP ticks, RANDOMIZE, END, STOP, REM or ' |
Wait, seed RND, stop, comment. |
Operators are + - * / ^, \ (integer division), MOD, comparisons, AND, OR and NOT.
Functions: ABS INT FIX SGN SQR SIN COS TAN ATN LOG EXP RND PI MIN MAX LEN LEFT$ RIGHT$ MID$ CHR$ ASC STR$ VAL INSTR UCASE$ LCASE$ TRIM$ STRING$ SPACE$ HEX$ INKEY$ TIMER.
INKEY$returns a typed key without waiting. The arrow keys areCHR$(128)toCHR$(131).TIMERis the game time in ticks.
The commands that reach machines, storage and the network are on DragonBASIC machine commands.
Running in the background
A program keeps running after you close the terminal, while its chunk is loaded and a DragonCPU on the network runs. Each running CPU core executes 40 statements per tick. An overheated CPU slows down, and a program pauses while no CPU runs. Running programs and their variables are saved with the world.
Files
| Command | Does |
|---|---|
SAVE "FARM" |
Store the program on a hard drive. |
LOAD "FARM" |
Load it. |
RUN "FARM" |
Load and run it. |
CHAIN "MENU" |
Inside a program: replace it with another file and start that. Variables are cleared. |
DIR |
List files. |
KILL "FARM" |
Delete a file. |
Names have up to 12 letters, digits, - or _. A saved program uses one kilobyte for every started
1,024 characters. While the drive writes it from its cache, the console shows WRITING C:FARM...,
then SAVED C:FARM. Anything you type meanwhile runs afterwards.
AUTORUN
Save a program as AUTORUN on a hard drive and it starts by itself when DragonOS reaches its desktop.
A farm panel then comes back after a server restart or power loss without anyone opening the terminal.
It runs once per boot: BYE returns to the desktop until every DragonCPU on the network is stopped
and started again.
An AUTORUN program acts as the last player who opened DragonBASIC on that terminal for CRAFT,
CANCRAFT, MISSING$ and EXPORT.
Floppies
Prefix a name with A: to use the floppy in a connected drive.
FORMAT "A:"
SAVE "A:FARM"
LOAD "A:FARM"
Format a writable floppy once before the first save. A floppy holds 32 files and about 255 KB. Eject it to give the program to another player.
Scripts
A text file that starts with #!/bin/basic runs as a DragonBASIC program from the shell. See
The dsh shell.