Archive: How to find specific line number


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


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

Thanks,

Does the job..;).