AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Removing Leading and Trailing WhiteSpace

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Dippy46



Joined: 06 Jul 2004
Posts: 171
Location: Manchester, England.

PostPosted: Mon Jan 17, 2005 11:24 pm    Post subject: Removing Leading and Trailing WhiteSpace Reply with quote

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 Smile

And thanx to AHK we have more power to the elbow.
Thanx Chris Very Happy
_________________
Simple ideas lie within reach, only of complex minds
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Mon Jan 17, 2005 11:39 pm    Post subject: Reply with quote

Look like it's already available Wink

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

PostPosted: Tue Jan 18, 2005 12:22 am    Post subject: Re: Removing Leading and Trailing WhiteSpace Reply with quote

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
View user's profile Send private message Send e-mail
Dippy46



Joined: 06 Jul 2004
Posts: 171
Location: Manchester, England.

PostPosted: Tue Jan 18, 2005 2:22 am    Post subject: Reply with quote

Hi Guys,
Sorry about that (slapped wrists) under duress !
MUST read the documentation Embarassed

Thanx Chris and BoBo for the prompt reply
_________________
Simple ideas lie within reach, only of complex minds
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group