[comp.sys.mac.hypercard] Testing card existence by name

nestor@iitmax.IIT.EDU (John Nestor) (01/28/89)

I would like to test whether a card of a given name exists in a stack
using hypertalk.  There must be an easy way to do this, but I sure can't
find anything.  My current hack is to do a linear search of the cards in
the stack, but this is painfully slow.  Have I overlooked a better way?
-- 
John A. Nestor				UUCP: ...spl1!iitmax!nestor
ECE Department				BITNET: EENESTOR@IITVAX
Illinois Institute of Technology
Chicago, IL 60616			(312) 567-3386

bbs@f444.n161.z1.FIDONET.ORG (Raines Cohen) (01/30/89)

John -
 
Easy.  Just go to the card by name, and then look at "the short name of this card".  If it matches, it exists.  If it doesn't, it doesn't.
 
Yes, a general exists() function would be VERY useful, especially with buttons and fields.
 
-- Raines Cohen
 SYSOP, BMUG BBS

--  
INTERNET:  bmug!User.Name@apple.COM   UUCP: apple!bmug!User.Name

dan@Apple.COM (Dan Allen) (01/30/89)

In article <2064@iitmax.IIT.EDU> nestor@iitmax.IIT.EDU (John Nestor) writes:
>I would like to test whether a card of a given name exists in a stack
>using hypertalk.  There must be an easy way to do this, but I sure can't
>find anything.  My current hack is to do a linear search of the cards in
>the stack, but this is painfully slow.  Have I overlooked a better way?

Try:

  go card foo
  if the result = "no such card" then beep
  
where foo is the name of the card and beep could easily be replaced with
whatever special thing you wanted to do.


Dan Allen                **    dan@apple.COM (Unix mail)
Software Explorer        **    ALLEN.DAN (AppleLink)
HyperCard Team           **    20525 Mariani Ave. MS 22AE
Apple Computer           **    Cupertino, CA 95014
***********************************************************
** Sam:    "You know what they say, 'You can kill more   **
**          flys with honey than with vinegar.'"         **
** Woody:  "I don't mean to butt in, but you can kill    **
**          the most with dead squirrels."               **
***********************************************************