[Newbies] Re: Best way to implement two-dimensional array
Herbert König
herbertkoenig at gmx.net
Thu Sep 6 09:53:52 UTC 2007
Hello John,
JA> But if I understand what is going on with Classes, as soon as I call
JA> "MyClass initialize", and save the Image, the class variables contain
JA> whatever I put them, and will do unless I do something to clear them
JA> out.
two things to add:
first: are you aware that Alt Shift i will bring up an explorer
instead of an inspector?
There it's easier to change classVars than stepping down to various
inspectors. Be aware that unlike an inspector it doesn't update
automatically.
second:
I have a few classes which I use as lookup tables, stored in
classvars.
For these I implement on the class side a fileIn/Out protocol to move
the classVars between images like e.g.:
TrainingsSamplesFehlerkategorien>>writeTrainingsSamples
"write the class var TrainingsSamples to a file using ReferenceStreams"
| rr |
rr := ReferenceStream fileNamed: 'trainingssamples.obj'.
"trainingsSamples is an accessor to classVar TrainingsSamples
which is a dictionary"
rr nextPut: TrainingsSamplesFehlerkategorien trainingsSamples .
rr close.
rr := nil
and for the opposite direction:
TrainingsSamplesFehlerkategorien>>readTrainingsSamples
"read the class var TrainingsSamples from a file using ReferenceStreams "
| rr |
rr := ReferenceStream fileNamed: 'trainingssamples.obj'.
TrainingsSamplesFehlerkategorien trainingsSamples: rr next.
rr close.
rr := nil
JA> So it doesn't matter whether I set them interactively or with an
JA> initialize method. Either way the class variables contain data.
JA> Furthermore, unless the initialize method changes, there is no actual
JA> need to call it again (though you might want to do so to ensure it's
JA> up to date).
Cheers
Herbert mailto:herbertkoenig at gmx.net
More information about the Beginners
mailing list