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
- :
- Remove Spaces from string with Installscript
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
‎May 02, 2008
11:08 AM
Remove Spaces from string with Installscript
I am trying to remove spaces from a string using InstallScript. I try to use the StrReplace(svString," ","") which kinda works, but I have some strings that could have (" " )unknown number of spaces in the strings.
I was also looking from something that works like TRIM,LTRIM,RTRIM.
I was also looking from something that works like TRIM,LTRIM,RTRIM.
(6) Replies
‎May 02, 2008
02:31 PM
I haven't used them, but there seem to be some other approaches at www.installsite.org > InstallScript Samples > Strings.
‎May 02, 2008
03:14 PM
Thank your for the link.
I just finished this to strip out all spaces and tabs. here is what i used.
I just finished this to strip out all spaces and tabs. here is what i used.
StrReplace(svFileLines,"\t","",0);
StrReplace(svFileLines," "," ",0);
\\ optional if the first two do not remove all empty space from a string.
CharReplace(svFileLines,STRTOCHAR('\0'),STRTOCHAR(''),0);
‎May 02, 2008
03:33 PM
Try these...
[CODE]
EXTERNAL prototype My_StrTrim(BYREF STRING, BYVAL STRING);
EXTERNAL prototype My_StrTrimLeft(BYREF STRING, BYVAL STRING);
EXTERNAL prototype My_StrTrimRight(BYREF STRING, BYVAL STRING);
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_StrTrimLeft(strDestination, strSource)
NUMBER nSize;
NUMBER nIndex;
BOOL bDone;
CHAR strChar;
begin
strDestination = strSource;
nSize = StrLength(strSource);
if nSize > 0 then
nIndex = 0;
bDone = FALSE;
while ( (!bDone) && (nIndex < nSize) )
strChar = strSource[nIndex];
if (strChar = " ") || (strChar = "\t") || (strChar = "\r") || (strChar = "\n") then
nIndex = nIndex + 1;
else
bDone = TRUE;
endif;
endwhile;
if (nIndex >= 1) && (nIndex < nSize) then
strDestination = "";
StrSub(strDestination, strSource, nIndex, nSize - nIndex);
elseif (nIndex >= nSize) then
strDestination = "";
endif;
endif;
return 0;
end;
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_StrTrimRight(strDestination, strSource)
NUMBER nSize;
NUMBER nIndex;
BOOL bDone;
CHAR strChar;
begin
strDestination = strSource;
nSize = StrLength(strSource);
if nSize > 0 then
nIndex = nSize - 1;
bDone = FALSE;
while ( (!bDone) && (nIndex > 0) )
strChar = strSource[nIndex];
if (strChar = " ") || (strChar = "\t") || (strChar = "\r") || (strChar = "\n") then
nIndex = nIndex - 1;
else
bDone = TRUE;
endif;
endwhile;
if (nIndex < (nSize - 1)) && (nIndex > 0) then
strDestination = "";
StrSub(strDestination, strSource, 0, nIndex + 1);
elseif nIndex < 0 then
strDestination = "";
endif;
endif;
return 0;
end;
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_StrTrim(strDestination, strSource)
STRING strTemp;
begin
strTemp = strSource;
My_StrTrimLeft(strTemp, strTemp);
My_StrTrimRight(strTemp, strTemp);
strDestination = strTemp;
end;
[/CODE]
[CODE]
EXTERNAL prototype My_StrTrim(BYREF STRING, BYVAL STRING);
EXTERNAL prototype My_StrTrimLeft(BYREF STRING, BYVAL STRING);
EXTERNAL prototype My_StrTrimRight(BYREF STRING, BYVAL STRING);
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_StrTrimLeft(strDestination, strSource)
NUMBER nSize;
NUMBER nIndex;
BOOL bDone;
CHAR strChar;
begin
strDestination = strSource;
nSize = StrLength(strSource);
if nSize > 0 then
nIndex = 0;
bDone = FALSE;
while ( (!bDone) && (nIndex < nSize) )
strChar = strSource[nIndex];
if (strChar = " ") || (strChar = "\t") || (strChar = "\r") || (strChar = "\n") then
nIndex = nIndex + 1;
else
bDone = TRUE;
endif;
endwhile;
if (nIndex >= 1) && (nIndex < nSize) then
strDestination = "";
StrSub(strDestination, strSource, nIndex, nSize - nIndex);
elseif (nIndex >= nSize) then
strDestination = "";
endif;
endif;
return 0;
end;
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_StrTrimRight(strDestination, strSource)
NUMBER nSize;
NUMBER nIndex;
BOOL bDone;
CHAR strChar;
begin
strDestination = strSource;
nSize = StrLength(strSource);
if nSize > 0 then
nIndex = nSize - 1;
bDone = FALSE;
while ( (!bDone) && (nIndex > 0) )
strChar = strSource[nIndex];
if (strChar = " ") || (strChar = "\t") || (strChar = "\r") || (strChar = "\n") then
nIndex = nIndex - 1;
else
bDone = TRUE;
endif;
endwhile;
if (nIndex < (nSize - 1)) && (nIndex > 0) then
strDestination = "";
StrSub(strDestination, strSource, 0, nIndex + 1);
elseif nIndex < 0 then
strDestination = "";
endif;
endif;
return 0;
end;
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_StrTrim(strDestination, strSource)
STRING strTemp;
begin
strTemp = strSource;
My_StrTrimLeft(strTemp, strTemp);
My_StrTrimRight(strTemp, strTemp);
strDestination = strTemp;
end;
[/CODE]
‎May 02, 2008
03:40 PM
Thank you, this is perfect.
If you would not mind could you assist me with a couple other of my posts.
string parse/index error
http://community.macrovision.com/showthread.php?t=180356
XML and installscript
http://community.macrovision.com/showthread.php?t=180310
If you would not mind could you assist me with a couple other of my posts.
string parse/index error
http://community.macrovision.com/showthread.php?t=180356
XML and installscript
http://community.macrovision.com/showthread.php?t=180310
‎May 02, 2008
03:53 PM
Made some comments already... Take a look...
‎May 02, 2008
03:58 PM
Thank you. very much 🙂