CGI and find

J. Landman Gay jacque at hyperactivesw.com
Tue Sep 2 17:00:01 EDT 2003


On 9/2/03 4:07 PM, Dar Scott wrote:

>  From the doc:
> 
>> When the search is successful, the card containing the text appears 
>> and a box is drawn around the found text.
> 
> 
> One might interpret this as saying 'find' is a gui command.

I sort of got it to work. If anyone is interested, here's how. I was 
using this syntax:

  repeat
   find theTerm
   if the result is not empty then exit repeat
   -- gather card data into a variable here
  end repeat

In the IDE, a "find" command will cycle until it comes back to the first 
instance that was found, at which point it returns "not found". That 
means that when the result is not empty, you are done searching. In a 
cgi, "not found" is returned if the search term does not exist anywhere 
in the stack, but as far as I can tell, it is never returned if the term 
does exist and the repeat loop is cycling. It will continue to find the 
same instances over and over. The above script works in the IDE but 
loops forever in a cgi.

If I take this fragment out of a repeat loop and look for only one 
instance, "find" does work. I get back a single instance. I can also use 
"find in fld <whatever>" and it searches only that field. But it won't 
work in a loop because it doesn't exit.

I changed the syntax to this:

  mark cards by finding theTerm
  repeat with x = 1 to the number of marked cds
    -- gather card data here
  end repeat

This works fine. You can also use "mark cards by finding theTerm in fld 
<whatever>". So my conclusion is that a cgi can't "find" in a repeat 
loop, but you can get all the instances if you "mark cards by finding".

I'm not sure enough of my test results yet to report this as a bug, but 
it seems to be what is happening.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list