 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Dippy46
Joined: 06 Jul 2004 Posts: 171 Location: Manchester, England.
|
Posted: Mon Jan 17, 2005 11:24 pm Post subject: Removing Leading and Trailing WhiteSpace |
|
|
Hi Folks,
Some thoughts on this by others please
First time I have needed to remove leading and trailing whitespace from a string. Turned to the following functions but got misled (not too difficult at my age). It is traditional in most basics and Xbases that rtrim and ltrim are used to remove said spaces. However it would seem that in their present format, these functions are surplus to requirements anyway because they both can be implemented with StringMid as demonstrated below
-------------------------------------------------
Functions in question:
StringTrimLeft , OutputVar, InputVar, Count
StringTrimRight, OutputVar, InputVar, Count
-------------------------------------------------
;StringTrimLeft implementation
StringMid, OutputVar, InputVar, 1, Count
;StringTrimRight implementation
StringLen, LenOfStr, InputVar
StringMid, OutputVar, InputVar, LenOfStr, Count , L
In fairness, this does seem to be an AutoIt artefact ?? QED
And thanx to AHK we have more power to the elbow.
Thanx Chris  _________________ Simple ideas lie within reach, only of complex minds |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Mon Jan 17, 2005 11:39 pm Post subject: |
|
|
Look like it's already available
| Quote: | AutoTrim
--------------------------------------------------------------------------------
Determines whether SetEnv and "var = value" statements remove spaces and tabs.
AutoTrim, On|Off
Parameters
On|Off On: tabs and spaces at the beginning and end of a string are removed from a variable whenever it is assigned a new value. This mirrors AutoIt2's behavior and is the default.
Off: tabs and spaces are not removed.
|
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Tue Jan 18, 2005 12:22 am Post subject: Re: Removing Leading and Trailing WhiteSpace |
|
|
| Dippy46 wrote: | | I have needed to remove leading and trailing whitespace from a string. | BoBo is right. Since AutoTrim is on by default, all you need to do to get rid of leading and trailing whitespace is to assign a variable to itself:
Var = %Var% |
|
| Back to top |
|
 |
Dippy46
Joined: 06 Jul 2004 Posts: 171 Location: Manchester, England.
|
Posted: Tue Jan 18, 2005 2:22 am Post subject: |
|
|
Hi Guys,
Sorry about that (slapped wrists) under duress !
MUST read the documentation
Thanx Chris and BoBo for the prompt reply _________________ Simple ideas lie within reach, only of complex minds |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|