Path: utzoo!mnetor!uunet!husc6!cmcl2!nrl-cmf!ames!pasteur!agate!violet.berkeley.edu!edmoy From: edmoy@violet.berkeley.edu Newsgroups: comp.sys.mac.hypercard Subject: Re: Searching a stack and creating a list of matching cards... Message-ID: <9635@agate.BERKELEY.EDU> Date: 5 May 88 18:21:09 GMT References: <2051@bgsuvax.UUCP> <1964@ur-tut.UUCP> Sender: usenet@agate.BERKELEY.EDU Reply-To: edmoy@violet.berkeley.edu.UUCP () Distribution: na Organization: University of California, Berkeley Lines: 56 Keywords: Help! In article <1964@ur-tut.UUCP> aisl@tut.cc.rochester.edu.UUCP (Larry Landry) writes: >on mouseUp > push card -- save the current card > ask "Grep for what" -- what do you want to grep for? > put empty into cardList -- start with no cards in list > > find it -- find 1st occurence of text > put the id of this card into startCard -- save it to test for end of list > repeat > put the id of this card & return after cardList -- add this card to list > find it -- find the next card > if the id of this card is startCard then exit repeat -- are we done? > end repeat > > pop card -- back to original card > put cardList into card field "grep list" -- display the list >end mouseUp > >This does have one known limitation; if the first card on which the string >is found has more than one occurence of the string, only that card will be >shown. This may be a major drawback for some applications and no problem >for others. There may be a simple way around that but I haven't looked too >deeply for one yet. I've used this technique before and have also come across this problem. Fortunately, there is an easy fix. Simply add: go next card just before the "find it" inside the repeat loop. This even works in the case of a single card, since the "go next card" will stay on the same card, and the find will succeed again (assuming the initial find succeeded). To test for the initial success, add: if the result is not empty then answer quote & it & quote && "not found." exit mouseUp end if after the first find statement. And to be knit-picky, you should have if it is empty then exit mouseUp after the ask statement, in case they hit the cancel button or don't put in a search string. Edward Moy Workstation Software Support Group University of California Berkeley, CA 94720 edmoy@violet.Berkeley.EDU ucbvax!violet!edmoy