Page 1 of 1

### What does this mean?

Posted: Mon Oct 31, 2005 2:55 pm
What does LTRIM\$ , RTRIM\$, and STR\$ mean?
example...LEFT\$(LTRIM\$(RTRIM\$(STR\$(q))), 1)
What would that do?

Posted: Mon Oct 31, 2005 3:20 pm

LTRIM cuts off all left spaces. RTRIM cuts off all right spaces EG

Code: Select all

``PRINT LTRIM\$(RTRIM\$("     I have extra spaces!             "));``
Would ouput "I have extra spaces!". As for STR\$, I dunno off hand. You can look it up.

Posted: Mon Oct 31, 2005 3:46 pm
Converts a variable into a string. Adds a leading space for signing (+/-)

Code: Select all

``````string\$="Test "+LTRIM\$(STR\$(123))
PRINT string\$
``````

Posted: Mon Oct 31, 2005 4:01 pm
Kylemc wrote:Converts a variable into a string. Adds a leading space for signing (+/-)

Code: Select all

``````string\$="Test "+LTRIM\$(STR\$(123))
PRINT string\$
``````
Except string is a reserved keyword and that code would never run

Posted: Mon Oct 31, 2005 4:10 pm
You get the idea.

### Re: What does this mean?

Posted: Mon Oct 31, 2005 6:26 pm
Anonymous wrote:What does LTRIM\$ , RTRIM\$, and STR\$ mean?
example...LEFT\$(LTRIM\$(RTRIM\$(STR\$(q))), 1)
What would that do?
LTRIM\$ trims off wightspaces(or spaces) left of a string:

Code: Select all

``````String = "     Hello     "

NewString = LTRIM\$(String)

NewString = "Hello    "``````
RTRIM\$ does the same just for the right side:

Code: Select all

``NewString = "    Hello"``
STR\$ turns a numerical variable to a string.

Code: Select all

``````Var = 100

String = STR\$(Var)

String = "100"``````
As for the code:

Code: Select all

``````q = 200

PRINT LEFT\$(LTRIM\$(RTRIM\$(STR\$(q))), 1)``````
Output is: 2

Posted: Mon Oct 31, 2005 7:44 pm
Let me walk you through Ratt's example, step by step as it evaluates the statement.

Code: Select all

``````q = 200

PRINT LEFT\$(LTRIM\$(RTRIM\$(STR\$(q))), 1)``````
1. It takes the STR\$ of 200, which gives us a string of 4 characters, a space and 200.

2. Next it does the RTRIM\$ which doesn't do anything because we have no trailing spaces. So we still have a space and 200.
3. Now it does the LTRIM\$, which removes the leading space. We now have 3 characters, 200.

4. Now it does the LEFT\$ on these 3 characters grabbing only the first character as specified by the ",1". So, the final result is 2.

It performs these functions in that order because, in the order of the parenthesis, each function needs a value or a string on which to operate. The STR\$ goes first since it has the value of q to work with. Then the RTRIM\$ works on the string result of the STR\$, and so on.
*****

Posted: Mon Oct 31, 2005 8:27 pm
I was hoping to spark creativity to figure why it does it.... But you are probaly right to explian it for him, it is rather a tricky code being all in one line...

Posted: Mon Oct 31, 2005 9:14 pm
Thanks. You all helped me out a lot.