Good day! Well, things were bookin' right along until I had to make my
fancy Find engine run for more than one card. I'm using the offset
function to help highlight found text. It works great with the Find
button: I simply rearranged a few lines and added a repeat loop to go to
the next card if the text isn't matched on the current card. The problem
occurs when I try to alter the Find Again. I need it to not only go to
the next card, but stop and tell the user when there are no more
occurrences. I'll quote an abbreviated version of the Find and Find
Again. I sure could use some help wrappin' my head around this one.

FIND BUTTON SCRIPT:

on mouseUp
  global gTextToFind,gChunk,gTextToSkip
    ask "What text do you want to find?"
  if the result is "Cancel" then
    exit mouseUp
  else
    put it into gTextToFind   -- to feed Find Again
    # start looking
    repeat with s = 1 to the number of cds in this stack
      put offset(gTextToFind, fld "storyText") into tTextOffset
      if tTextOffset <> 0 then   -- found it!
        put "char" && tTextOffset && "to" && tTextOffset + \ 
            length(gTextToFind) -1 && "of fld 1" into \ 
            gChunk  -- for colorizing
        put tTextOffset + length(gTextToFind) - 1 into \ 
            gTextToSkip  -- tells Find Again where to start
        # colorizing here
        # scroll the field
         exit mouseUp
      else
        go next cd
      end if
    end repeat
    answer "Sorry, the text was not found"
  end if
end mouseUp


FIND AGAIN BUTTON SCRIPT:

on mouseUp
  global gTextToFind,gTextToSkip,gChunk
  
  resetFoundText  -- takes highlighting off
  
  put offset(gTextToFind,fld 1,gTextToSkip) into tTextOffset
  if tTextOffset = "0" then
    answer "Sorry, no more occurrences of the text were found."
    exit mouseUp
  else
    put tTextOffset + gTextToSkip into tStartText
    put "char" && tStartText && "to" && tStartText + \ 
     length(gTextToFind) - 1 && "of fld 1" into \ 
     gChunk   -- feeds next Find Again
    put tStartText into gTextToSkip
    # colorizing here
    # scroll the field
  end if
end mouseUp


Thanks, in advance, for any pointers!

Mary Bull
[EMAIL PROTECTED]

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

Reply via email to