ok, i have a Problem and i cant solve it.
i have to patch some Files. And i want to write a macro.
my Problem is, if i use a Variable or a Label and use the macro more then one times, he says the variable or label is already declared. Then i used relative jumps, but then he writes "succsess123167succsess128167succsess183167succsess133167"
at the end of the File or in some tets he wrote only the first line and then only "succsess".
the original code is this:
!macro patchFileTest templatePath zielpfad filename
ClearErrors
FileOpen $R0 '${templatePath}\${filename}' r #
IfErrors done_test_${filename}
ClearErrors
SetOutPath '${zielpfad}'
FileOpen $R1 '${filename}' w
IfErrors not_patched_test_${filename}
ClearErrors
loop_test_${filename}:
FileRead $R0 $R3
IfErrors eof_test_${filename}
#StrCmp ${v1} '1' 0 +2
${StrRep} $R3 "$R3" "%DBListenerport%" "$TestDB_Listenerport"
#StrCmp ${v2} '1' 0 +2
${StrRep} $R3 "$R3" "%Hostname%" "$TestDB_Hostname"
#StrCmp ${v3} '1' 0 +2
${StrRep} $R3 "$R3" "%Server%" "$Servername"
#StrCmp ${v4} '1' 0 +2
${StrRep} $R3 "$R3" "%DBSID%" "$TestDB_DBSID"
#StrCmp ${v5} '1' 0 +2
${StrRep} $R3 "$R3" "%User%" "$TestDB_Mainuser"
#StrCmp ${v6} '1' 0 +2
${StrRep} $R3 "$R3" "%TNSname%" "$TestDB_TNSname"
#StrCmp ${v7} '1' 0 +2
${StrRep} $R3 "$R3" "%Passwort%" "$TestDB_MainuserPasswort"
#StrCmp ${v8} '1' 0 +2
${StrRep} $R3 "$R3" "%Pfad%" "$INSTDIR${TestDB}"
FileWrite $R1 $R3
IfErrors +2 0
Goto loop_test_${filename}
DetailPrint '!!!!!!!! Konnte nicht in ${zielpfad}\${filename} schreiben!!!!!!!!!'
eof_test_${filename}:
FileClose $R1
FileClose $R0
Goto +4
not_patched_test_${filename}:
DetailPrint '!!!!!!!! Konnte ${filename} nicht anlegen!!!!!!!!'
Goto +2
done_test_${filename}:
DetailPrint '!!!!!!!! Konnte ${templatePath}\${filename} nicht öffnen(lesen)!!!!!!!!'
!macroend
my last test was this:
!include StrFunc.nsh
${StrRep}
/* ProduktivDB */
!macro patchFileProd param1 param2 param3
!define templatePath ${param1}
!define zielpfad ${param2}
!define filename ${param3}
Messagebox MB_OK "${param1}"
Messagebox MB_OK "${param2}"
Messagebox MB_OK "${param3}"
Messagebox MB_OK "${templatePath}"
Messagebox MB_OK "${zielpfad}"
Messagebox MB_OK "${filename}"
call patchFile
!undef templatePath
!undef zielpfad
!undef filename
!macroend
Function patchFile
/* Datei einlesen und schreiben */
Messagebox MB_OK "${param1}"
Messagebox MB_OK "${param2}"
Messagebox MB_OK "${param3}"
Messagebox MB_OK "${templatePath}"
Messagebox MB_OK "${zielpfad}"
Messagebox MB_OK "${filename}"
ClearErrors
FileOpen $R0 '${templatePath}\${filename}' r #
IfErrors done_${filename} #+25
ClearErrors
SetOutPath '${zielpfad}'
FileOpen $R1 '${filename}' w
IfErrors not_patched_${filename} #+19
loop_${filename}:
ClearErrors
FileRead $R0 $R3
IfErrors eof_${filename} #+13
#StrCmp ${v1} '1' 0 +2
${StrRep} $R3 "$R3" "%DBListenerport%" "$ProduktivDB_Listenerport"
#StrCmp ${v2} '1' 0 +2
${StrRep} $R3 "$R3" "%Hostname%" "$ProduktivDB_Hostname"
#StrCmp ${v3} '1' 0 +2
${StrRep} $R3 "$R3" "%Server%" "$Servername"
#StrCmp ${v4} '1' 0 +2
${StrRep} $R3 "$R3" "%DBSID%" "$ProduktivDB_DBSID"
#StrCmp ${v5} '1' 0 +2
${StrRep} $R3 "$R3" "%User%" "$ProduktivDB_Mainuser"
#StrCmp ${v6} '1' 0 +2
${StrRep} $R3 "$R3" "%TNSname%" "$ProduktivDB_TNSname"
#StrCmp ${v7} '1' 0 +2
${StrRep} $R3 "$R3" "%Passwort%" "$ProduktivDB_MainuserPasswort"
#StrCmp ${v8} '1' 0 +2
${StrRep} $R3 "$R3" "%Pfad%" "$INSTDIR"
FileWrite $R1 $R3
IfErrors +2
Goto loop_${filename} #-15
#Messagebox MB_OK "!!!!!!!! Konnte nicht in ${zielpfad}\${filename} schreiben!!!!!!!!!"
DetailPrint '!!!!!!!! Konnte nicht in ${zielpfad}\${filename} schreiben!!!!!!!!!'
eof_${filename}:
FileClose $R1
FileClose $R0
Goto +4
not_patched_${filename}:
#Messagebox MB_OK "!!!!!!!! Konnte ${filename} nicht anlegen!!!!!!!!"
DetailPrint '!!!!!!!! Konnte ${filename} nicht anlegen!!!!!!!!'
Goto +2
done_${filename}:
#Messagebox MB_OK "!!!!!!!! Konnte ${templatePath}\${filename} nicht öffnen(lesen)!!!!!!!!"
DetailPrint '!!!!!!!! Konnte ${templatePath}\${filename} nicht öffnen(lesen)!!!!!!!!'
FunctionEnd
the Messageboxes are for test.
Can anybody help me?