Statalist The Stata Listserver

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

st: Dialog programming: (I)what lists can be passed (II)How to put quotes

From   "David Elliott" <>
Subject   st: Dialog programming: (I)what lists can be passed (II)How to put quotes
Date   Fri, 3 Nov 2006 18:11:31 -0400

I am making my first foray into dialog programming and it is a steep
climb up the learning curve.

I basically want a dialog to do the following:

1) if no dataset is open, open a dataset or, if one is open, use it or
open a different one.  I know how to do this with the FILE control and
filter() option

2) subsequently, I want to populate two variable lists to be used in
COMBOBOX dropdownlists.  They should consist of (a) a list filtered to
include only numeric variables and (b) a list of all variables (I
don't want to use the VARLIST control unless I absolutely have to)

I have already figured out that, since Stata must load the file first
to populate the lists, I have to have an intermediate step to open the
file.  Also, since the dialog must wait for that action, I have made

I'd like to populate my lists with:

PROGRAM LOAD_VAR /*Load Measure and Grouper varlists*/
foreach var of varlist * {
	local type : type `var'
	global allvar $allvar `var'
	if inlist("`type'","byte","int","long","float","double") {
		global measlist $measlist `var'

or, alternatively, something like

PROGRAM LOAD_VAR /*Load Measure and Grouper varlists*/
put "quietly ds, not(type string)"
global measlist `r(varlist)' /* would contain all numeric variables */
put "quietly ds"
global allvar `r(varlist)'

I can see that my lists have been created by issuing a post dialog
-mac dir-. Unfortunately, I can't tell if this sort of construct is
allowed for COMBOBOX controls although you appear to be able to pass
global strings to an EDIT control.  So am I trying to micturate to
windward here?  I can see other situations where one might want to
pass lists to a combobox, for example have contents(variable labels)
values(variable list). (I am programming dialogs for non/occasional
users of Stata and am trying to insulate people form cryptic variable
names)  I have had no difficulty programming comboboxes with this type
of construct in other languages so I am surprised I can't seem to do
it here.

Another issue I have been unable to resolve is how to *put* a "quoted
string" onto the rstring.  As a silly example:

PROGRAM command
	put "di "
	put "Goodbye cruel world"

The quotes are stripped so the output command is -di Goodbye cruel
world- rather than -di "Goodbye cruel world"- and attempts at various
quote combinations and attempts to use separate puts with char(34) are
to no avail, nor is any use of escaped characters.

Thanks in advance for any help/insights provided.

David Elliott
*   For searches and help try:

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