Archive: String and file


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)


Not that clear. If $iniFileInstalledApp is empty, you'll just get "\app.exe". What are you expecting to happen?


if $IniFileInstalledApp is blank, replace its content with ".", so it will work (ie: use current directory) if you append a \path...


!include LogicLib.nsh

${If} $IniFileInstalledApp == ""
StrCpy $IniFileInstalledApp "."
${EndIf}
MessageBox MB_OK "$IniFileInstalledApp\app.exe"

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.


Err.... What? o____O


Or just merge to strings like:

WriteLog "text1"+"text2"


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 ?

It's not going about the installation directory. It's about a resourcekit. The location is defined in the ini-file.


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.)


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.


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.


Is there a possibility to write two variables after eachother, without any space?
${appDir}${file} is not working.


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.


And What about:
variable 1: MyVar1 - contains "foo"

"$MyVar1bar"

This won't work, right? And that's what I was looking for.


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

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)

Thx :) This all really solved the problem. In this case we used Named vars (Global).