简体   繁体   中英

NSIS - Use offset with combination of !insertmacro

I was forced to use labels in my installer like this:

  IfFileExists "$INSTDIR\XX\*.*" XX_Found 0
      !insertmacro UnselectSection ${Section_XX}
  XX_Found:

  IfFileExists "$INSTDIR\YY\*.*" YY_Found 0
      !insertmacro UnselectSection ${Section_YY}
  YY_Found:

because these does not work:

  IfFileExists "$INSTDIR\XX\*.*" +2 0
      !insertmacro UnselectSection ${Section_XX}

  IfFileExists "$INSTDIR\YY\*.*" +2 0
      !insertmacro UnselectSection ${Section_YY}

Any proposal why? I think its because of !insertmacro statement but i could not find any information or workaround on the internet.

You cannot use relative jumps on macros because a macro can contain more than one instruction. !insertmacro basically pastes the content of the !macro into your code during the first compiler phase.

I prefer using the LogicLib:

!include LogicLib.nsh
Section
${If} ${FileExists} "$InstDir\file.ext"
  !insertmacro ...
${EndIf}
SectionEnd

You can also use labels to jump over !insertmacro .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM