Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 6th February 2017, 11:39   #1
tham123
Junior Member
 
Join Date: Feb 2017
Posts: 3
Is there a way to get a warning when a constant is undefined?

Consider the following code:

PHP Code:
VIProductVersion "1.1.1.${PATCH_VER}
If PATCH_VER was not set earlier by a mistake, the version will turn out to be 1.1.1.${PATCH_VER}.

Is there any way to get an error/warning message in a situation like this?

Use case: We have a lot of installers being built and NSIS files change regularly, and a mistake like this will not get noticed unless manually checked.
tham123 is offline   Reply With Quote
Old 6th February 2017, 13:01   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,588
Quote:
VIProductVersion "1.1.1.${PATCH_VER}"
VIAddVersionKey "ProductName" "Test Application"
does not compile in NSIS v3 if PATCH_VER is not defined to be a valid number.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 6th February 2017, 13:08   #3
tham123
Junior Member
 
Join Date: Feb 2017
Posts: 3
Quote:
Originally Posted by Anders View Post
does not compile in NSIS v3 if PATCH_VER is not defined to be a valid number.
Sorry, that was a bad example. I meant something like this:

PHP Code:
VIAddVersionKey "FileDescription" "My ${APP_NAME} Installer" 
Is there a way I can get a warning/error if APP_NAME is not defined here?
tham123 is offline   Reply With Quote
Old 6th February 2017, 15:11   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,588
You can use a little hack like this:

PHP Code:
!macro VIAddVersionKey name data
!define /redef TEMPCHECK_VIAddVersionKey ""
!searchparse /noerrors "${data}" "${U+24}TEMPCHECK_VIAddVersionKey
VIAddVersionKey 
"${name}" "${data}"
!if "${TEMPCHECK_VIAddVersionKey}!= ""
!error "Bad VIAddVersionKey data: ${data}"
!endif
!
undef TEMPCHECK_VIAddVersionKey
!macroend

!define PATCH_VER 2
!insertmacro VIAddVersionKey "ProductName 1" "Test Application PATCH_VER"
!insertmacro VIAddVersionKey "ProductName 2" "Test Application ${PATCH_VER}"
!insertmacro VIAddVersionKey "ProductName 3" "Test Application ${PATCH_VER_DOESNOTEXIST}
Will not work if your string is supposed to contain a $ but then you could change the search to ${ probably...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 8th February 2017, 10:16   #5
tham123
Junior Member
 
Join Date: Feb 2017
Posts: 3
Thank you!
tham123 is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Tags
undefined, warning

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump