PDA

View Full Version : Relative jumps


Deliverator
21st August 2004, 17:59
Suppose you have a macro that consists of 5 lines.

You do a

IfFileExists "$ApplicationDir\${MY_DIR}\${MY_EXE}" 0 +1
!insertmacro UnselectSection ${MySec}


I don't think will work because the macro is expanded into 5 lines. The +1 will jump into the middle of the macro code.

Other than using a label for the jump, is there a way around this?

I have about 7-8 lines od code that need this logic and didn't want to use a lot of labels.

Anders
21st August 2004, 23:29
u could do:

function UnselectSectionFunc
!insertmacro UnselectSection ${MySec}
functionend

IfFileExists "$ApplicationDir\${MY_DIR}\${MY_EXE}" 0 +1
call UnselectSectionFunc

Joost Verburg
22nd August 2004, 16:51
First of all it should be +2 instead of +1 to jump over the next line.

Second, you should use a label when jumping over macros. A function won't help if you have to insert a macro multiple times with different parameters.

Deliverator
22nd August 2004, 18:39
I'm thinking of going with something like this for now.


!macro SetSection SectionName FileToCheck
!insertmacro SelectSection ${SectionName}
IfFileExists ${FileToCheck} 0 Skip${SectionName}
!insertmacro UnselectSection ${SectionName}
Skip${SectionName}:
!macroend

eccles
23rd August 2004, 08:33
Another option is LogicLib, which hopefully makes scripts more readable:!include LogicLib.nsh

...

${If} ${FileExists} "$ApplicationDir\${MY_DIR}\${MY_EXE}"
!insertmacro UnselectSection ${MySec}
${EndIf}