Skip to content
⌘ NSIS Forum Archive

LineFind *

5 posts

Noude#

LineFind *

Hello !

I have a problem, my internship will be completed soon and I'm stuck on a very small thing...

In a folder I have a number 'n' a files.xml

In these files I have to replace a line (the 6th) "<storeref refid="st1"/>" by "<storeref refid="store1"/>".

So I'm doing that but it's doesn't work, I have to give a name of file ='(

Section
${LineFind} "C:\k3\studies\config\studies\*"         ""         "6"     "DeleteLines"
${LineFind} "C:\k3\studies\config\studies\*"         ""         "6"     "WriteToFile"
SectionEnd
Function WriteToFile
FileWrite $R4 "<storeref refid=$\"store1$\"/>$\r$\n"
Push $0
FunctionEnd
Function DeleteLines
StrCpy $0 SkipWrite
Push $0
FunctionEnd 
Can you help me please ? Thanks a lot !
Afrow UK#
Read the manual. You aren't using it properly (namely the contents of your callback function).

Stu
Noude#
Hello,

I have already read the manual 10 times but I really do not see how to use globbing in the LineFind function, I can not just put *?

I have this now:

Section ;File.xml: "st1" or "store1" ?

${LineFind} "C:\k3\studies\config\studies\*" "" "1:-1" "Replace"

SectionEnd



Function Replace

StrCpy $1 $R9
${WordReplace} '$R9' 'st1' 'store1' '+*' $R9
StrCmp $1 $R9 +2
IntOp $R0 $R0 + 1
Push $0

FunctionEnd

And it works if I put a name of file, but not with a *...
Noude#
Hey, it's OK now, but it's fat I think ^^

Section ;File.xml: "st1" or "store1" ?

FindFirst $0 $1 C:\k3\studies\config\studies\*.xml
loop:
StrCmp $1 "" done
DetailPrint $1
${LineFind} "C:\k3\studies\config\studies\$1" "" "1:-1" "Replace"
FindNext $0 $1
Goto loop
done:
FindClose $0

SectionEnd

Function Replace

StrCpy $1 $R9
${WordReplace} '$R9' 'st1' 'store1' '+*' $R9
StrCmp $1 $R9 +2
IntOp $R0 $R0 + 1
Push $0

FunctionEnd
Afrow UK#
I'm pretty sure you could just do this:
StrCpy $R9 `<storeref refid="store1"/>$\r$\n`

Stu