Page 1 of 1

"Replace String" not working

Posted: Mon Sep 22, 2014 1:38 am
by anja_laenge
Hello,

in my MSI Code I am trying to use replace string to eliminate double backslashes. This does not work. Do I have to use an escape sequnce? How to get the desired result?
My code:
Replace \\ with \ in variable INI_DATABASE


~InstallAware Clipboard Data~
~Replace String~
~{DA594190-1EDD-4924-BB91-97707554DB60}~
~INI_DATABASE~
~\\~
~\~
~TRUE~
~TRUE~


Regards
Anja

Re: "Replace String" not working

Posted: Mon Sep 22, 2014 11:01 am
by FrancescoT
Dear Anja,

I just tried the following and it works fine.

Code: Select all

~InstallAware Clipboard Data~
~MessageBox~
~{158D0B9E-5122-4613-948C-975FCF727049}~
~~
~INI_DATABASE = $INI_DATABASE$~
~0~
~1~
~~
~Replace String~
~{98531009-1298-4A0E-BC3F-91944AE20721}~
~INI_DATABASE~
~\\~
~\~
~TRUE~
~FALSE~
~Set Variable~
~{CEEDD1E2-6F66-4AAD-A4E9-FA173B047905}~
~INI_DATABASE$MYAH$MYAH$FALSE~
~\\MyPath~


Regards

Re: "Replace String" not working

Posted: Tue Sep 23, 2014 1:08 am
by anja_laenge
Hi Francesco,

I solved it but noticed a noteworthy feature:

Get Folder Location System->Program Files Directory into PROGRAMFILES
Set Variable INI_DATABASE to $PROGRAMFILES$\MyPath\Database
[...]
Replace \\ with \ in variable INI_DATABASE

The above does not work. Inserting the line
Set Variable INI_DATABASE to $INI_DATABASE$
as next to last line makes it work.

It seems that "Replace String" does not resolve the variable to its final value but works on the literal string "$PROGRAMFILES$\MyPath\Database" - which obviously contains no double backslashes.
Of course that can be bypassed by removing the backslash in the variable assignment but this behaviour of "Replace String" seems quite odd if you're coming from a developer background.

Regards
Anja

Re: "Replace String" not working

Posted: Tue Sep 23, 2014 11:47 am
by FrancescoT
Dear Anja,

I am very sorry, but I am really not able to replicate your findings ... supposing that I haven't missed anything.

Using the following code snippet, the double slash gets removed correctly and always by the Replace String command.
I used a messagebox before and after the Replace String command, to verify the correct behavior.

Set Variable PROGRAMFILES to
Get Common Folder Location System->Program Files Directory into PROGRAMFILES
Set Variable INI_DATABASE to $PROGRAMFILES$\MyPath
MessageBox: , INI_DATABASE = $INI_DATABASE$
Replace \\ with \ in variable INI_DATABASE
MessageBox: , INI_DATABASE = $INI_DATABASE$


Code: Select all

~InstallAware Clipboard Data~
~MessageBox~
~{771EDAF1-E247-4D5E-BC75-F3505F6615CA}~
~~
~INI_DATABASE = $INI_DATABASE$~
~0~
~1~
~~
~Replace String~
~{4871BDBA-6FD0-42B4-BA8E-EBC2B2DB608D}~
~INI_DATABASE~
~\\~
~\~
~TRUE~
~FALSE~
~MessageBox~
~{9621C3AF-5817-4BE0-8EB9-8A3928E78CC7}~
~~
~INI_DATABASE = $INI_DATABASE$~
~0~
~1~
~~
~Set Variable~
~{BABAF01F-C579-48D3-9005-0319223C7C11}~
~INI_DATABASE$MYAH$MYAH$FALSE~
~$PROGRAMFILES$\MyPath~
~Get Folder Location~
~{17C40206-7A5D-4D5F-A613-5C192156B1AE}~
~PROGRAMFILES~
~20~
~TRUE~
~Set Variable~
~{473A4250-0D73-41BD-B646-589BB1BEE753}~
~PROGRAMFILES$MYAH$MYAH$FALSE~
~~


Regards