- NSIS Discussion
- String and file
Archive: String and file
StephanB86
2nd December 2009 13:40 UTC
String and file
How do I use a string and a variable in one line.
For example,
MessageBox MB_OK "$IniFileInstalledApp\app.exe"
This works.
However, sometimes the ($IniFileInstalledApp-)variable should be blank, as it is configured in the ini.
MessageBox MB_OK "$IniFileInstalledAppapp.exe"
This won't work. How can I take care that this will work?
Just tried with
MessageBox MB_OK "$IniFileInstalledApp"+"app.exe" , however it won't work either.
Hope that i'm clear enough 8)
kichik
2nd December 2009 13:45 UTC
Not that clear. If $iniFileInstalledApp is empty, you'll just get "\app.exe". What are you expecting to happen?
Wizou
2nd December 2009 14:10 UTC
if $IniFileInstalledApp is blank, replace its content with ".", so it will work (ie: use current directory) if you append a \path...
kichik
2nd December 2009 14:23 UTC
!include LogicLib.nsh
${If} $IniFileInstalledApp == ""
StrCpy $IniFileInstalledApp "."
${EndIf}
MessageBox MB_OK "$IniFileInstalledApp\app.exe"
StephanB86
2nd December 2009 14:47 UTC
The executable i refer to could be placed in some other directory just like system32. But often it is in a custom directory.
At the moment it is not an opportunity to include the files.
The first check is if the directory exists and if not then set the variable to blank, but then I'm stuck with the backslash.
Then I though I could use the location WITH a backslash and then the file. But then it will handle it all as a variable.
MSG
2nd December 2009 14:52 UTC
Err.... What? o____O
StephanB86
2nd December 2009 16:03 UTC
Or just merge to strings like:
WriteLog "text1"+"text2"
Wizou
2nd December 2009 16:19 UTC
Originally posted by StephanB86
The first check is if the directory exists and if not then set the variable to blank, but then I'm stuck with the backslash.
Where do you want to install the files, if the directory does not exist ?
StephanB86
3rd December 2009 07:36 UTC
It's not going about the installation directory. It's about a resourcekit. The location is defined in the ini-file.
MSG
3rd December 2009 07:40 UTC
StephanB86, could you PLEASE tell us what it is that you're trying to accomplish. I, for one, haven't the slightest clue what you're talking about.
(If you don't speak English, please find someone who can translate for you.)
StephanB86
3rd December 2009 08:10 UTC
For example the app.exe must run. But I cannot use $appDirapp.exe I must run $appDir\app.exe
So I was looking for merging these two as it must be running.
On the $appDir there's a check if the directory exists.
MSG
3rd December 2009 08:51 UTC
So... you just want to append two strings? Then just do that. Append them.
Exec "$appDir\app.exe"
Like I said. Please tell us what you're trying to accomplish. Sentences like "On the $appDir there's a check if the directory exists" don't mean anything.
StephanB86
4th December 2009 07:52 UTC
Is there a possibility to write two variables after eachother, without any space?
${appDir}${file} is not working.
MSG
4th December 2009 08:27 UTC
Yes, that is possible.
variable 1: MyVar1 - contains "foo"
variable 2: MyVar2 - contains "bar"
MessageBox MB_OK "$MyVar1$MyVar2" - will output "foobar".
Like I just told you. If you want to append two variables, just append them.
StephanB86
4th December 2009 10:20 UTC
And What about:
variable 1: MyVar1 - contains "foo"
"$MyVar1bar"
This won't work, right? And that's what I was looking for.
Wizou
4th December 2009 10:44 UTC
interesting remark...
after a quick test, it seems to work however... (i wonder how ^^)
OutFile "test.exe"
>Var myvar
Section
StrCpy $myvar "foo"
MessageBox MB_OK "$myvarbar"
>SectionEnd
>
displays "foobar"
if you feel troubled by this, you might want to use $0..$9 or $R0..$R9 instead of a named variable
Wizou
4th December 2009 10:48 UTC
note that
OutFile "test.exe"
>Var myva
>Var myvar
Section
StrCpy $myva "fu"
StrCpy $myvar "foo"
MessageBox MB_OK "$myvarbar"
>SectionEnd
>
displays "foobar" and not "furbar"
(i wonder how the logic works to determine which sequence of letters is part of a variable name)
StephanB86
4th December 2009 13:21 UTC
Thx :) This all really solved the problem. In this case we used Named vars (Global).