Hi,
Currently, I use an external nsh file to replace text in files.
Is there a way to replace text in file with the integrated include nsh files: wordfunc, strfunc or else?
Something like:
${StrRepFile} "$FILEPATH" "oldtext" "newtext"
Replace in file
8 posts
Name "Output"
OutFile "Output.exe"
!include "TextFunc.nsh"
!insertmacro LineFind
!include "WordFunc.nsh"
!insertmacro WordReplace
Section
${LineFind} "C:\ReplaceInFile.txt" "C:\ResultFile.txt" "1:-1" "LineFindCallback"
IfErrors 0 +2
MessageBox MB_OK "Error"
SectionEnd
Function LineFindCallback
${WordReplace} "$R9" "Replace this string" "Replace with this string" "+" $R9
Push $0
FunctionEnd
Thank you.
Is it normal to push $0 instead of $R9 at the end of the callback function?
And do you know if there is difference between StrRep and WordReplace?
Is it normal to push $0 instead of $R9 at the end of the callback function?
And do you know if there is difference between StrRep and WordReplace?
Push $var ; If $var="StopLineFind" Then exit from function
; If $var="SkipWrite" Then skip current line (ignored if "/NUL")
What happen if I don't Push something at the end of the callback function? Or if I push an empty string?
If you don't use "StopLineFind", "SkipWrite", you can Push anything else "Push 0", "Push ''" ... You need to Push something, otherwise it will bring to stack corruption.
Thank you very much. It works fine.
By the way is there a difference between StrRep (from StrFunc.nsh) and WordReplace?
By the way is there a difference between StrRep (from StrFunc.nsh) and WordReplace?
Read documentation