[comp.sys.mac.hypercard] Need help with search algorithm

sutton@TAURUS.CS.NPS.NAVY.MIL (Frank Sutton) (01/26/91)

I need some recommendations on how to script an
algorithm I'm trying to create. I need to input a word
in a card field in stack A. Upon hitting return, the
word in the field will be searched for in various
card fields in stack B. When a match is found, I
want the name of the card it was found on. Any
suggestions would be greatly appreciated. Thanks
for the help.

Frank (sutton@cs.nps.navy.mil)

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (01/26/91)

In article <9101252050.AA03068@taurus.cs.nps.navy.mil>
sutton@TAURUS.CS.NPS.NAVY.MIL (Frank Sutton) writes:
>I need some recommendations on how to script an
>algorithm I'm trying to create. I need to input a word
>in a card field in stack A. Upon hitting return, the
>word in the field will be searched for in various
>card fields in stack B. When a match is found, I
>want the name of the card it was found on.

I'll assume that you have HyperCard 2.0. In 2.0, you can mark all
cards meeting a certain search criterion. This is much faster if you
use "mark cards by finding". This does something like what you
want to do:

  on returnInField
    put card field "Word To Find" into wordToFind
    lock screen
    set the lockMessages to true
    go stack "B"
    unmark all cards -- clear the decks
    mark cards by finding wordToFind
    put empty into foundCardList
    repeat with x = 1 to the number of marked cards
      put the short name of marked card x after foundCardList
    end repeat
    go recent card
    put foundCardList into field "Found Card List"
    set the lockMessages to false
    unlock screen
  end returnInField

You can make the search criterion more complex, at the cost of some
speed, by using "mark cards where" instead of "mark cards by finding";
for instance,

  mark cards where ("x" is in field 1) and ("y" is not in field 2)
-- 
========= jeanne a. e. devoto ========================================
 jdevoto@apple.com     |  You may not distribute this article under a
 jdevoto@well.sf.ca.us |  compilation copyright without my permission.
______________________________________________________________________
 Apple Computer and I are not authorized      |        CI$: 72411,165
 to speak for each other.                     |