Announcement

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

  • Prompt for values interactively in do file

    Dear Statalist,

    Is there any way to prompt for local variable with pattern i.e. numeric only/alpha only with do file to run particular code on typed value. I have seen _request(var) but it accept any values not patterns and need to move cursor in command window and need to type there.

    I wish to prompt it as a dialog and type value there instead of command window.

    Thanks & best regards,
    Rasool Bux

  • #2
    In Stata either you write code for dialog boxes (which isn't reserved for StataCorp, but few programmers outside StataCorp seem interested) or you allow do files or ado files to accept arguments. The territory in between is sparsely populated.

    I don't understand from your abstract description what you want to do concretely, so find it hard to say more.

    See also https://www.stata.com/statalist/arch.../msg01258.html on the terminology "local variable".

    Comment


    • #3
      You can create dialog boxes, see help dialog programming . However, my guess is that trying to integrate a .do file with a dialog is more trouble than it is worth. It would probably be much more efficient to let the dialog box collect the necessary information at the beginning, and let complete the .do file with that information, and then let it run the .do file.
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Dear Maarten,

        Currently I am doing this as below, But I want to get input by using textbox and store the entered value for further processing. I want to restrict the input as 4 digit numbers only.

        *==== code =====
        di in red "Enter the cluster No (in command window): " _request(ans)
        capture window stopbox rusure `"CLUSTER ENTERED : $ans for processing "'
        if _rc == 0 {
        di "you entered : $ans"
        }
        *=== end ====

        Please suggest.
        Rasool Bux

        Comment

        Working...
        X