Why there is no trim/trimright(/trimleft() functions in ahk?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
brandonhotkey
Posts: 113
Joined: 03 Nov 2013, 05:46

Why there is no trim/trimright(/trimleft() functions in ahk?

08 May 2014, 05:18

Edit: If anybody else wonders why cannot find trim()/trimleft()/trimright() functions, visit these pages:
http://ahkscript.org/docs/commands/index.htm
http://ahkscript.org/docs/commands/Trim.htm
Because google leads us to old command list where these functions are missing.


I looked about 1/2 hour but no trim function found. That's weird.

Can somebody write function trimLeft, trimRight or trim?

I tried this but then realized I don't know how to loop the string and refer it§s characters. It would be yet more complicated if it should consider Unicode characters...

Code: Select all

trimLeft(byref s, omitchars=" `s`n`r" ){
}
Last edited by brandonhotkey on 08 May 2014, 12:42, edited 3 times in total.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Why there is no trim function in ahk?

08 May 2014, 05:25

StringTrim?
like

Code: Select all

InputVar := "AutoHotkey"

; StringTrimLeft, OutputVar, InputVar, Count
StringTrimLeft, OutputVar, InputVar, 4
MsgBox, % OutputVar                                          ; Hotkey
String-Commands vs String-Functions
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
brandonhotkey
Posts: 113
Joined: 03 Nov 2013, 05:46

Re: Why there is no trim function in ahk?

08 May 2014, 05:46

jNizM wrote:StringTrim?
According manual:
StringTrim Removes a number of characters from the left or right-hand side of a string. It works similar like substr but I want to trim only certain characters if they are present.

But this is not what I want. I don't know count of characters. I don't know if there is a space on begin or no.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Why there is no trim function in ahk?

08 May 2014, 05:50

RegExReplace?
StringReplace?
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
brandonhotkey
Posts: 113
Joined: 03 Nov 2013, 05:46

Re: Why there is no trim function in ahk?

08 May 2014, 06:05

I have seen ppl using

Code: Select all

item := trim(A_loopfield, At) and
item := trim(A_loopfield)
this works for me:

Code: Select all

str := trim(str," ")
But I wonder why ppl using it so rarely. I could not find it on internet by searching "ahk trim" but I have found it my codes received by ppl
brandonhotkey
Posts: 113
Joined: 03 Nov 2013, 05:46

Re: Why there is no trim function in ahk?

08 May 2014, 06:21

To be more exact. I have looked for trim left or trimleft.

On this page
http://www.autohotkey.com/docs/commands.htm
where I have looked trim and I did not found it. But I went on page here:
http://www.aautohotkey.coma/docs/Functions.htm
and I could not find it neither.

Just now then I google trim the result is on lower position:
http://ahkscript.org/docs/commands/Trim.htm

So could anybody fix the links in docs to find word trim or trimleft/trimright to refer to the previous link? It could help to find the ltrim and rtrim.
Last edited by brandonhotkey on 08 May 2014, 12:43, edited 1 time in total.
just me
Posts: 9457
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Why there is no trim function in ahk?

08 May 2014, 11:31

Almost all parts of the online documentation of the old forum belong to AHK 1.0.48.05 released on September 25, 2009.

Poly seemingly doesn't like later versions.
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Why there is no trim function in ahk?

08 May 2014, 11:57

I believe you look for the "AutoTrim" setting.
ciao
toralf
brandonhotkey
Posts: 113
Joined: 03 Nov 2013, 05:46

Re: Why there is no trim function in ahk?

08 May 2014, 12:37

toralf wrote:I believe you look for the "AutoTrim" setting.
No, I have tried autotrim and did not work. Only trim() and possibly the other two functions.
It would be enough just to create thread containing words "trimleft and trimright" in the title for the google to be able to search better.
brandonhotkey
Posts: 113
Joined: 03 Nov 2013, 05:46

Re: Why there is no trim function in ahk?

08 May 2014, 12:44

just me wrote:Almost all parts of the online documentation of the old forum belong to AHK 1.0.48.05 released on September 25, 2009.

Poly seemingly doesn't like later versions.
Thanks. I did not noticed the difference! I haven't yet be on the new version manual! I must check it next time.
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
Contact:

Re: Why there is no trim/trimright(/trimleft() functions in

08 May 2014, 12:57

I prefer to use the CHM help file that is included in the installation.
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: Why there is no trim/trimright(/trimleft() functions in

08 May 2014, 13:15

Coco wrote:I prefer to use the CHM help file that is included in the installation.
can CHM help file be downloaded (accessed) separately (independently) without installation?
brandonhotkey
Posts: 113
Joined: 03 Nov 2013, 05:46

AHK help file

08 May 2014, 14:17

Coco wrote:@Guest10, Yes, it's available in the downloads page. Or link: AHK CHM Documentation
Oh, I have found it too on my PC but did not know about it. It could be good, but do you know how to convert the colors of the document? I don't preffer white background which tires eyes, so when it is in document it could be possible to convert it. to eyes friendly colors

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, inseption86, jaka1 and 284 guests