This is an old problem, because the act of "checking" for the castmember results in the error itself.

There are a couple of solutions, but I would suggest that at the beginning (depending on how many words you have) you build a list of all available words. Then, you check against that list.

If it's short enough, and constant, you can just hardcode it, but a more flexible way is to scan the casts. Assuming the words are all in a segregated cast (or at least together in another one), you can use functions like:

the number of members in castlib x
the name of member x in castlib y

Basically, find the range you want to check (from 1 to the number of members ..., or from 100 to 500), then start with an empty list and then loop through the range.

For each member, check if the type is #empty (if you expect some to be empty), and if not, and assuming the name isn't "" (an empty string), then add it to your list.

You only want to do this once, unless you expect the castmembers to be changing on the fly.

Then, when you run your code, instead of going to the castmember, first check it against your list and see if it's in there. If it is, then it's valid, and you can safely access the castmember.

- Tab


At 01:33 PM 11/27/02, Sharon Moeller wrote:
In a dictionary application, the user clicks on a word, thus a variable
called gLookup is populated with that word

I am then swapping the definition sprite with that new word

On mouseUp me
  sprite(15).member = member gLookup
End

The problem is when a definition isn't in the cast.  How do I write the
error checking to compensate?

Sharon Moeller
[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