why was LoopParse (no space) removed?

Discuss the future of the AutoHotkey language
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: why was LoopParse (no space) removed?

07 Jan 2018, 13:56

Internallly, certainly LoopParse would be easier to detect compared to Loop Parse, in the sense that LoopParse doesn't need to be distinguished from Loop [Count] where the count expression starts with a variable named, eg, Parse. These examples are a bit ridiculous ofc, but still, it is not very nice,

Code: Select all

Parse := 2
var := 3
; Interpreted as a parsing loop
Loop Parse + var
	Msgbox "Loop 1:`t" A_index "`t" A_LoopField
; Interpreted as Loop count
Loop Parse+var 
	Msgbox "Loop 2:`t" A_index "`t" A_LoopField

; Load time error - not interpreted as loop count due to variable named 'Parse'
;Loop Parse . var 
;	Msgbox "Loop 3:`t" A_index "`t" A_LoopField

Having no particularly good reasons for allowing a comma here may mean this leads to removing the comma entirely, or maybe not
I prefer it without the comma, for some reason I've become unfond of initial commas :think: :)

Cheers.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: why was LoopParse (no space) removed?

10 Apr 2018, 18:06

- I'm preparing some core function libraries for sharing.
- Is it feasible for Loop Count, for Count to be 'can be an expression' in AHK v1? Or is there some obstacle? I.e. that parameter 1 would be 'can be an expression' when Loop has only 1 parameter. Cf. WinMove which has special handling for when exactly 2 parameters are specified.
- That way virtually all of the loops would be two-way compatible, and I could fix any parsing loops (temporarily, with a comment) to use a for loop with StrSplit for full two-way compatibility.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: why was LoopParse (no space) removed?

11 Apr 2018, 23:08

Count cannot be an expression for the reason noted in the documentation.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: why was LoopParse (no space) removed?

11 Apr 2018, 23:17

- Ah I see, the old-style File loop can also be one-parameter only.
- So I suppose for something like this to happen, it would need a directive. Thanks.

- [EDIT:] Another thing that could be helpful:

Code: Select all

for _, A_LoopField in StrSplit(vText, ",")
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: why was LoopParse (no space) removed?

22 Aug 2018, 14:08

I think this could work. I hope people like it.

Code: Select all

;AHK v2 only:
Loop expression

;AHK v1/v2 two-way compatible:
Loop integer ;e.g. Loop 3
Loop (expression) ;e.g. Loop (obj.Length()) ;must start with '(' and end with ')'
LoopFiles ...
LoopParse ...
LoopParseCSV ...
LoopRead ...
LoopReg ...

==================================================

AHK V1/V2 TWO-WAY COMPATIBLE EXAMPLES

Loop 3
Loop (vCount)
LoopFiles vDir "\*", "FDR"
LoopParse vText, "`n", "`r" ;with StrSplit-style 'Delimiters' parameter
LoopParseCSV vText
LoopRead vPath
LoopReg vRegKey, "VKR"
For 'Loop (expression)', the only plausible AHK v1 loop (count/files/reg), that could clash, would be looking for a dir/extensionless file inside the working dir starting with '(' and ending with ')', and you could use % "(needle)" if needed.

Perhaps the LoopParse 'Delimiters' parameter should be made like StrSplit, for consistency, and to avoid confusion.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 21 guests