Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!samsung!munnari.oz.au!uniwa!fennel.cc.uwa.oz.au!n_hays From: n_hays@fennel.cc.uwa.oz.au Newsgroups: comp.sys.mac.hypercard Subject: Re: Wanted: "Find Next" Message-ID: <1990Nov23.061239.2641@fennel.cc.uwa.oz.au> Date: 22 Nov 90 22:12:39 GMT References: <1990Nov20.155800.2630@fennel.cc.uwa.oz.au> <11336@goofy.Apple.COM> Organization: University of Western Australia Lines: 125 In article <11336@goofy.Apple.COM>, batman@apple.com (Ken Laws) writes: > In article <1990Nov20.155800.2630@fennel.cc.uwa.oz.au> > n_hays@fennel.cc.uwa.oz.au writes: >> One thing which I find a particular nuiscance, however, is the change >> to the way HC handles "finds". >> I have a simple script designed to extract a copy of any line >> containing a particular word. >> It runs along the lines of: >> >> Put "foo" into ThingToFind >> repeat until cooked >> find string ThingToFind >> do stuff with it >> end repeat >> >> The problem is that HC 1.x could always be relied upon to find the >> NEXT example of ThingToFind on any given card. HC 2 always returns >> to the first example. > > I've tried to reproduce this, but without the exact script I can't. > A few tests using 2.0 and 2.0v2 reveal no changes from 1.2.5's behavior. > The only things I can think of (off the top of my head) that would cause > this problem are: > A. You go to another card after finding. > B. You use the "click" or "drag" commands. > > Ken Laws > HyperCard Team (Kevin is my boss... and a damn good one, too) > > Disclaimer: Not to be taken internally. > Void where prohibited. > I don't speak for Apple. Ok - here it is. This script is designed to cycle through all the cards of a stack except for the first which is special. It finds all instances of a particular word and copies the sentences in which that word appears to a field on the first card, together with info about the card from which it was extracted. It ends when it finds the example that it first found, so the first and last sentences are the same. This is a reconstruction of my original script, but I've tried it out with HC 1.2.5 and it works. In HC 2 it finds the first example, selects the line, puts it in storehouse and, on the next repeat, finds the first match again thereby bringing the script to an end. HC 1.2.5 finds the NEXT match, either on another card or somewhere else on the same card (unless there are no more matches of course in which case the script ends). As I said, its possible to kludge around this - but its ugly. Simply repeating the "find string Wsearch" works unless there are two matches on the same card - ie. it's dependant on moving to another card. Any help much appreciated. On reflection, it occurs to me that the problem is possibly not a different "find", but how long HC 2 "remembers" things. I have run across this problem before, with scripts that use values such as "the selection" as a variable. HC 1.2x remembers such a value for the duration of the handler, or until it is changed, while HC 2 will forget it within the space of a repeat loop. on Wordsearch put empty into Wordsearchcount put empty into wordsearchtest put empty into wordsearchtest2 ask "Find all Occurrences of Which Word?" if it is empty then exit to hypercard put it into WSearch put "Searching - please wait" go to first card of background "Standard" repeat find string Wsearch put the foundchunk into chunky select the foundline put the selection into eureka if eureka is empty then play "boing" put "Nothing Found" exit to hypercard end if if the id of this cd is the id of first cd then if Wordsearchcount is 0 then play "boing" put "Nothing Found" exit to hypercard end if exit repeat end if add 1 to Wordsearchcount if wordsearchcount = 1 then put field title into Wordsearchtest put chunky into Wordsearchtest2 end if put eureka&&return&&field "author"&&return&&field "title"B &&return&&"-----------------------------------------------"B &&Return&&return after storehouse if wordsearchcount is not 1 then if field "title" = Wordsearchtest and chunky = B Wordsearchtest2 then exit repeat end if else next repeat end if end repeat go to first card put storehouse after cd field "Wordsearch" put wordsearchcount&&"Matches"&return before cd field "Wordsearch" if the visible of cd field "Wordsearch" is not "true" then send mouseup to button "Wordsearch" end if hide message box end Wordsearch Hmmm! the "option-return" character seems to have come out as a "B" - but you get the idea. Neale ************************************************************************** n_hays@fennel.cc.uwa.oz.au University of Western Australia This University cannot afford to let me send mail! **************************************************************************