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?

  • $\begingroup$ Re update: probably because: Working with DynamicModule: SetDelayed + OwnValues, not to mention that you are multiplying WaitUntil with Dynamic@Grid. $\endgroup$
    – Kuba
    Dec 22, 2016 at 12:55
  • $\begingroup$ p.s. what about putting a Button to Print instead of using undocumented feature. $\endgroup$
    – Kuba
    Dec 22, 2016 at 13:01
  • $\begingroup$ @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? $\endgroup$
    – yode
    Dec 22, 2016 at 13:18
  • $\begingroup$ 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? $\endgroup$
    – Kuba
    Dec 22, 2016 at 13:21
  • $\begingroup$ @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. :) $\endgroup$
    – yode
    Dec 22, 2016 at 13:37

1 Answer 1


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 @
    {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.


  • $\begingroup$ I mean,I want to make it a module pack,but it don't work still? $\endgroup$
    – yode
    Dec 22, 2016 at 11:32
  • $\begingroup$ @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 $\endgroup$
    – m_goldberg
    Dec 22, 2016 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.