# Question about WaitUntil

I have a such function:

fun := DynamicModule[{from,
to}, {FileNameSetter[Dynamic[from], "Directory",
Appearance -> "from where"],
FileNameSetter[Dynamic[to], "Directory", Appearance -> "to where"]}
WaitUntil[And @@ {ValueQ[from], ValueQ[to]}];
Print[StringJoin[from, to]]]


I mean,When I run the fun,I want to print that folder string after I select that two folder,but why this code cannot work?Any bug in my code?Or how to implement it?

• Re update: probably because: Working with DynamicModule: SetDelayed + OwnValues, not to mention that you are multiplying WaitUntil with Dynamic@Grid. – Kuba Dec 22 '16 at 12:55
• p.s. what about putting a Button to Print instead of using undocumented feature. – Kuba Dec 22 '16 at 13:01
• @Kuba The Print is other something in my real qeustion.And I have tried your Button,it work too,but I want to make this two part in a custom function.Do you think it is feasible?And I should provide all code? – yode Dec 22 '16 at 13:18
• Why do you insist on WaitUntil if you don't know how it works. There are documented ways to control flow. Maybe DialogInput would be apropriate? – Kuba Dec 22 '16 at 13:21
• @Kuba Thanks for your suggestion.As your promption,SystemDialogInput["Directory"] solve my question almost.but I will wait a solution with a WaitUntil in this post. :) – yode Dec 22 '16 at 13:37

## 1 Answer

Any bug in your code? I would say: yes, the bug of using undocumented functions without taking the time to figure what they do. Now I don't know much about WaitUntil, but by reading Simon Woods answer here, I got the idea the following might work:

Clear[done, from, to]
done := And @@ {ValueQ[from], ValueQ[to]}

Dynamic @
Row[
{FileNameSetter[Dynamic[from], "Directory", Appearance -> "from where"],
FileNameSetter[Dynamic[to], "Directory", Appearance -> "to where"]} ]

WaitUntil[done]; Print[from, "  ", to]


And it does. This is what cell group looks like when it is initially evaluated.

And this is what it looks like after both directories have be chosen.

• I mean,I want to make it a module pack,but it don't work still? – yode Dec 22 '16 at 11:32
• @yode. Think about what this shows -- that the two file name setters and the WaitUntil expression all have to be active at the same time. Your code must accomplish that. So that's what you need to concentrate on – m_goldberg Dec 22 '16 at 16:05