> On Mon, 09 Apr 2001 Sivakatirswami wrote
>
> I am trying to implement a  simple search function in an eBook (see menu
> script below) my problem is that the find function gets "stuck" on the
> current card.
>
> I need it to go forward and after finding the last instance of a string in
> the present card, move to the next card etc. Presently it just loops back to
> the first instance of that string in the same field on the same card? What
> am I doing wrong? I do see that after the last find on the current card the
> function returns a empty foundChunk. I suppose one can write a handle for
> that which then "drives" the function forward to the next card, but I
> thought "there is got to be an easier way."
>
> on menuPick pWhich
>   switch pWhich
>   case "Find" --command key assignment is cmd-F
>     if the selection is not empty then
>       put the Selection into gSearchString
>       find string gSearchString
>     else
>       ask "Find what?"
>       put it into gSearchString
>       find string gSearchString
>       if the result is not empty then answer "Sorry, no such text." with
> "OK"
>     end if
>     break
>   case "Find Again" --command key assignment is cmd-G
>     find string gSearchString
> --this is the one that loops back to the top of the same field instead of
> moving to the next card.
>     break
>   end switch
> end menuPick
>
>
> Hinduism Today
>
> Sivakatirswami
> Editor's Assistant/Production Manager
> [EMAIL PROTECTED]
>
If you want simply to *search* a stack for a string in fields or
scripts, use an offset function, list the results - as a possibility the
found lines in a results' field - together with the address of the
objects in which the searchstring was found, use the clicktext to
navigate from the address to the card or script where the searchstring
is located. It takes a bit longer to script this, but this is the
general idea.

If you want to browse  a stack for a searchstring and at the same time
look immediately at each found instance, I suppose you have indeed to
use the find command, but from *outside*, i.e. from the message box or
another (modal) stack. In this case you can indeed use your script with
an addition:
Put the lines

       "global gSearchstring # this variable is necessary
       put the name of the topstack into TName
       set the defaultstack to TName"

right after your handler "on menupick pwhich"

and the script should work from a button in a modal stack that you may
call in a button from the stack to be searched with "modal "SavirFind""
(do not forget to place a "close stack" button on the modal stack).

Regards,

Wilhelm Sanke




Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to