Statalist


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

Re: st: Stata 9 dialog problem with .iseq()


From   [email protected] (James Hassell, StataCorp)
To   [email protected]
Subject   Re: st: Stata 9 dialog problem with .iseq()
Date   Thu, 30 Aug 2007 17:24:33 -0500

Sergiy Radyakin <[email protected]> has found a bug in the 
dialog system in Stata 9. The bug occurs when comparing a string 
control with a string literal using iseq(). The problem is triggered
if the string literal contains a (.) dot.  

This bug has already been fixed in Stata 10, however Sergiy will need
to code around this in Stata 9.  He will be able to do this by using 
the _values_ list that can be associated with comboboxes, and then
compare a string without the problematic dot. I have included a modified 
version of Sergiy's code below.


/*                test_combo.dlg (MODIFIED)         */

VERSION 9
SYNCHRONOUS_ONLY
POSITION 300 100 300 100

DIALOG main, label("Stata 9 combobox problem")
BEGIN
	COMBOBOX   cb1 30 10 100 ., 				///
	contents(ls_combovalues) 				///
	values(ls_combovalues2) 				///
	onselchange("program combo_changed") dropdownlist
END

LIST  ls_combovalues
BEGIN
	"First"
	"Second"
	"Third"
	"Other..."
END
LIST ls_combovalues2
BEGIN
	"First"
	"Second"
	"Third"
	"other"
END

SCRIPT PREINIT
BEGIN
	create BOOLEAN AfterInit
END

SCRIPT POSTINIT
BEGIN
	AfterInit.settrue
END

PROGRAM combo_changed
BEGIN
	if AfterInit {
		if main.cb1.iseq("other") {
			/// put out Other... as a literal
			put `"di as result "' 
			put `"""' "Other..." `"""'
			stata hidden

			stopbox note "We are OK"
		}
	    	if ! main.cb1.iseq("other") {
			put `"di as result ""' main.cb1 `"""'
			stata hidden
		}
	}
END

// -- EOF(test_combo.dlg) --


--James Hassell, StataCorp


> I am experiencing a problem with how the strings are handled in the
> dialogs (Stata 9). The attached code makes the problem apparent.
> 
> To reproduce the problem:
> 
> 1. save the file into test_combo.dlg
> 2. db test_combo
> 3. When any item is selected, its name appears in the Stata results window
> 4. When "Other" is selected, a message will pop-up "We are OK"
> 5. Now replace "Other" with "Other...". Notice that it must be changed 2 times.
> 6. discard
> 7. db test_combo
> 8. When any item is selected, its name appears in the Stata results window
> 9. When "Other" is selected,  the message DOES NOT pop-up.

> The problem relates to using points in the values. I want to notify a
> user that a new dialog window will open if a particular value is
> selected among the choices (which is conventionally done by placing
> "..." after it).
> 
> Is there any quick fix to it?


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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