30 lines
754 B
QBasic
30 lines
754 B
QBasic
|
|
10 REM A TYPE declares its fields; each takes its own type from its own suffix,
|
||
|
|
20 REM which is the same rule every other name in this language follows.
|
||
|
|
30 TYPE POINT
|
||
|
|
40 X#
|
||
|
|
50 Y#
|
||
|
|
60 END TYPE
|
||
|
|
70 TYPE SHAPE
|
||
|
|
80 NAME$
|
||
|
|
90 ORIGIN@ AS POINT
|
||
|
|
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 POINT
|
||
|
|
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#
|