Empty a list of globals
Éric Chatonet
eric.chatonet at wanadoo.fr
Wed Apr 7 12:00:40 EDT 2004
Le 7 avr. 04, à 17:34, Mark MacKenzie a écrit :
> Hit a bit of a stumper for me.
>
> At preopencard time I need to clear a bunch of globals. I created the
> following handler and it doesn't seem to clear the globals involved.
> In
> a succeeding handler they keep their previous values. Am I doing
> something fundamentally wrong?
>
> preOpenCard
> put
> "gBulletCalibre,gBulletDesign,gBulletSizedDiam,gBulletNomWeight,gBullet
> LotCustom"
> into gGlobalsToEmpty
> repeat with x = 1 to the number of items of gGlobalsToEmpty
> put empty into item x of gGlobalsToEmpty
> end repeat
> end preOpenCard
>
> When faced with a series of globals to reset to zero or empty how do
> you
> do it with a minimum of scripting?
>
> Mark MacKenzie
>
Hi Mark,
You have to declare global variables :
on preOpenCard
local tGlobalsToEmpty, tGlobalName
-----
put
"gBulletCalibre,gBulletDesign,gBulletSizedDiam,gBulletNomWeight,gBulletL
otCustom" into tGlobalsToEmpty
repeat for each item tGlobalName in tGlobalsToEmpty
do "global" && tGlobalName
do "put empty into" && tGlobalName
end repeat
end preOpenCard
You can also declare your globals outside the handler at the top of the
script and forget nominal declaration in the preOpencard handler:
global
gBulletCalibre,gBulletDesign,gBulletSizedDiam,gBulletNomWeight,gBulletLo
tCustom
-----
on preOpencard
local tGlobalsToEmpty, tGlobalName
-----
put
"gBulletCalibre,gBulletDesign,gBulletSizedDiam,gBulletNomWeight,gBulletL
otCustom" into tGlobalsToEmpty
repeat for each item tGlobalName in tGlobalsToEmpty
do "put empty into" && tGlobalName
end repeat
end preOpenCard
Hope this helps,
Amicalement,
Éric Chatonet
24, Boulevard de Port-Royal
75005 Paris
More information about the use-livecode
mailing list