Loop Files: accept array for FilePattern

Propose new features and changes
User avatar
jeeswg
Posts: 6378
Joined: 19 Dec 2016, 01:58
Location: UK

Loop Files: accept array for FilePattern

29 Dec 2018, 10:53

- It would be useful to accept a linear array for the FilePattern parameter.
- And perhaps the Mode parameter could accept a linear array also, in which case, the length of both arrays would have to be identical.

Code: Select all

;before:
vList := A_StartMenu "|" A_StartMenuCommon
Loop, Parse, vList, % "|"
{
	vDir1 := A_LoopField
	Loop, Files, % vDir1 "\*", % "FR"
	{
		MsgBox, % A_LoopFileFullPath
	}
}

;after (proposal):
oArray := [A_StartMenu, A_StartMenuCommon]
Loop, Files, % oArray, % "FR"
{
	MsgBox, % A_LoopFileFullPath
}
[EDIT:] Added the word 'proposal'.
Last edited by jeeswg on 12 May 2019, 02:23, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 3704
Joined: 17 Jul 2016, 01:02
Contact:

Re: Loop Files: accept array for FilePattern

30 Dec 2018, 15:36

- It would be useful to accept a linear array for the FilePattern parameter.
I would say slightly more convenient than,

Code: Select all

for k, dir in [A_StartMenu, A_StartMenuCommon]
	Loop, Files, % dir . "\*", % "FR"
		MsgBox % A_LoopFileFullPath
rather than useful.

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

Re: Loop Files: accept array for FilePattern

30 Dec 2018, 15:52

- Thanks, using a for loop neatly allows you to store the folder path, to view it in the variable list.
- One advantage of accepting an array is that you avoid an additional layer of indentation. E.g. the loops could contain layers of indentation, and could be inside layers of indentation/a function/a class. Also, you can avoid using higher-than-necessary numbers e.g. break 3 and continue 3. The additional layers/higher numbers obscure the logic.
- (Also, at present, sometimes you want a double loop within a double loop, which could be simplified to a loop within a loop.)
- (So if you're thinking in your head one layer of indentation, but the code is forcing you to use two layers of indentation, that problem is then avoided.)

- [EDIT:] Omg glad that I'm essentially finished with wish list ideas, forgot what it was like. Only challenge it in a 'serious' way if you legitimately think it's a bad idea, otherwise my imagination goes into immediate overdrive for nothing!
- Anyway, you've been naughty, you've written a long post offering opinions but no new facts, essentially saying it's useful but only somewhat useful, useful enough to be added though?
- (I've been reflecting on how to have peaceful AHK v2 discussions should more ever arise.) HNY Helgef! :P
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 3704
Joined: 17 Jul 2016, 01:02
Contact:

Re: Loop Files: accept array for FilePattern

30 Dec 2018, 16:19

re. break, good points :thumbsup:. Happy new years jeeswg :heart:
seragnn44
Posts: 2
Joined: 07 Mar 2019, 13:11

Re: Loop Files: accept array for FilePattern

07 Mar 2019, 14:17

It might be useful for non experts to have this indicated in the answer as someone may copy paste it and find it not working. A perfect example would be someone who is converting all ".jpg" files to ".png" before carrying out a crucial function

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 6 guests