Files
gw-basic-2026/tests/programs/def_fn.bas
Eremey Valetov 616259537a Phase 2: variables, arrays, program execution, and control flow
Add variable storage (scalar and array), program line storage with
RUN/LIST/NEW, and full control flow: FOR/NEXT, GOTO, GOSUB/RETURN,
IF/THEN/ELSE, WHILE/WEND, ON GOTO/GOSUB, DATA/READ/RESTORE.

New modules: interp.c (1445 lines - execution loop and statement
dispatcher), vars.c, arrays.c, input.c. Version bumped to 0.2.0.
16 test programs pass including Leibniz pi and prime sieve.
2026-02-10 11:16:58 -05:00

7 lines
173 B
QBasic

10 REM DEF FN test
20 DEF FN SQ(X) = X * X
30 DEF FN CU(X) = X * X * X
40 PRINT "5 squared ="; FN SQ(5)
50 PRINT "3 cubed ="; FN CU(3)
60 PRINT "Sum ="; FN SQ(3) + FN CU(2)