Converting Cast Names to Cast Numbers

Date:    Sat, 26 Nov 1994 07:52:32 MST
From:    Chris Malley 
Subject: Re: Using cast member numbers and cast member names in Lingo

> I was wondering if you convert your references to numbers automatically
> or manually (cause I don't think it would be fun to do manually).

This isn't the most "refined" way of doing this, but it works for me...

I have an 'initGlobals' handler that's called from the 'on startMovie' handler. Among other things, it contains all 'number of cast' calls, so that they're isolated in one place. While I'm doing development, I continue to 'the number of cast' to initialize cast nums, offsets, etc. When I test/press, I switch to fixed cast numbering.

Code might look like this:

 
        --*  Cast number globals. Initially, use cast names
        --*  to get the cast numbers.  This block of code will
        --*  be replaced with fixed constants to increase
        --*  performance.
        set gFirstPhotoCastnum = the number of cast "photo1.pic"
        set gFirstMovieCastnum = the number of cast "movie1.pic"
        ...
 
        --*  Generate code that uses fixed cast numbering. The
        --*  generated code replaces the above code to improve
        --*  performance.
        put "BEGIN GENERATED CODE"
        put "set gFirstPhotoCastnum =" && gFirstPhotoCastnum
        put "set gFirstMovieCastnum =" && gFirstMovieCastnum
        ...
        put "END GENERATED CODE"
 
        --*  This block of code was generated by the above section
        --*  of code.  It may be out-of-date, since it depends on
        --*  fixed cast numbering.
        --set gFirstPhotoCastnum = 120
        --set gFirstMovieCastnum = 250
To I freeze the code for pressing a master or testing, I do the following:
  1. Open the Messages window
  2. Start the app so that 'startMovie' gets invoked. Copy all the output that appears between the "BEGIN/END GENERATED CODE" tags in the Message window.
  3. Paste this code into my initGLobals handler, removing extra quotes and other unwanted stuff. (The 3rd chunk of code above is an example.)
  4. Comment out the first block of code in the above example, disabling all 'the number of cast' expressions.
When I go back to doing development, I comment out the generated code, and uncomment the code that uses 'the number of cast'.

There's undoubtedly a better way to do this, but this has worked for me so I haven't been motivated to refine it yet. It does require you to keep all 'the number of cast' stuff in one place, which may be inconvenient. And each time you add a 'the number of cast' call, you need to add a line of code to generate the fixed-position code.

If anyone has a cleaner way of doing this, please post. Chris Malley
Inroads Interactive
Boulder CO