5.2 Predefines

You can use these standard predefines to automatically add the build time to the title of development versions, add the date to the version number, etc.

5.2.1 ${COUNTER}

Expands to a number (Starting at 0 and incrementing by 1 every time it is used)

5.2.2 ${FILE}

Current script name.

5.2.3 ${FILEDIR}

Current script directory.

5.2.4 ${LINE}

Current line number.

5.2.5 ${DATE}

Date when the script started compiling according to the current locale.

5.2.6 ${TIME}

Time when the script started compiling according to the current locale.

5.2.7 ${TIMESTAMP}

Date & time of the last modification to the script file according to the current locale.

5.2.8 ${NSIS_VERSION}

NSIS version used to build the script.

5.2.9 ${NSIS_PACKEDVERSION}

NSIS version as a 32-bit number.

  1. !if 0x3014000 >= "${NSIS_PACKEDVERSION}"
  2. !error "NSIS 3.15 or higher is required to build this installer!"
  3. !endif

5.2.10 ${NSIS_CHAR_SIZE}

The size of a character code unit (in bytes). 1 in ANSI installers and 2 in Unicode installers.

A grapheme cluster consists of a base character plus optional combining characters and diacritics and is defined as one or more code points. One or more code units is required to encode a single code point.

5.2.11 ${NSIS_PTR_SIZE}

The size of a pointer (in bytes) in the generated installer.

5.2.12 ${U+1}…${U+10FFFF}

A Unicode (UCS-4) character.

  1. DetailPrint "${U+2115}SIS" # DOUBLE-STRUCK CAPITAL N + "SIS"

5.2.13 Scope Predefines

Standard predefines that contain information about the current code scope.

5.2.13.1 ${GLOBAL}

Defined in the global scope.

  1. Section test
  2. !ifdef ${__GLOBAL__}
  3. !error "this shouldn't be here!"
  4. !endif
  5. SectionEnd
  6.  
  7. PageEx instfiles
  8. !ifdef ${__GLOBAL__}
  9. !error "this shouldn't be here!"
  10. !endif
  11. PageExEnd

5.2.13.2 ${SECTION}

Defined as the section name, without any prefixes, in section scope.

  1. !ifdef __SECTION__
  2. !error "this shouldn't be here!"
  3. !endif
  4.  
  5. Section test
  6. !ifndef __SECTION__
  7. !error "missing predefine!"
  8. !endif
  9.  
  10. !if ${__SECTION__} != test
  11. !error "wrong predefine value!"
  12. !endif
  13. SectionEnd
  14.  
  15. Section !test
  16. !if ${__SECTION__} != test
  17. !error "wrong predefine value!"
  18. !endif
  19. SectionEnd
  20.  
  21. Section un.test
  22. !if ${__SECTION__} != test
  23. !error "wrong predefine value!"
  24. !endif
  25. SectionEnd

5.2.13.3 ${FUNCTION}

Defined as the function name, without any prefixes, in function scope.

  1. !ifdef __FUNCTION__
  2. !error "this shouldn't be here!"
  3. !endif
  4.  
  5. Function test
  6. !ifndef __FUNCTION__
  7. !error "missing predefine!"
  8. !endif
  9.  
  10. !if ${__FUNCTION__} != test
  11. !error "wrong predefine value!"
  12. !endif
  13. FunctionEnd
  14.  
  15. Function un.test
  16. !if ${__FUNCTION__} != test
  17. !error "wrong predefine value!"
  18. !endif
  19. FunctionEnd

5.2.13.4 ${PAGEEX}

Defined as the page type in PageEx scope.

  1. !ifdef __PAGEEX__
  2. !error "this shouldn't be here!"
  3. !endif
  4.  
  5. PageEx instfiles
  6. !ifndef __PAGEEX__
  7. !error "missing predefine!"
  8. !endif
  9.  
  10. !if ${__PAGEEX__} != instfiles
  11. !error "wrong page type"
  12. !endif
  13. PageExEnd

5.2.13.5 ${UNINSTALL}

Defined in section, function or PageEx scopes of the uninstaller.

  1. !ifdef __UNINSTALL__
  2. !error "this shouldn't be here!"
  3. !endif
  4.  
  5. Function test
  6. !ifdef __UNINSTALL__
  7. !error "this shouldn't be here!"
  8. !endif
  9. FunctionEnd
  10.  
  11. Function un.test
  12. !ifndef __UNINSTALL__
  13. !error "missing predefine!"
  14. !endif
  15. FunctionEnd

5.2.13.6 ${MACRO}

Defined as the name of the current macro.