l_d_allan
9th May 2006 18:59 UTC
HowTo: uppercase variable outside of function?
I looked in the documentation and on this forum, but didn't find an obvious way to uppercase a variable or defined variable outside of a function (for example, to change the OutFile name).
# File: CommonCode.nsh
!include "WordFunc.nsh"
Var MixedCaseVar
Var UpperCaseVar
# StrCpy doesn't work outside of functions
strcpy $MixedCaseVar "camelCaseName"
strcpy $UpperCaseVar $MixedCaseVar
# Does StrFilter work outside of functions?
${StrFilter} $UpperCaseVar "+"
OutFile $UpperCaseVar + "_Setup.exe"
I've got a whole series of installers that:
!include CommonCode.nsh
Afrow UK
9th May 2006 19:05 UTC
Hmmm. You're getting confused with run-time and compile-time. This has been explained millions of times before. Variables contain data to be used at run-time, i.e. when the installer is executed by the end user. How can you possibly set the name of the installer to a value that hasn't even been created yet?
-Stu
l_d_allan
9th May 2006 21:15 UTC
Ok, here is more info on what I want to do. Sorry I wasn't clear in the original question.
There will eventually be about 50 or more separate scripts that allow installation of different Bibles (like KJV, ESV, NET, ASV, WEB, etc). The only difference is which files are included. However, some of the information used by the installer is lower case, and some is upper case (especially case sensitive URL links to use for Internet downloads.)
The app is part of a "family of applications", so the main nsis script is fairly elaborate to detect previous installations of 4 other apps within the "family" so resources can be shared.
Here is an example of the nsis code that !includes a 700+ line .nsh file
/* File: LcdBibleStarterKitSetup_KJV.nsi */
!define STARTER_KIT_BIBLE_ABBREV Kjv
!define STARTER_KIT_BIBLE_ABBREV_UC KJV
!define STARTER_KIT_BIBLE_NAME "King James Version"
!define STARTER_KIT_BIBLE_MODNAME KjvLite
!define STARTER_KIT_BIBLE_DRIVER_NAME ztext
!define STARTER_KIT_BIBLE_FILE_EXT bzs
!include "CrosswireFamilyDefines.nsh"
!include "LcdProjectDefines.nsh"
# Essentially everything is in this 700+ line .nsh file
!include "LcdBibleStarterKitSetup.nsh"
Within the file LcdBibleStarterKitSetup.nsh, there are lines such as:
OutFile "${PROJECT_NAME}StarterKitSetup_${STARTER_KIT_BIBLE_ABBREV_UC}.exe"
It works fine to have these lines:
!define STARTER_KIT_BIBLE_ABBREV Kjv
!define STARTER_KIT_BIBLE_ABBREV_UC KJV
This would be fine if there were only one or two scripts, but with 50 or more installers, it seemed worth checking if there was a way to do the UC (upper-case) with a function rather than having to define two separate constants.
I had put together 4 scripts, and then realized that the second line above was advisable for the URL link to be correct on a Linux webhost that uses Apache. That involved changes to 4 files rather than one file. For future maintenance and enhancements, it will obviously be easier to change the one .nsh file than 50+ "stubs" that !include the .nsh file.
To illustrate, here is a link to a "StarterKit" (1.4mb):
LcdBibleStarterKitSetup_WEB
Thanks for your help.
Afrow UK
9th May 2006 21:25 UTC
There's no simple way to do this. You'd have to write an external parser executable which does the conversions. This could even be another NSIS installer.
http://nsis.sourceforge.net/Invoking...n_compile-time
-Stu