Tom Richardson wrote:
> I have a need to reset all globals (hundreds of them) but hang onto a
> small hand full

Here's a further method. If you use some internal naming convention for your
global variables, all what you need is:

on clearGlobalsSelective()
  repeat with g = 1 to the globals.count()
    if not ("u" = chars(string(the globals.getPropAt(g)), 1, 1)) then the globals[g] = 
VOID
  end repeat
end

The naming convention used here as an example is really simple: you name your
globals at your will, but the ones you want preserved from being cleared are
to be prefixed by a "u", that stands for "unclearable". For example, let's take
these two sets of globals:

global giggle, mumble, titter, roarr, gurgle, gulp, help, swish, slam, gasp, pant
global uGiggle, uMumble, uRoarr, uGulp, uPant, uOffTopic

Some of them are initialized in startMovie, or in whichever else place and time,
while others aren't:

on startMovie                                   
  uGiggle = "..gigglin:)..gigglin:).."
  uMumble = "mumblemumble..."
  uTitter = ":())) :()) ( :)( :)(( :)((( :)()()("
  uRoarr = "RRRRRROAR"
  uGulp = "GULP!!!"
  uPant = 100100100100
  mumble = uMumble
  roarr = uRoarr
  gulp = uGulp
  help = "...HHHHHELP!!!"
  swish = "((< >))----->======>>>>>>>>"
  slam = "[   [  [ [ [[[]~***"
  pant = uPant
  uOffTopic = [#no: 1, #lions: 2, #herein: 3]
end

Run clearGlobalsSelective()in the message window:

-- Welcome to Director --

showglobals

-- Global Variables --
uGULP = "GULP!!!"
uGiggle = "..gigglin:)..gigglin:).."
uPant = 100100100100
uMumble = "mumblemumble..."
uRoarr = "RRRRRROAR"
uOffTopic = [#no: 1, #lions: 2, #herein: 3]

The unprefixed globals aren't listed because showglobals doesn't show void globals.

There's more. If you wanted to init your globals to a some value of specific intrinsic
type, you could do it by a prefix using two characters or more. For example, with a
two-chars prefix:

on initGlobalsHyperSelective()
  repeat with g = 1 to the globals.count()
    px = chars(string(the globals.getPropAt(g)), 1, 2)      -- px is for prefix
    case 1 of
      (px = "uI") : the globals[g] = 0                      -- integer
      (px = "uF") : the globals[g] = 0.0                    -- float
      (px = "uC") : the globals[g] = EMPTY                  -- string of characters
      (px = "uL") : the globals[g] = list()                 -- linear list
      (px = "uP") : the globals[g] = [:]                    -- property list
        -- and so on..
      otherwise
        the globals[g] = VOID
    end case
  end repeat
end

The use of a "u" could seem reduntant in this case. It depends on how things are
organized. Please note I didn't tested this last handler.

Hope this helps,

Franco
Hic sunt leones

FC Programming Consultant
http://www.chnexus.com/main.htm
mailto:[EMAIL PROTECTED]
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to