PDA

View Full Version : How to use and Trim to get variable strings


pw317
03-29-2004, 04:53 PM
Hello. I am probably asking a very dumb question but I've found it is easier to ask dumb questions than none at all.

The problem is: The Trim function returns a new string with trailing blanks removed. However, strings can only be defined as fixed length. The fixed length string will now have added blanks if it is longer. There doesn't seem to be any way to exploit the Trim function so that I can set a string variable that has trailing blanks removed.

What I want are variable length strings with leading and trailing blanks removed. I cannot find a simple way to do this.

tzeis
03-30-2004, 12:23 AM
I generally trim the character argument at the point where I need to use it. An alternative might be to store the beginning and ending index of the substring you want to keep and specify the substring where you need the trimmed string. If you are sending the variable as an argument, you can trim the actual argument, and make the dummy argument the exact size to hold the string by using "*" as the length indicator.

pw317
03-30-2004, 04:17 AM
Thanks. That sounds plausible. Cumbersome but I think I can live with it.