jwg1@bunny.UUCP (James W. Gish) (06/16/88)
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. -- Jim Gish GTE Laboratories, Inc., Waltham, MA CSNET: jgish@gte.com UUCP: ..!harvard!bunny!jwg1
dan@Apple.COM (Dan Allen) (06/16/88)
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
PGREENEA@RICE.BITNET (06/17/88)
In article 5888@bunny.uucp, jwg1@bunny.uucp (Jim Gish) says... >I need a function CardExists ( cardName ) that will return true iff >a card of name cardName exists in the stack. One way, perhaps not the best, is -------------------------------- push card go to card cardName if the result is empty then put true into itExists else put false into itExists end if pop card -------------------------------- If the card isn't there, the result will contain either "Can't find card cardName" or "No such card"; I think it depends on the version of HyperCard (the first message for 1.0.1, the second for 1.1 and 1.2). Pam Greene Rice University PGREENEA@ICSA.RICE.EDU Neither ICSA nor Rice (nor anyone else, for that matter) necessarily agrees with me. I'm just a student, after all; what do I know?
jtw@dadent (Trent Wohlschlaeger) (06/18/88)
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. > >... >-- >Jim Gish >GTE Laboratories, Inc., Waltham, MA >CSNET: jgish@gte.com UUCP: ..!harvard!bunny!jwg1 Correct me if I'm wrong, (I don't have my <several necessary> Hypercard manuals handy) but doesn't go to cardName if the result is not empty then -- the card does not exist else -- the card exists, have fun end if work? This also leaves you on the current card without any further scripting if the desired card does not exist, unless I also have fallen prey to the D-RAM shortage.