- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: How to trim trailing blanks from a string
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
1.)How can I trim trailing blanks from a string? I need to check if a string is empty. If it is not then I need to perform an action.
Example: hString = " ";
2.)Is there a single command which will trim trailing blanks? Also what if someone enters a tab and it is saved in the string? How would I ignore tab characters?
StrTrim does not return string, hence modify
exampleString = StrTrim(exampleString );
to
StrTrim(exampleString ); // exampleString passed as reference, hence changes will be reflected back
You can refer below link for return values of StrTrim method
See the previous thread related to almost your query on string:
https://community.flexera.com/t5/InstallShield-Forum/Remove-Spaces-from-string-with-Installscript/m-p/40185
https://helpnet.flexerasoftware.com/installshield21helplib/Subsystems/installshield21langref/helplibrary/LangrefString_functions.htm
There is no built-in method to remove trailing spaces alone. You can use StrTrim to remove both the leading and trailing spaces and tabs from a string
or
You can write your own method as your requirement. You can find example here.
https://community.flexera.com/t5/InstallShield-Knowledge-Base/String-Indexing-Example/ta-p/4526
I tried using StrTrim but I am getting an error message : "string value required". Does anyone have any idea why this is happening?
string exampleString = " ";
exampleString = StrTrim(exampleString ); // Gives compile error message "string value required".
StrTrim does not return string, hence modify
exampleString = StrTrim(exampleString );
to
StrTrim(exampleString ); // exampleString passed as reference, hence changes will be reflected back
You can refer below link for return values of StrTrim method