Hi
I have a text file with 4 rows and a value 0 or 1 in each row. When I change one value (from outer web with javascript), the letter A is written beside it. It looks like this:
settings.ini
1
0
1A
0
With AHK I would like to delete the letter A and get the row number and the row value, so I can trigger the right switch (call procedure). I think that with TXT_RegExReplace I'm close enough, but I just can't extract these two values. Please help.
Code:
#t::
TriggerFilename=d:\myweb\cgi-bin\settings.ini
TXT_RegExReplace("!" . TriggerFilename, 1, 4, "A", "")
Return
TXT_RegExReplace(TextFile, StartLine, EndLine, NeedleRegEx, Replacement=""){
Original := A_BatchLines
SetBatchLines, -1
TextFile := (SubStr(TextFile,1,1)="!") ? (SubStr(TextFile,2),OW=1) : TextFile
FileRead, Str, %TextFile%
Loop, Parse, Str, `n, `r
{
If A_Index between %StartLine% and %Endline%
{
OutPut .= RegExReplace(A_LoopField, NeedleRegEx, Replacement, Count)
OutPut .= "`n"
Counts += Count
LineNo .= Count
}
Else
OutPut .= A_LoopField "`n"
}
If OW {
FileDelete, %TextFile%
FileAppend, %OutPut%, %TextFile%
MsgBox % "Line No. : " LineNo
}
Else {
SplitPath, TextFile,, Dir, Ext, Name
FileDelete, % Dir "\" Name "_copy." Ext
FileAppend, %OutPut%, % Dir "\" Name "_copy." Ext
}
SetBatchLines, %Original%
Return Counts
}