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

18 lines
541 B
Plaintext

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