Archive: A bug? Naaaa, just a n00b problem: IfFileExists fails.


A bug? Naaaa, just a n00b problem: IfFileExists fails.
I'm checking on the existance of a common Windows dll before installing it if it's not there:

IfFileExists "$SYSDIR\msvcr70.dll" +1
File "e:\src\archive\msvcr70.dll"

I get an error while trying to open the (existing) file for writing, indicating that the if failed (or rather, succeeded when it should have failed). Does anyone know why?


It sounds like if the file exists, you want to skip the File command, if so, you need:

IfFileExists "$SYSDIR\msvcr70.dll" +2
File "e:\src\archive\msvcr70.dll"

From the documentation:

4.4 Relative Jumps
Unlike labels, relative jumps are, as the name suggests, relative to the place they are called from. You can use relative jumps wherever you can use labels. Relative jumps are marked by numbers. +1 jumps to the next instruction (the default advancement), +2 will skip one instruction and go to the second instruction from the current instruction, -2 will jump two instructions backward, and +10 will skip 9 instructions, jumping to the tenth instruction from the current instruction.

An instruction is every command that is executed at run-time, when the installer is running. MessageBox, Goto, GetDLLVersion, FileRead, SetShellVarContext are all instructions. AddSize, Section, SectionGroup, SectionEnd, SetOverwrite (and everything under Compiler Flags), Name, SetFont, LangString, are not instructions because they are executed at compile time.

Examples:

Goto +2
MessageBox MB_OK "You will never ever see this message box"
MessageBox MB_OK "The last message was skipped, this one should be shown"


Nevermind....


Ah, nuts, you're right. I opened your response and didn't see the top line, where you are explaining that I got the number wrong, counting skipped lines instead of just lines. I wrote a long explanation of how those lines seemed to be right to me, and they were, only they weren't mine, they were yours. I thought you were quoting me in the lines, and I made perfect sense to myself, which I often do. Thanks for your help, I appreciate it.

And it won't happen again. :hang:


No problem, glad i could help.