RosettaCodeData/Task/Multiple-distinct-objects/BBC-BASIC/multiple-distinct-objects.basic

18 lines
541 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
REM Determine object count at runtime:
n% = RND(1000)
REM Declare an array of structures; all members are initialised to zero:
DIM objects{(n%) a%, b$}
REM Initialise the objects to distinct values:
FOR i% = 0 TO DIM(objects{()},1)
objects{(i%)}.a% = i%
objects{(i%)}.b$ = STR$(i%)
NEXT
REM This is how to create an array of pointers to the same object:
DIM objects%(n%), object{a%, b$}
FOR i% = 0 TO DIM(objects%(),1)
objects%(i%) = object{}
NEXT