martti
7th February 2006 09:00 UTC
How to find specific line number
Hi folks,
I couldn't find a function to search a text file with search string and return the matching line number(s) for further inline search/replace.
All current one's seems to need the line number as parameter.
Thanks in advance
Instructor
7th February 2006 14:44 UTC
Name "Output"
OutFile "Output.exe"
!include "TextFunc.nsh"
!insertmacro LineFind
!insertmacro TrimNewLines
!include "WordFunc.nsh"
!insertmacro WordFind
Section
StrCpy $R0 "SearchString"
${LineFind} "C:\input.txt" "C:\output.txt" "1:-1" "LineFindCallback"
IfErrors 0 +2
MessageBox MB_OK "Error"
SectionEnd
Function LineFindCallback
${TrimNewLines} '$R9' $R9
${WordFind} "$R9" "$R0" "E+1{" $1
IfErrors end
MessageBox MB_OKCANCEL '$$R9 "Line"=[$R9]$\n$$R8 "#" =[$R8]' IDOK +2
StrCpy $0 StopLineFind
end:
StrCpy $R9 "$R9$\r$\n"
Push $0
FunctionEnd
martti
7th February 2006 15:23 UTC
Thanks,
Does the job..;).