How to simplify the code.
Posted: Wed Jun 24, 2015 9:06 am
Hi,
I need to replace certain words in file. but i don't want to replaces the same words which are inside dollar symbol.
eg:- This is only an example $only$ ok? Here i want to replace "only" with "something".
current output:- This is something an example $something$ ok?
Required output:- This is something an example $only$ ok?.
Now iam using the following code. but it is very complicated code and it required lot of time.
Is there any idea to simplify the code.
Thanks,
Samjith.
I need to replace certain words in file. but i don't want to replaces the same words which are inside dollar symbol.
eg:- This is only an example $only$ ok? Here i want to replace "only" with "something".
current output:- This is something an example $something$ ok?
Required output:- This is something an example $only$ ok?.
Now iam using the following code. but it is very complicated code and it required lot of time.
Code: Select all
put the text of field "MytextField" into myfile
put replaceText(myfile,"\n","^EOL") into myfile
repeat with i = 1 to the number of chars in myfile
if char i of myfile contains "$" then
add 1 to tmp
if tmp = 1 then
put "^SOE" & CR & char i of myfile after yy
else
put char i of myfile & CR & "^EOE" after yy
put 0 into tmp
end if
else
put char i of myfile after yy
end if
end repeat
put 0 into m
repeat for each lines iT in yy
if iT contains "$" then
add 1 to m
put " *****In_Line_Equation " & m & "***** " into so
replace IT with so in myfile
put iT & cr after ELine
end if
end repeat
put replaceText(myfile, "\^SOE\n","") into myfile
put replaceText(myfile, "\n\^EOE","") into myfile
put replaceText(myfile, "\^EOL",cr) into myfile
Is there any idea to simplify the code.

Thanks,
Samjith.