Old 7th February 2006, 08:00   #1
martti
Junior Member
 
Join Date: Nov 2005
Posts: 5
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
martti is offline   Reply With Quote
Old 7th February 2006, 13:44   #2
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
code:
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

Instructor is offline   Reply With Quote
Old 7th February 2006, 14:23   #3
martti
Junior Member
 
Join Date: Nov 2005
Posts: 5
Thanks,

Does the job...
martti is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump