This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: TextSubSubstitute does not append backslash !
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 17, 2008
11:13 AM
TextSubSubstitute does not append backslash !
Seems TextSubSetValue or TextSubSubstitute does not associate/replace a trailing backslash. I am trying to replace the TEMP variable in the string but these function always remove the trailing backslash and give wrong result. Can somebody help here:
sNewStr = "-s -a -f1\"\Install.iss\" ;
s1 = sNewStr;
TextSubParseTextSub(sNewStr);
GetEnvVar(sNewStr, sEnvVar);
sEnvVar = sEnvVar + "\\";
TextSubSetValue(s1, sEnvVar, FALSE);
TextSubSubstitute(s1, FALSE);
The above code sets s1 as: "-s -a -f1\"C:\TempInstall.iss\"
whereas, I want to set s1 as: "-s -a -f1\"C:\Temp\Install.iss\"
Regards
sNewStr = "-s -a -f1\"
s1 = sNewStr;
TextSubParseTextSub(sNewStr);
GetEnvVar(sNewStr, sEnvVar);
sEnvVar = sEnvVar + "\\";
TextSubSetValue(s1, sEnvVar, FALSE);
TextSubSubstitute(s1, FALSE);
The above code sets s1 as: "-s -a -f1\"C:\TempInstall.iss\"
whereas, I want to set s1 as: "-s -a -f1\"C:\Temp\Install.iss\"
Regards
(5) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 17, 2008
11:22 AM
Please use a double backslash inside double-quotes to represent a literal backslash character (the same idea as using \" to represent a double-quote inside a string):
sNewStr = "-s -a -f1\"\\Install.iss\"";
sNewStr = "-s -a -f1\"
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 17, 2008
11:57 AM
Thanks Robert. But I am asking this data ("-s -a -f1"\Install.iss\") from end users via a different application...which is then passed to InstallScript. Hence it will be unfair for me to ask my end-users to put "\\" after just because IS does not support it? Please let me know.
Regards
Regards
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 17, 2008
12:49 PM
If I understand the question: If you pass the string from an external source, it will internally have the backslashes represented correctly; it's only if you have the backslash character directly in InstallScript that you need the double backslash.
Do you have an example of how you're getting the data from the external program? Do you have the same problem when you do that (as opposed to hard-coding the string in InstallScript)?
Do you have an example of how you're getting the data from the external program? Do you have the same problem when you do that (as opposed to hard-coding the string in InstallScript)?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 23, 2009
11:42 AM
I could not get the TextSubSubstitute to replace the backslash character at all, trailing or otherwise. So I wrote this general replace function. This works for all backslashes (i.e. not just trailing).
Note: I have not done extensive testing on this function; I only made sure it worked for my needs.
////////////////////////////////
export prototype Replace(BYREF STRING, STRING, STRING); // stringToOperateOn, find, replaceWith
////////////////////////////////
function Replace(text, find, replaceWith)
NUMBER listID, n, nResult;
STRING svString, svNew;
begin
listID = ListCreate(STRINGLIST);
StrGetTokens ( listID, text, find );
n = ListCount ( listID );
if (n > 0) then
nResult = ListGetFirstString (listID, svString);
while (nResult != END_OF_LIST)
svNew = svNew + svString + replaceWith;
nResult = ListGetNextString (listID, svString);
endwhile;
text = svNew;
endif;
end;
/////////////////////////////
Soap box:
InstallShield, when are you going to start really listening to/watching your users? Three or four years ago I was creating installations for our product. I had a terrible experience using your product. Our install person left the company 6 months ago and I'm back on maintaining our installer. I've been on it a couple weeks now and it's the same frustrating, time-consuming experience! Whatever your usability department is now, it needs to double in size, unless it's currently zero, in which case you need to get busy creating good one. (It's not that there are not good things with your product; it's that the ratio of bad:good is seemingly much higher than almost all other software tools I use. Kudos to the well-done features)
The replace function is found in most scripting languages. And it's not like you're trying to keep InstallScript as some lower level language--you have plenty of simplified functions: MessageBox, Delay, StrFind, etc.
Note: I have not done extensive testing on this function; I only made sure it worked for my needs.
////////////////////////////////
export prototype Replace(BYREF STRING, STRING, STRING); // stringToOperateOn, find, replaceWith
////////////////////////////////
function Replace(text, find, replaceWith)
NUMBER listID, n, nResult;
STRING svString, svNew;
begin
listID = ListCreate(STRINGLIST);
StrGetTokens ( listID, text, find );
n = ListCount ( listID );
if (n > 0) then
nResult = ListGetFirstString (listID, svString);
while (nResult != END_OF_LIST)
svNew = svNew + svString + replaceWith;
nResult = ListGetNextString (listID, svString);
endwhile;
text = svNew;
endif;
end;
/////////////////////////////
Soap box:
InstallShield, when are you going to start really listening to/watching your users? Three or four years ago I was creating installations for our product. I had a terrible experience using your product. Our install person left the company 6 months ago and I'm back on maintaining our installer. I've been on it a couple weeks now and it's the same frustrating, time-consuming experience! Whatever your usability department is now, it needs to double in size, unless it's currently zero, in which case you need to get busy creating good one. (It's not that there are not good things with your product; it's that the ratio of bad:good is seemingly much higher than almost all other software tools I use. Kudos to the well-done features)
The replace function is found in most scripting languages. And it's not like you're trying to keep InstallScript as some lower level language--you have plenty of simplified functions: MessageBox, Delay, StrFind, etc.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 26, 2009
12:14 PM
InstallScript provides a function named StrReplace that can be used to perform non-textsub related string replacement.
With regards to the original behavior posted, the string that contains the textsub to be replaced needs to be as Robert had mentioned:
sNewStr = "-s -a -f1\"\\Install.iss\"";
Without the double-backslash between and Install.iss, an invalid escape sequence is generated. This is equivalent to how hard-coded strings are handled by a C/C++ compiler.
One other thing to note about textsub behavior is TextSubSubstitute will remove any trailing backslashes on textsub values (in the above case, the '\' appended to sEnvVar for TEMP will be removed when TextSubSubstitute is called).
With regards to the original behavior posted, the string that contains the textsub to be replaced needs to be as Robert had mentioned:
sNewStr = "-s -a -f1\"
Without the double-backslash between
One other thing to note about textsub behavior is TextSubSubstitute will remove any trailing backslashes on textsub values (in the above case, the '\' appended to sEnvVar for TEMP will be removed when TextSubSubstitute is called).