[comp.sys.mac.hypercard] How can you tell if a card is there

raphi@shemesh.Eng.Sun.COM (Raphael Rom) (05/12/91)

In a script of stack A I want to take a different action depending upon
the existence or nonexistence of a certain card in stack B.  Going to
that card is of course no good because if the card does not exist an
error occurs which requires user intervention.

Any suggestion?  Is there a more general way to catch errors of this
kind?

Raphi Rom

vanover@bcsaic.UUCP (Jann VanOver) (05/16/91)

raphi@shemesh.Eng.Sun.COM (Raphael Rom) writes:
>In a script of stack A I want to take a different action depending upon
>the existence or nonexistence of a certain card in stack B.  Going to
>that card is of course no good because if the card does not exist an
>error occurs which requires user intervention.

Hypercard 2.0 has a new operator called "There is a" or "There is not a"
which lets you check for existance of objects.  So for your example:
  if there is a card "certain card" of stack "B"
  then take an action
  else take a different action

If you are using Hypercard 1.2.X, there is an XFCN in the Dartmouth XCMD
distributions called "ObjectExists()" that lets you do the same check.
It seems to be a little pickier about quoted strings so I'll include a
sample of how I use it:
  put quote into q   
  put "card "&q&"certain card"&q&" of stack "&q&"B"&q into CheckThisCard
  if ObjectExists(CheckThisCard)
  then take an action
  else take a different action

*** not a coincidence that this ended up in HC2.0, the author of 
ObjectExists is jkc, John Kevin Calhoun who went on to become part 
of the HC 2.0 team and who is ALWAYS a benefit to this newsgroup 
with his helpful advice!  Hi Kevin!

Good Luck Raphael!

Jann
vanover@atc.boeing.com