Old 9th August 2010, 16:56   #1
Noude
Junior Member
 
Join Date: Aug 2010
Posts: 40
Unhappy Variable in a string

Hello !


I search how to put a variable in a string please.

I explain, I have this:

Var EtudeName
ReadINIStr $R1 $DESKTOP\Data.ini "Data" "EtudeName"
StrCpy $EtudeName $R1
;----Here I have $EtudeName == Tomcat 6.0----
File "C:\Program Files\Admin builder\$EtudeName.zip"

But it don't work !
The command File said that it doesn't find the file "C:\Program Files\Admin builder\$EtudeName.zip"
It is normal because I want to have "C:\Program Files\Admin builder\Tomcat 6.0.zip"

I tried with '$EtudeName' or with "$EtudeName", ... I tried everything but...

Please help... =(
Noude is offline   Reply With Quote
Old 9th August 2010, 18:42   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You're confusing compile time and run time. The compiler needs to know the file path at compile time to compress the file therefore you can't give it a run time variable. Instead you want to use LogicLib and selectively call the correct File instruction depending on the value of $EtudeName.

Stu
Afrow UK is offline   Reply With Quote
Old 9th August 2010, 20:20   #3
Noude
Junior Member
 
Join Date: Aug 2010
Posts: 40
(sorry for my english I'm French,I posted this question on Todae but no response... =( )

Oooooooooh thanks for your answer !!! =)

So I have to use the LogicLib ?

I don't really understand all I'm sorry...

I have to do what with the LogicLib ? How can I do that I want to do ?

I don't want the code but just can you explain me a little bit more please ?

I'm in Internship in an entreprise (In French "stage en entreprise"^^) and I have my deadline the 19th August... :/

The C language miss me... snif
Noude is offline   Reply With Quote
Old 10th August 2010, 05:42   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
As he said, the File command is evaluated at compile time (that means when the installer is being compiled). I think you want to read the INI at the *user's* computer, so you cannot do different File commands for different INI values (obviously).

PHP Code:
ReadINIStr $EtudeName $DESKTOP\Data.ini "Data" "EtudeName"
${If} $EtudeName == "Tomcat 6.0"
  
File "C:\Program Files\Admin builder\Tomcat 6.0.zip"
${ElseIf} $EtudeName == "Tomcat 5.0"
  
File "C:\Program Files\Admin builder\Tomcat 5.0.zip"
${ElseIf} $EtudeName == "Tomcat 5.1"
  
File "C:\Program Files\Admin builder\Tomcat 5.1.zip"
(etcetc)
{
$EndIf
Note: Because you want to install a different file for every value in that ini, your installer will probably end up being rather big.

(If you want to read the INI on the *compiler's* computer, then you cannot use ReadINIStr because you have to use compile-time commands. There is no standard compiletime command to read INI strings. You can use a vbscript, or an exe file you created yourself, or whatever.)
MSG is offline   Reply With Quote
Old 10th August 2010, 08:49   #5
Noude
Junior Member
 
Join Date: Aug 2010
Posts: 40
Ah OK !

I will try something, Thanks for help !

If the thing I want to do don't works I will be back here =)

Thanks !
Noude is offline   Reply With Quote
Old 10th August 2010, 10:24   #6
Noude
Junior Member
 
Join Date: Aug 2010
Posts: 40
Now it's okay ! I don't really use your "method" but now it's work !

it's really hard to tell you how I did it in English but in any case it works great !

Thanks for your help !
Noude is offline   Reply With Quote
Old 10th August 2010, 10:47   #7
Noude
Junior Member
 
Join Date: Aug 2010
Posts: 40
And just a little last thing.

I have a full path:

"C:\Documents and Settings\arelliaud\Bureau\Installeur\Install\Java\JRE.exe"

And, in my script I want to utilise "File"

So can I do File /r "C:\Documents and Settings\arelliaud\Bureau\Installeur\Install\Java\JRE.exe" ?

I don't think so... It do really strange things in compil time !

And I have no choice, I have to put the full path like this =(
Noude is offline   Reply With Quote
Old 10th August 2010, 11:10   #8
Noude
Junior Member
 
Join Date: Aug 2010
Posts: 40
Nooooo It's okay !

Thanks for all ! =)
Noude is offline   Reply With Quote
Old 10th August 2010, 15:06   #9
Noude
Junior Member
 
Join Date: Aug 2010
Posts: 40
Hellow !

I've already a new last question pleaaaase =(

If my boolean is at 1 I have to compil with "File "${FILEJAVA}""

But if my boolean is at 0 I don't want to compil with "File "${FILEJAVA}"" because if my boolean is at 0, ${FILEJAVA} doesn't exist ! So: error.

How can I do please ? =(

PHP Code:
ReadINIStr     $Bool_Java         $PLUGINSDIR\SelectElements.ini     "Field 9"  "State"

;With a manipulation I put the value of $Bool_Java in the !define BOOL_JAVA
;There's no problem with this ;)

!define BOOL_JAVA 0

Section "Java"                     Java_JRE

!if ${BOOL_JAVA} == 1
Goto begin
!else
Goto end
!endif

begin:
SetOutPath    $TEMP
File        "${FILEJAVA}"

; Installation JRE
    nsExec::ExecToStack '
$TEMP\${JAVA}'

end:
SectionEnd 

Last edited by Noude; 10th August 2010 at 15:42.
Noude is offline   Reply With Quote
Old 10th August 2010, 15:37   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Again you're confusing compile time and run time. Everything beginning with a ! are compile time instructions. Read the docs. Just wrap the entire section in an !if/!endif.

Stu
Afrow UK is offline   Reply With Quote
Old 10th August 2010, 15:50   #11
Noude
Junior Member
 
Join Date: Aug 2010
Posts: 40
Ow yeeeeeeeeeees ! It's working ! =)

Thank you !

I read the doc but I've found a lot of things but not this...

Thx a lot !
Noude is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
bonjour, file, put, string, variable

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