theblazingangel
4th July 2007 05:57 UTC
SetOverwrite not working (urgent!)
i've got a problem with SetOverwrite. i need to control SetOverwrite with a command line parameter, this means wrapping a SetOverwrite command in an ${If} check, but it's not working... it's as if the ${If} check doesn't exist, i've also tried StrCpm and that doesn't have any effect either!
in the below example it should always overwrite an existing file, unless the switch is set in which case it should only do it if it has a newer copy. however what actually happens is that it always does the if-newer check...
example code that doesn't work:
!include 'MUI.nsh'
!include 'LogicLib.nsh'
Name 'test'
InstallDir "C:\test\"
OutFile "test.exe"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE 'English'
Var /GLOBAL switch_test
Section 'Installation'
SetOutPath $INSTDIR
StrCpy $switch_test '0'
${If} $switch_test == '1'
SetOverwrite ifnewer
${EndIf}
File test.txt
SectionEnd
what am i doing wrong?
i'd appreciate a speedy response if possible, i'm already late delivering the software i'm packing due to other delays.
thank you :)
theblazingangel
4th July 2007 06:34 UTC
damn it, found the answer here: http://forums.winamp.com/showthread.php?postid=2183260
i've also now found the note in the 'compiler command' section of the docs. perhaps it could be made clearer, perhaps even just a note could be added that ${If} and StrCmp have no effect, because i think it's pretty important that we know that!!!
kichik
4th July 2007 18:52 UTC
Compiler flags now states:
The following commands affect how the compiler generates code and compresses data. Unless otherwise noted, these commands are valid anywhere in the script, and effect every line below where each one is placed (until overridden by another command). They cannot be jumped over using flow control insutrctions.
For example, in the following script, blah.dat will never be overwritten.
${If} $0 == 0
SetOverwrite on
${Else}
SetOverwrite off
${EndIf}
File blah.dat # overwrite is always off here!
Instead, the following should be used.
${If} $0 == 0
SetOverwrite on
File blah.dat
${Else}
SetOverwrite off
File blah.dat
${EndIf}
What do you think?
theblazingangel
4th July 2007 19:22 UTC
that looks great, thanks :)
the only gripe i now have is that when compiling a release using the /nonfatal switch on the file command, warnings for missing items are now listed twice, and it seems to process all of the files to include twice.
i wish it didn't do that...
kichik
4th July 2007 19:25 UTC
Well, those are different errors. You might even have a !system command in between those two that generates the file so the second File might not fail.