Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!eos!labrea!decwrl!sun!hanami!landman From: landman%hanami@Sun.COM (Howard A. Landman) Newsgroups: comp.sys.mac.hypercard Subject: Re: Searching a stack and creating a list of matching cards... Message-ID: <52572@sun.uucp> Date: 9 May 88 23:59:42 GMT References: <2051@bgsuvax.UUCP> <1964@ur-tut.UUCP> Sender: news@sun.uucp Reply-To: landman@sun.UUCP (Howard A. Landman) Distribution: na Organization: Sun Microsystems, Mountain View Lines: 39 Keywords: Help! In article <1964@ur-tut.UUCP> aisl@tut.cc.rochester.edu.UUCP (Larry Landry) writes: >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. The code that needs to be changed is the line > if the id of this card is startCard then exit repeat -- are we done? The middle section of Larry's code: > 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 needs to be changed to something like (I haven't tested this): find it -- find 1st occurence of text -- Should have a test here for not finding it! put the id of this card into startCard -- save it to test for end of list put the id of this card & return after cardList -- add this card to list go next card -- make sure we don't stop on first card by mistake repeat find it -- find the next card if the id of this card is startCard then exit repeat -- are we done? put the id of this card & return after cardList -- add this card to list end repeat Is this simple enough? Note that the absence of a test for not finding anything means that there is another bug, namely that you will always find at least one card even if the string doesn't exist anywhere. Fixing this is left as an exercise ... Howard A. Landman landman@hanami.sun.com UUCP: sun!hanami!landman