[comp.sys.mac.hypercard] find command - 2 questions

matth@kink.CNA.TEK.COM (Matt Harcourt) (01/03/90)

Two questions from a beginning hypercard programmer...

Is it possible to limit the scope of the find command to a set of
fields rather than a single field?

And a related question,
When using the find command, is it possible (within the script) to
determine where the text that was found is located?  For instance, if
I'm searching a particular field for the occurance of some text I can
tell if the next occurance appears on a different card or background,
but can I determine if the next occurance found is before/after the
previous occurance found if both are on the same card?  What I'm
trying to do is detect when the find "wraps" around to the first
occurance of some text on a card which contains multiple occurances
(and the only occurances) of the text.

Thanks,
-Matt

 ____________________________________________________________________________
 Matt Harcourt               |
 Tektronix Inc.              | CSnet:                    matth@tekred.CNA.TEK
 625 S.E. Salmon             | UUCP:     uunet!tektronix!tekred.CNA.TEK!matth

allen@codon1.berkeley.edu (Edward Allen;345 Mulford;x2-9025) (01/03/90)

Matt Crawford asks two questions about finds, one about restricting finds to 
a set of fields, another about testing the situation in which a string is
found.

Usually to get what you want from a find that is more than a simple one,
you wind up writing scripts using the properties "the foundchunk",
"the foundfield", or "the foundline" to assess whether what you found was
where you wanted it.

the foundChunk returns a description of which characters in which field were
found with a syntax something like "char 2 to 6 of bkgnd field 3"

the foundField is probably the property to test for if you want to restrict to
one of a set of fields, only displaying results if the foundField was
appropriate.

the foundline returns something like "line 3 of card field 5"

These properties were new with HyperCard 1.2, I think.  If you have an older
version, get 1.2.2 or 1.2.5 if using system 6.04.

Ed Allen (allen@enzyme.berkeley.edu)
"

dlugose@uncecs.edu (Dan Dlugose) (01/05/90)

In article <5026@tekred.CNA.TEK.COM> matth@kink.CNA.TEK.COM (Matt Harcourt) writes:
>When using the find command, is it possible (within the script) to
>determine where the text that was found is located?  For instance, if
>I'm searching a particular field for the occurance of some text I can
>tell if the next occurance appears on a different card or background,
>but can I determine if the next occurance found is before/after the
>previous occurance found if both are on the same card?  What I'm
>trying to do is detect when the find "wraps" around to the first
>occurance of some text on a card which contains multiple occurances
>(and the only occurances) of the text.
>

   I use a script for replacing strings only on the card I'm looking at.
The meat of it is:
   put the name of this card into startc
   repeat
       find targ in field x
       if the foundfield is not empty then
           if "bkgnd field 1" is the foundfield then
           if startc = the name of this card

Dan Dlugose
UNC Educational Computing Service