Below is the source from a file that needs to be changed. I am using "for each line in" to "move" the open bracket up one line so that the "camera" values are easier to handle using itemDel.
Code: Select all
camera_track
[
keys 3
0 1 0.1 0.5 0 0 1.7321
1 1 0.1 0.5 0 0 1.7321
12 1 0.1 0.5 0 0 1.7321
]
camera_zoom
[
keys 3
0 1 0.1 0.5 1
1 1 0.1 0.5 0.915311
12 1 0.1 0.5 0.915311
]
camera_roll
[
keys 3
0 1 0.1 0.5 0
1 1 0.1 0.5 0.259061
12 1 0.1 0.5 0.259061
]
camera_pan_tilt
[
keys 3
0 1 0.1 0.5 0 0
1 1 0.1 0.5 -0.059462 0.216465
12 1 0.1 0.5 -0.059462 0.216465
]
Code: Select all
local tcount
put 1 into tcount
repeat for each line i in varText
if i contains "camera_" then
replace "[" with "" in line tcount + 1 of varText
replace "camera_" with "[camera_" in line tcount of varText
end if
add 1 to tcount
end repeat
It only changes the FIRST "camera_" line encountered. After that it won't finish the others. The odd thing is that if I change the camera text using anything that doesn't have a bracket in it AND any form of the word camera it works fine. Putting the "[" in the replace text messes up the replacement using the incremented tcount variable. Also if I use any of the letters of "camera" in that order will also break the repeat. For example if I try to replace "camera_" with "---cam" doesn't work. Anything else will work.
This DOES work:
Code: Select all
local tcount
put 1 into tcount
repeat for each line i in varText
if i contains "camera_" then
replace "[" with "" in line tcount + 1 of varText
replace "camera_" with "dagnabbit" in line tcount of varText
end if
add 1 to tcount
end repeat
There's another issue. If I use the format below it works fine. Notice I am using the tcount to check for the line... however this makes the script very very very slow. The files I am changing are huge. The difference in time between these two is astronimcal, 2 seconds without counting the lines compared to 10 minutes using the code below.
Code: Select all
local tcount
put 1 into tcount
repeat for each line i in varText
if line tcount of varText contains "camera_" then
replace "[" with "" in line tcount + 1 of varText
replace "camera_" with "dagnabbit" in line tcount of varText
end if
add 1 to tcount
end repeat
I am going insane on this one. Driving me crazy.