Skip to content
⌘ NSIS Forum Archive

IfFileExists works like... how?

6 posts

Guest#

IfFileExists works like... how?

Hi again. I got a question related to how the NSIS script works which I haven't really sorted out yet with the use of documentation only.

In the very short time since I've been aquainted to NSIS (3 days ago) I saw in the documentation things like this:

IfFileExists $WINDIR\notepad.exe 0 +2
MessageBox MB_OK "notepad is installed"

What's that +2? What's it supposed to mean? And the 0? The 0 I guess means go to the next line.
Afrow UK#
I guess you missed this bit in the documentation.



-Stu
Guest#
But the 0?

Yeah, I suspected that. But still, according to the documentation, 1 should mean jump to the next instruction while 2 should mean skip the next instruction. Then what does 0 mean? I assume "do nothing" / "continue execution as if nothing happened"?
flyakite#
+2 means jump two instructions. Say you have the following:

IfFileExists "FILE.exe" +1 +2
Exists
DoesNOTExist


If the file exists, it jumps 1 instruction, meaning, it jumps to "Exists". Technically 0 and "" do the same thing. It essentiall tells the installer to just continue. +1 means jump 1 instruction, which really is just continuing.

+2 goes two lines of course. So it ends up at DoesNOTExist.

+# doesn't mean to skip the next # instructions. It means to jump to that instruction. +2 goes two instructions, skipping 1.


If relative jumps confuse you you could always use labels as alternative.