Yup the RegEx wrapper was exaclty what I was looking for:
Code:
SetMission(missionID)
{
p:="^[^;].*mission.*"
r:=";$0"
FileDelete, C:\TEST\tmp.ini
Loop, read, C:\TEST\test.ini, C:\TEST\tmp.ini
{
s:=A_LoopReadLine
e:=RE_Replace(s,0,p,0,r)
if (e>0)
FileAppend, %s%`n
Else
FileAppend, %A_LoopReadLine%`n
}
p:=";(.*""" . missionID . """.*)"
r:="$1"
FileSetAttrib, -R, C:\TEST\test.ini
FileDelete, C:\TEST\test.ini
Loop, read, C:\TEST\tmp.ini, C:\TEST\test.ini
{
s:=A_LoopReadLine
e:=RE_Replace(s,0,p,0,r)
if (e>0)
FileAppend, %s%`n
Else
FileAppend, %A_LoopReadLine%`n
}
FileDelete, C:\TEST\\tmp.ini
return
}
Works like a charm. This is probably not the most efficient way to do things since I end up writing out a file twice, but this adds a ';' at the beginning of any line that contains the word 'mission' and doesn't already have a ';' at the beginning and then removes the ';' from the beginning of the mission line that was passed into the function.
Thanks!
Brian