1

I need to do certain replacement after and before particular strings. Example: I need to "replace bad with good in field "MytextField"". But this replacement should be done after begin{document} and before end{document}. None of the word replace before begin {document} and after end{document}. How is this possible?. if I use this code "replace bad with good in field "MytextField"" all the instants of bad should be replaced with good. I don't need to change the entire field.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Indian
  • 49
  • 7

2 Answers2

2

This should work if your begin and end markers only appear once in the field...

   put wordOffset("begin{document}",fld "MytextField") into tBegin
   put wordOffset("end{document}",fld "MytextField") into tEnd
   put replaceText(word tBegin to tEnd of fld "MytextField","bad","good") into word tBegin to tEnd of fld "MytextField"

If the markers appear several times you will need a repeat loop to step through each one.

Paul

Paul
  • 176
  • 1
  • 4
0

Put this into a field: aa red aa red aa red aa red

Put this into a button

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 --just in case...
   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
dunbarx
  • 756
  • 5
  • 4