Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!claris!apple!dan From: dan@Apple.COM (Dan Allen) Newsgroups: comp.sys.mac.hypercard Subject: Re: efficient cardExists function Message-ID: <12258@apple.Apple.COM> Date: 16 Jun 88 04:45:23 GMT References: <5888@bunny.UUCP> Reply-To: dan@apple.apple.com.UUCP (Dan Allen) Organization: Apple Computer Inc, Cupertino, CA Lines: 26 In article <5888@bunny.UUCP> jwg1@bunny.UUCP (James W. Gish) writes: >I need a function, cardExists( cardName ), that will return true iff >a card of name cardName exists in the stack. > >So far, the only thing I could come up with is a repulsively slow >linear search that compares cardName with the name of each card in >the stack. How about something like push this card get id of this card go card "foo" -- where foo is your card name if it is not the id of this card then pop card -- to get you back where you were -- set some variable so you know the card exists else -- card does not exist, set a variable or whatever end if I haven't tried it but something along these lines should use the full power of HyperCard's fast search when you say go card "foo" and the rest is just error checking. I'm sure there are a variety of ways to check where you are or were or whatever.... Dan Allen Software Explorer Apple Computer