Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: dialog programming question

From (James Hassell, StataCorp)
Subject   Re: st: dialog programming question
Date   Thu, 22 Jun 2006 15:12:25 -0500

My initial impression was that Michael was trying to get the dialog to show
the correct values when it was first shown, thus PREINIT and POSTINIT would
be the logical choice. However, I see that Michael wants the dialog to
reflect changes that have occurred within Stata due to an ado program that
the dialog box has initiated. This can be done by using the connection between
Stata dialogs and the class system. Appendix B of -help dialog- hints at this
but does not give a lot of detail. Basically the ado program must be aware
of the dialog and through the class system it can update the controls
in the dialog. This is done by using member programs for the various controls.

For example:
/* snippet of a dialog definition saved in xyz.dlg */
DIALOG main, tabtitle("Main")
  EDIT  ed_edit1        10 10 200 ., default(global something)

/* snippet of ado program that changes the dialog */
.xyz_dlg.main.ed_edit1.setvalue $someGlobalMacro

// or alternatively
.xyz_dlg.main.ed_edit1.setvalue `"`someLocalMacro'"'

Notice that the dialog is saved in a file named xyz.dlg and can be manipulated
by the ado program using xyz_dlg.tabName.controlName.memberProgram

Admittedly this is an advanced feature of the dialog programming language
without extensive documentation. I would like to encourage Michael to contact
Stata Technical Support if he has specific questions about their application.

--James Hassell, StataCorp

>> Michael may be able to use a PREINIT or POSTINIT script from within the 
>> dialog
>> to do what he wants. The idea is not to issue a Reset, but to have the
>> dialog initialize itself with the correct values at the appropriate time.
>> For more information on PREINIT and POSTINIT, see -help dialog- and
>> take a look at section 5.6 Special scripts and programs.
>I don't think this will help.  I'm giving the user the option of filling out 
>an edit control with the name of an analysis, defined as a specific group of 
>about 15 different settings that the dialog box allows them to select.  When 
>they type in a named group of settings and click a button control, the 
>dialog launches a program that calls a Stata ado that looks up the 
>associated values for these other settings in a Stata dataset and puts them 
>into global macros to be used as defaults for all of the other controls in 
>the dialog.   This all works fine in terms of the call to the Stata ado and 
>the loading of the values into global macros.
>The problem is that the values shown in the dialog controls do not change 
>until the user clicks the reset button.  I just really need the ability to 
>refresh the dialog box somehow.  I can't see how the PREINIT or POSTINIT can 
>help.  I was hoping there was a function I could call.  I was thinking of 
>trying to disable and then re-enable controls to see if that makes them 
>update the default value.  Maybe I could have the dialog box close itself 
>down and then re-launch itself?  Any other ideas?

*   For searches and help try:

© Copyright 1996–2022 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index