Page 1 of 1

Until fails with directory recursion

Posted: 14 Jan 2024, 12:18
by mikeyww
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.

Re: Until fails with directory recursion

Posted: 14 Jan 2024, 12:34
by RussF
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

Re: Until fails with directory recursion

Posted: 14 Jan 2024, 13:15
by mikeyww
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.

Re: Until fails with directory recursion

Posted: 15 Jan 2024, 06:31
by RussF
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

Re: Until fails with directory recursion

Posted: 15 Jan 2024, 06:57
by thqby
until expression, the loop stops only when the expression evaluates to true. But done is always false.

Re: Until fails with directory recursion

Posted: 15 Jan 2024, 07:08
by RussF
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

Re: Until fails with directory recursion

Posted: 15 Jan 2024, 07:30
by mikeyww
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.

Re: Until fails with directory recursion

Posted: 15 Jan 2024, 09:21
by lmstearn
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'

Re: Until fails with directory recursion

Posted: 15 Jan 2024, 09:51
by thqby
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;

Re: Until fails with directory recursion  Topic is solved

Posted: 22 Mar 2024, 19:43
by lexikos
Fixed by v2.0.12.