home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-01-01 | 1015 b | 50 lines | [TEXT/MACA] |
- \ suppose you have an array with object addresses stored in it:
-
- 4 array objectArray
-
- \ make three objects
-
- var myVar
- int myInt
- rect myRect
- string myString
- new: myString
-
- myVar myInt myRect myString put: objectArray
-
- \ now put a few values in the objects
-
- 12 put: myVar
- 10 put: myInt
- 10 10 100 100 put: myRect
- " hello" put: myString
-
- \ now draw each object, but late bind to the objects held in the array:
-
- print: [ 0 at: objectArray ]
- print: [ 1 at: objectArray ]
- print: [ 2 at: objectArray ]
- print: [ 3 at: objectArray ]
-
- \ or do it like this
-
- : printStuff limit: objectArray 0 DO print: [ i at: objectArray ] LOOP ;
-
- printStuff
-
- \ suppose myVar points to another object like myRect
-
- myRect put: myVar
-
- print: [ obj: myVar ] \ is the same as
- print: [ get: myVar ]
-
-
- \ note: printstuff will send the print: message to each object in the
- \ objectArray. Since myVar now holds an object itself, to print the
- \ second object (in this case myRect), one must do this:
-
- \ print: [ obj: [ 0 at: objectArray ] ]
-
-
-