von dp am 06.Juli 97 um 16:25:56:
>Paul M. Hemmer wrote:
>
>>...It seems that you cannot declare
>>global variables using the 'do' statement,
and Joe Sparks replied (in parts)
>just do a do declare (used to work, haven't needed this for years)
>snip...
>By the way, using tons of globals this way is very bad form indeed, and
>should only be used if there is no other way to contains the values. A
>list is usually a far superior way to hold a range of values.
>
Sure enough. (Just for the record: I once wanted to check limits and used
the handler published in the other post to crash director by creating
globals and I hit the wall at about 25,000.)
Also, the do statement is quite slow, it may take up to 7 times longer to
DO compared with to SEND a command.
On the other hand, do is very flexible. I can have a list Ldirty and
whenever I puppet a sprite, create an object, etc. that may create a
problem if the user chooses to jump somewhere else I add the code to
destroy that object-or-whatever to that list as a string that can be DOne.
Now, instead of a lot of if-then-else-docase I just call the cleanUp
handler which one by one executes the buggers via the stored code in the
list.
set viele=Count(LDirty)
repeat with rum = 1 to viele
do getat(LDirty,rum)
end repeat
set LDirty=[]
I could write a bazillion of specific handlers and call them via SEND but I
prefer to do all this on the fly. Creating globals with do is a sine qua
non for this since, regardless whether I use 25,000 globals or just 5
global property lists I still have to access them to get rid of an object.
Another scenario where creating globals via do is quite useful is a 'fake a
miaw in shockwave' situation. In other words: create a group of sprites
with a certain content plus the object/s that control those sprites with a
single line of lingo.
The key is the puppeting-an-empty-sprite technique discussed here earlier
by Gretchen MacDowall et.al. In design time I 'record' all the relevant
sprite properties of the sprites in question to a property list with the
sprite as the property. To this I addProp the necessary lingo to new/birth
the controlling objects as a DOable string with the name of the global that
object lives in as the property. Now a handler can take this list as a
paraameter aand process it one by one, puppet an empty sprite if the
property is an integer or perform some lingo (birth an object) if the
property is not an integer.
At least parts of this have been used in a Bezier design tool that wraps
some code around Darrel Plant's Bezier lingo to allow a
drag&drop-a-frameScript design of animations along bezier curves.
Daniel Plaenitz
D. Plänitz