LTrim? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
aliztori
Posts: 119
Joined: 19 Jul 2022, 12:44

LTrim?

Post by aliztori » 26 Nov 2022, 07:03

How can i wrtie a comment in this method of assign

Code: Select all

array:=
(LTrim Join
	[
		"var1",
		"var2",
		"var3",
		"var4"
	]
)
this to this :

Code: Select all

array:=
(LTrim Join
	[
		"var1",  ;comment
		"var2",  ;comment
		"var3",  ;comment
		"var4"   ;comment
	]
)
that errored

User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: LTrim?

Post by mikeyww » 26 Nov 2022, 07:19

Code: Select all

array =
( LTrim Join C
	[
		"var1",  ;comment
		"var2",  ;comment
		"var3",  ;comment
		"var4"   ;comment
	]
)
MsgBox, %array%
Explained: Splitting a Long Line into a Series of Shorter Ones, Method #2

sofista
Posts: 650
Joined: 24 Feb 2020, 13:59
Location: Buenos Aires

Re: LTrim?  Topic is solved

Post by sofista » 26 Nov 2022, 07:22

Add option Comments (or Comment or Com or C) to the right of the section's opening parenthesis (ref.: Auto-execute Section):

Code: Select all

array:=
(LTrim Join C
	[
		"var1",  ;comment
		"var2",  ;comment
		"var3",  ;comment
		"var4"   ;comment
	]
)

For k, v in array
	MsgBox, % v

User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: LTrim?

Post by mikeyww » 26 Nov 2022, 07:24

sofista script is better. Mine is just a string!

sofista
Posts: 650
Joined: 24 Feb 2020, 13:59
Location: Buenos Aires

Re: LTrim?

Post by sofista » 26 Nov 2022, 07:42

mikeyww : Nope, my script is just longer than yours, not better :)

User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: LTrim?

Post by mikeyww » 26 Nov 2022, 07:53

Thanks!

For aliztori: compare = to :=. Use the latter to create an array!

:)

garry
Posts: 3768
Joined: 22 Dec 2013, 12:50

Re: LTrim?

Post by garry » 26 Nov 2022, 10:57

also a short example

Code: Select all

#warn
e1:=""
array1:=
(LTrim Join C
	[
		"var1",  ;comment
		"var2",  ;comment
		"var3",  ;comment
		"var4"   ;comment
	]
)
For k, v in array1
   e1 .= v . "`r`n"
MsgBox,%e1%
e1:=""

var:="
(LTrim Join`r`n C
var1  ;comment
var2  ;comment
var3  ;comment
var4  ;comment
"
)
msgbox,%var%
var:=""
return

Post Reply

Return to “Ask for Help (v1)”