Old 9th May 2006, 18:59   #1
l_d_allan
Member
 
l_d_allan's Avatar
 
Join Date: Jun 2005
Location: Colorado Springs, CO
Posts: 94
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).

code:
# 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

Last edited by l_d_allan; 9th May 2006 at 20:36.
l_d_allan is offline   Reply With Quote
Old 9th May 2006, 19:05   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 9th May 2006, 21:15   #3
l_d_allan
Member
 
l_d_allan's Avatar
 
Join Date: Jun 2005
Location: Colorado Springs, CO
Posts: 94
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
code:
/* 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:
code:
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.
l_d_allan is offline   Reply With Quote
Old 9th May 2006, 21:25   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

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