Until fails with directory recursion Topic is solved

Report problems with documented functionality
User avatar
mikeyww
Posts: 26972
Joined: 09 Sep 2014, 18:38

Until fails with directory recursion

14 Jan 2024, 12:18

This seems bizarre, but this script does not recurse (i.e., no subdirectories are processed). It does work if the Until statement is removed.

Code: Select all

#Requires AutoHotkey v2.0
done := False
Loop Files 'C:\*.*', 'R'
 MsgBox A_Index '`n' A_LoopFilePath
Until done
MsgBox done, 'Done', 'Iconi'
Version 2.0.11 on Win 11 Pro.
RussF
Posts: 1269
Joined: 05 Aug 2021, 06:36

Re: Until fails with directory recursion

14 Jan 2024, 12:34

Could it be because [docs2]Loop Files[/docs2] and [docs2]Loop (until)[/docs2] are essentially two different statements? I don't see any examples of [docs2]Loop Fils[/docs2] with an Until clause. You could use a code block and Break out of the loop when you set the done flag.

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

Re: Until fails with directory recursion

14 Jan 2024, 13:15

Thank you, Russ.

It is not a syntax error.

Until:
Until can be used with any Loop or For.
I am currently using Break as my solution.
RussF
Posts: 1269
Joined: 05 Aug 2021, 06:36

Re: Until fails with directory recursion

15 Jan 2024, 06:31

Point for you - bad assumption on my part. Since Until is only used by loops, I did not look for more documentation than what existed under "Loop Until". :oops:

Russ
User avatar
thqby
Posts: 408
Joined: 16 Apr 2021, 11:18
Contact:

Re: Until fails with directory recursion

15 Jan 2024, 06:57

until expression, the loop stops only when the expression evaluates to true. But done is always false.
RussF
Posts: 1269
Joined: 05 Aug 2021, 06:36

Re: Until fails with directory recursion

15 Jan 2024, 07:08

thqby wrote:
15 Jan 2024, 06:57
until expression, the loop stops only when the expression evaluates to true. But done is always false.
That was probably intentional, to show that the Loop Files does not work with Until. He should be getting a message box with every file on his hard drive and instead is getting none.

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

Re: Until fails with directory recursion

15 Jan 2024, 07:30

until expression, the loop stops only when the expression evaluates to true. But done is always false.
You seem to be suggesting that the loop should continue to recurse into the subdirectories. I have already written that this does not happen, and that is the problem. You can try it at your end to see whether you experience the same problem. The loop does run for the directory but not any subdirectories.
User avatar
lmstearn
Posts: 695
Joined: 11 Aug 2016, 02:32
Contact:

Re: Until fails with directory recursion

15 Jan 2024, 09:21

it might be handling "Done" as a literal instead, no difference with (Done=True) or (A_Index=5)?
As a matter of interest the following is fine in V1:

Code: Select all

done := False
Loop, Files, C:\*.*, R
MsgBox % A_Index . "`n" . A_LoopFilePath
Until done
MsgBox done, 'Done', 'Iconi'
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
User avatar
thqby
Posts: 408
Joined: 16 Apr 2021, 11:18
Contact:

Re: Until fails with directory recursion

15 Jan 2024, 09:51

It's a bug.

https://github.com/AutoHotkey/AutoHotkey/blob/v2.0/source/script.cpp#L10778

Code: Select all

if (ResultToBOOL(ARG1))
{
  aResult = LOOP_BREAK;
  return true;
}
return false;

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 66 guests