[comp.sys.mac.hypercard] Finding Text

slang@bmerh563.bnr.ca (Steven Langlois) (04/24/91)

I'm new to HyperTalk so bare with me. Is there a Find Again type of command in hypertalk
or does find just always find the first occurance from the current card?


Steven Langlois
ISDN Basic Rate Access
BNR, a subsidiary of Northern Telecom

Bitnet: slang@bnr.ca
Bitnet from AppleLink:  slang@bnr.ca@DASNET#                                    

Harry.Myhre@p2.f863.n102.z1.fidonet.org (Harry Myhre) (04/26/91)

Steven Langlois writes in a message to All on 24 Apr 91

SL> I'm new to HyperTalk so bare with me. Is there a Find Again type 
SL> of command in hypertalk or does find just always find the first 
SL> occurance from the current card?

With HC 2.0, yes. Type find "cat" into the message box and press return. HC
2.0 will find the first occurance of cat in your stack and put a rectangle around
it. Press return again and it will find the next occurance.
 

--  
: Harry Myhre - via FidoNet node 1:102/851 (818)352-2993
: ARPA/INTERNET: Harry.Myhre@p2.f863.n102.z1.fidonet.org
: UUCP: ...!{elroy,elroy!bohica}!mcws!863.2!Harry.Myhre
: Compu$erve: >internet:Harry.Myhre@p2.f863.n102.z1.fidonet.org

oddjob@oz.plymouth.edu (Andrew C. Stoffel) (05/01/91)

In article <284.2819CAE4@mcws.fidonet.org> Harry.Myhre@p2.f863.n102.z1.fidonet.org (Harry Myhre) writes:
>
>Steven Langlois writes in a message to All on 24 Apr 91
>
>SL> I'm new to HyperTalk so bare with me. Is there a Find Again type 
>SL> of command in hypertalk or does find just always find the first 
>SL> occurance from the current card?
>
>With HC 2.0, yes. Type find "cat" into the message box and press return. HC
>2.0 will find the first occurance of cat in your stack and put a rectangle around
>it. Press return again and it will find the next occurance.
Ok..... (I knew that one......) BUT
how would one do it within a script ????? Do I HAVE to put what I'm
looking for into the msg box along with find and send a return until
there are no more occurances of what I looking for ???

I have a stack of 108 cards (with the possibility(sp?) of MORE) with
eleven fields on each that I want to search & then mark the card for
viewing or printing. I can mark cards with
	mark cards
 etc. and then act on those marked cards but this seems to work ONLY
if I tell it to check one field. This is fine for some things (and I
use it for them). How do I get it to mark EVERY card that contains
something in A field that I am looking for ??

Find doesn't SEEM to work from a script ....

-- 
|"The Snark WAS a Boojum, you see!"|Good   : acs@unhd.unh.edu       |
|"Reality !?! Isn't that something |Better : ANDYS@psc.plymouth.edu |
|    you sprinkle on ice ??"       |Best   : oddjob@oz.plymouth.edu |

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (05/02/91)

In article <1991May1.151453.14818@oz.plymouth.edu> oddjob@oz.plymouth.edu
(Andrew C. Stoffel) writes:
>I have a stack of 108 cards (with the possibility(sp?) of MORE) with
>eleven fields on each that I want to search & then mark the card for
>viewing or printing. I can mark cards with
>	mark cards
> etc. and then act on those marked cards but this seems to work ONLY
>if I tell it to check one field. This is fine for some things (and I
>use it for them). How do I get it to mark EVERY card that contains
>something in A field that I am looking for ??

If I understand you correctly, what you want is

  unmark all cards
  mark cards by finding "foo"
  go first marked card

and then in your "find again" button

  on mouseUp
    go next marked card
  end mouseUp
-- 
========= 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.                     |

gilbert@MDI.COM (John Gilbert) (05/02/91)

In article <1991May1.151453.14818@oz.plymouth.edu> oddjob@oz.plymouth.edu (Andrew C. Stoffel) writes:
>
>Find doesn't SEEM to work from a script ....

There are some subtle aspects to using find that I think I have reasoned
out by experimentation.  I had similar problems to what you described.
The bottom line centers around the find text remaining hilited.

If you do a find, and move to a card, the found text will be selected.  If
you are doing this from within a script, it will work, but if you do anything
else in the script prior to issuing your next find that causes the found text
to no longer be "selected", then a subsequent find will find the same text
again.

The find operation is designed to find each occurance of something, including
the "next" occurance on a card.  The currently selected text on a card is a
cursor of sorts, indicating where the next search will begin from (how you
percieve what fields are next or previous, or at all serial may be a trick,
perhaps it is handled by field number sequence??).  If nothing is selected,
it seems to start at the beginning of the card.

What I did in situations like you described, situations that involve
identifying cards with ANY occurance (one or more) of the text I was looking
for, was to do something like:

on foo
   repeat
     find "meaning of life"
     --
     -- do all kinds of stuff
     --
     go next card
  end repeat
end foo

Find works, and quite logically.  But there are some things that you may not
always consider.  Most of the time I want to use it to find cards.  But
there may be cases where I may want to find each instance of text on a card.
I have even been fooled by it finding text in hidden fields.  Now that
2.0 offers the "don't search" property, that can be fixed in some cases.

You should really check into the used of the mark all cards with...
functionality, as it may provide an even better solution.

John Gilbert

-- 
John Gilbert
gilbert@MDI.COM
..!uunet!mdisea!gilbert

weiss@watson.seas.ucla.edu (Michael Weiss) (05/03/91)

You're right...it is next to impossible to do the find multiple times in a
script.  I actually gave up on doing it that way, and found a wonderful (but
incredibly slow) XCMD/XFCN set that does finds throughout the entire stack,
and takes you through the cards one by one.  It came on the CAMEO stack from
NOAA.
--
\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | /
-  Michael Weiss  weiss@watson.seas.ucla.edu  |  School of Engineering and  -
-                 izzydp5@oac.ucla.edu        |    Applied Science, UCLA    -
/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | \ 

cdlee@aix01.aix.rpi.edu (CHUNDA LEE) (05/04/91)

In article <284.2819CAE4@mcws.fidonet.org> Harry.Myhre@p2.f863.n102.z1.fidonet.org (Harry Myhre) writes:
>
>Steven Langlois writes in a message to All on 24 Apr 91
>
>SL> I'm new to HyperTalk so bare with me. Is there a Find Again type 
>SL> of command in hypertalk or does find just always find the first 
>SL> occurance from the current card?
>
>With HC 2.0, yes. Type find "cat" into the message box and press return. HC
>2.0 will find the first occurance of cat in your stack and put a rectangle around
>it. Press return again and it will find the next occurance.
> 
>
>--  
>: Harry Myhre - via FidoNet node 1:102/851 (818)352-2993
>: ARPA/INTERNET: Harry.Myhre@p2.f863.n102.z1.fidonet.org
>: UUCP: ...!{elroy,elroy!bohica}!mcws!863.2!Harry.Myhre
>: Compu$erve: >internet:Harry.Myhre@p2.f863.n102.z1.fidonet.org

In HyperTalk, one easy way to find all the "text" is put the FIND in a repeat route and put the condition "if the result is empty then exit repeat". In this subroutine you can add something you want to do after you find the string.

CD LEE,  cdlee@rpi.edu
Rensselaer Polytechnic Institute