Files
akbasic/tests/language/structures/records.bas
Logikoma 221ed7219d Keep BASIC fixtures within the input line limit
Reflow the approved reference cases, shorten local fixture comments, and split the executable docs line so the 80-byte input buffer can read every source line.

Co-authored-by: andrew <andrew@aklabs.net>
2026-08-04 18:50:44 -04:00

30 lines
746 B
QBasic

10 REM A TYPE declares fields; each takes its type from its own suffix,
20 REM which is the same rule every other name in this language follows.
30 TYPE COORD
40 X#
50 Y#
60 END TYPE
70 TYPE SHAPE
80 NAME$
90 ORIGIN@ AS COORD
100 AREA%
110 END TYPE
120 DIM A@ AS SHAPE
130 DIM B@ AS SHAPE
140 A@.NAME$ = "FIRST"
150 A@.ORIGIN@.X# = 10
160 A@.ORIGIN@.Y# = 20
170 A@.AREA% = 2.5
180 REM Assignment COPIES. B@ is its own record from here on.
190 B@ = A@
200 A@.NAME$ = "CHANGED"
210 A@.ORIGIN@.X# = 99
220 PRINT A@
230 PRINT B@
240 REM A whole nested record copies as a unit too.
250 DIM P@ AS COORD
260 P@ = B@.ORIGIN@
270 PRINT P@
280 REM And a structure renders with its type name and its fields.
290 PRINT B@.ORIGIN@.X# + B@.ORIGIN@.Y#