Old 5th February 2009, 14:31   #1
KalleBalle
Junior Member
 
Join Date: Feb 2009
Posts: 2
Name, OutFile, InstallDir

Hey! I am new to this and have mananged to find answers to most questions that have poped up. But with this one I could use some help.

I need to be able to change the name, outfile and installdir among other things depending on the users nationality. Right now the installer is a modified version of Modern UIs MultiLanguage.nsi.

So I have the following code:

var PublisherName
var ProductGroup
var ProductName

;Name and file
Name $ProductName

;Default installation folder
InstallDir "$PROGRAMFILES\$(^PublisherName)\$(^ProductGroup)\$(^ProductName)"

Function .onInit

StrCpy $PublisherName "a"
StrCpy $ProductGroup "b"
StrCpy $ProductName "c"

When the installer is run the default path is:
C:\Programs\\\

Guessing this means that the InstallDir code is run before the .onInit and not update after the .onInit has been run. But there must be some way to make this work...

Help would be greatly appriciated!
KalleBalle is offline   Reply With Quote
Old 5th February 2009, 14:36   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
Function .onInit
...
StrCpy $instdir "c:\some fancy path\$myvar\hello"
FunctionEnd

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 5th February 2009, 14:37   #3
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
What you're looking for is !define and ${const}.
code:
!define PUBLISHER_NAME a
!define PRODUCT_GROUP b

InstallDir $PROGRAMFILES\${PUBLISHER_NAME}\${PRODUCT_GROUP}


NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 5th February 2009, 14:42   #4
KalleBalle
Junior Member
 
Join Date: Feb 2009
Posts: 2
Wow, those are some fast replies, impressive and much appreciated. Bit confused. Can NSIS !define be changed at run-time? Else I don't understand how that would work...
KalleBalle is offline   Reply With Quote
Old 5th February 2009, 14:48   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
NSIS defines can't be changed at runtime, but if you want to change OutFile as well, you have to use !defines as that can never change on runtime.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik 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