Page 1 of 1

FIND go back

Posted: Tue Sep 16, 2014 12:01 pm
by MaxV
Hi,
I like find behaviour: each time you call it, it continues from the last founded word.
Is there a way to go back with find ? I mean to go back to the previous founded text or find backward. :?:

Re: FIND go back

Posted: Tue Sep 16, 2014 2:48 pm
by dunbarx
Hi.

This derives from HC behavior, 27 years ago. The last "find", whether within a single field or anywhere on a stack of cards, is indexed internally. Similar to when one reads from an external file, the character where the last "read" ended is stored, and any subsequent read will resume from that point.

I do not think there is any way to do what you want unless you index yourself. But this is simple; store the foundChunk, or even a more complete pathway if on different cards with every successful find, in a custom property, and create a UI gadget to reveal the entire "found" history. This would be a fun and useful gadget to store in a library or plug-in. You will have to fake the find by selecting the foundChunk and changing its textStyle to "box", or whatever...

Craig Newman

EDIT:

You can access this history with a ready-made "undo", or rather "unFind", perhaps with a custom key combination, where the find sequence is reversed one by one instead of presenting the whole history.

Re: FIND go back

Posted: Wed Sep 17, 2014 4:35 pm
by MaxV
At the present I solved this way, but I think that there are more elegant solutions:
button find:
########CODE#######
on mouseUp
#cerca avanti
find string the text of field "campocerca" in field "testo"
put the contCerca of button "bottoneCerca" into temp
add 1 to temp
set the contCerca of button "bottoneCerca" to temp
end mouseUp
#####END OF CODE#####

button find back:
########CODE#######
on mouseUp
#cerca indietro
put the contCerca of button "bottoneCerca" into temp
put temp - 1 into temp
if temp < 1 then
put 1 into temp
end if
set the contCerca of button "bottoneCerca" to temp
find empty in field "testo"
repeat for temp time
find string the text of field "campocerca" in field "testo"
end repeat
end mouseUp
#####END OF CODE#####

Re: FIND go back

Posted: Wed Sep 17, 2014 6:06 pm
by dunbarx
Hi.

Simon will forgive me. I just know it.

On a new card, make four buttons and a field. Put a bunch of different words in the field, but making sure that one word repeats several times. Let's make that word "XXX". Name the four buttons: "findNext", "findPrevious". "showHistory" and "clearHistory".

In the script of "findNext":

Code: Select all

on mouseUp
   find "XXX"
   set the foundHistory of this card to the foundHistory of this card & return & the foundChunk
end mouseUp
In "findPrevious"

Code: Select all

on mouseUp
   set the foundHistory of this cd to line 1 to -2 of the foundHistory of this cd
   get the last line of the foundHistory of this cd
   set the textstyle of it to "box"
end mouseup
In "showHistory"

Code: Select all

on mouseUp
   answer the foundHistory of this cd
end mouseUp
in "clearHistory"

Code: Select all

on mouseUp
   set the foundHistory of this card to ""
  set the textStyle of word 1 to 1000 of fld 1 to "plain"
end mouseUp
Start by clearing the history. Find one or two instances of the text. Check out the history. Go back a bit. Check out the history. Make this work nicer for you.

Craig