Legacy screen and keyboard
KEY, SCREEN(), CSRLIN and POS() in Cortex BASIC 1.0.1, with browser limitations and execution performance.
Cortex BASIC reference · language features and browser requirements.
Inspect the text screen
SCREEN(row,column[,colorflag]) reads the shared virtual text screen. Coordinates start at 1. A blank cell returns 32; a character returns its character code. Nonzero colorflag returns background × 16 + foreground. Invalid coordinates report Illegal function call. CSRLIN is the historical spelling (not CSRLN); POS(0) reports the column and accepts any numeric dummy argument.
CLS
COLOR 14,1
LOCATE 3,5
PRINT "AB";
R=CSRLIN: C=POS(0)
A=SCREEN(3,5): ATTR=SCREEN(3,5,1)
PRINT R;",";C;",";A;",";ATTRThe queries follow PRINT, INPUT echo, LOCATE, WIDTH, VIEW PRINT, wrapping, scrolling and CLS. Default text dimensions are 80 × 25. WIDTH supports 40/80 columns and 25/43/50 rows. This browser uses all rows unless KEY labels or VIEW PRINT reserve a region. SCREEN() supports the single text page in SCREEN 0; graphics character recognition and text-page switching are not emulated.
Function keys and event handlers
KEY n,"text" assigns up to 15 characters to F1–F10 (1–10), F11 (30), or F12 (31). An empty string restores the normal extended key code. KEY ON displays labels; KEY OFF removes labels without disabling macros. KEY LIST lists assignments. Read macros through INKEY$ or INPUT$.
KEY OFF
ON KEY(11) GOSUB up
KEY(11) ON
DO
K$=INKEY$
LOOP UNTIL K$=CHR$(27)
END
up: PRINT "Up pressed": RETURNKEY(n) ON enables trapping, STOP retains a pending event until ON, and OFF discards pending events. Keys 11–14 are Up, Left, Right and Down. Keys 15–25 accept a two-byte modifier/scan definition. Either Shift is reported as the combined Shift flag (3); Ctrl=4, Alt=8, Num Lock=32, Caps Lock=64. Browser/OS reserved keys cannot be guaranteed. Blocking INPUT uses the browser line editor without macros or traps. Mobile devices need an external keyboard for physical function keys.
Execution performance
Version 1.0.1 fixes unnecessary timer delays and batches text delivery. The runtime yields cooperatively in short time slices to process keyboard input and Stop. There is one automatic execution speed. Use TIMER, SLEEP, or Cortex timers to time animations; empty counted loops naturally run faster. Explicit waits and sound timing retain their behavior.
Hardware and project files
INP and OUT report an unsupported-operation BASIC error: browsers do not provide raw PC hardware-port access. No arbitrary port emulation is claimed. Existing project-scoped file support includes OPEN/CLOSE, INPUT #, LINE INPUT #, PRINT #, WRITE #, GET/PUT, EOF, LOF, LOC, SEEK, FILES, KILL and NAME. DOS devices, OS file handles and cross-process locks are unavailable. See file I/O for formats, storage and limits.