Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can I use a dialog to get parameters for a do-file?

    I have a do-file reading and writing into a small group of catalogs. There are several such groups, and I am trying to write a dialog asking which group - so I don't have to edit the do-file for every run. My aim was to start the dialog from inside the do-file, select which group of catalogs should be used, and click OK to make the do-file continue. The dialog commands set a couple of global macros, which are then picked up by the do-file and "translated" into complete paths.
    Now, my dialog itself is working - but I have found no way to make the do-file stop and wait for the dialog commands to run. After loading/displaying the dialog box, the do-file just continues without the input from the dialog, and then the dialog commands pop up later.
    - Is there a way to make the do-file wait, or am I completely on the wrong track? I have noticed that dialogs originally are meant to be inserted into the User menu ...
    - Is there another way of making the do-file ask for input?

  • #2
    Originally posted by Steinar Bjørnæs View Post
    - Is there another way of making the do-file ask for input?
    I've only played with Stata's menu dialogues briefly and so can't say about them, but you can use something like
    Code:
    display in smcl as text "Enter catalogue" _request(answer)
    in a while loop that repeats until a null answer (carriage return only) is entered (control then goes to a continue, break to exit the loop).

    Comment


    • #3
      Dear Steinar,

      yes, you can do a lot with Stata dialogs. An earlier version of ADePT software was implemented as a wizard-type Stata dialog, see e,g, this (outdated) manual:
      http://siteresources.worldbank.org/I...5/ADePT_SP.pdf

      For comparison, the present interface is much more flexible (implemented in C#):
      http://siteresources.worldbank.org/I...c_collated.png

      On your questions:

      1) The trick to do would be to reformulate your program from this pattern:
      do--dlg--do--dlg--do
      to this pattern:
      dlg--do-dlg-do-dlg

      2) Do files may ask for input from the command line, see the (rarely used nowadays) option _request() of the display command as Joseph suggested;
      You can use plugins, plugins are executed modaly
      You can start external programs.


      Best, Sergiy

      Comment


      • #4
        Joseph, I wasn't aware of that option.
        Sergiy, I tried starting my job with the command "db <dialogname>" instead of with "do <dofilename>", and started the do-file as the last command in the dialog. Works perfectly.
        Thank you, both!

        -SteinarB.

        Comment

        Working...
        X