Reputation: 49
I need to do certain replacement, but i don't want to replace this globally. eg:- replace bad with good in field "MytextField". But i don't want to replace this bad with good globally. is there any option for asking yes and no options. if i press yes it will replace, otherwise it will go to the next occurance for asking yes and no and so on.
Upvotes: 0
Views: 49
Reputation: 756
Many ways to do this, but try this experiment. Make a field with this in it:
aa red aa red aa red aa red
Now make a button, and put this in its script:
local latest
on mouseUp
put 0 into latest
startFinding fld 1.0
end mouseUp
on startFinding tText,tOffset
if the optionKey is down then exit to top
put wordOffset("red",fld 1,tOffset) into latest
answer "Change word" && (latest + tOffset) && "?" with "Change" or "Continue"
If it = "change" then put "green" into word (latest + tOffset) of fld 1
add latest to tOffset
if tOffset < the number of words of fld 1 then startFinding fld 1,tOffset
end startFinding
You might embellish this by including some of the preceding and following words with each run, so that the context can be presented to the user.
Craig Newwman
Upvotes: 1