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

From |
Kevin Crow <kcrow@stata.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: strange behavior of booleanfunctions in dialog if expressions |

Date |
Wed, 02 Apr 2008 17:21:55 -0500 |

Zurab was trying to see if a value passed to an edit box in his dialog was <= 0. The problem is that edit boxes return strings, not numeric values. Zurab will need to convert the value in the edit box to a double to use –isle()- correctly. For example,

VERSION 9

POSITION . . 300 300

SCRIPT PREINIT

BEGIN

create DOUBLE x

END

DIALOG main

BEGIN

EDIT ed_ed1 30 44 170 ., label("input") numonly

BUTTON bt_bt1 30 100 100 ., label ("button") onpush(program action)

END

PROGRAM action

BEGIN

call x.setvalue class main.ed_ed1.value

if x.isle(0) {

stopbox note "true"

exit

}

stopbox note "false"

END

Kevin Crow

--StataCorp

Zurab Sajaia wrote:

Dear all,

I have encountered this problem in both Stata version 9.2 and 10 and not sure whether I'm doing something wrong or it's indeed strange.

The setup is as follows:

I have a (numeric) parameter entered by a user and before executing need to check it's values to be in some range... so something like this example:

VERSION 9

POSITION . . 300 300

DIALOG main

BEGIN

EDIT ed_ed1 30 44 170 ., label("input") numonly

BUTTON bt_bt1 30 100 100 ., label ("button") onpush(program action)

END

PROGRAM action

BEGIN

if main.ed_ed1.isle("0") {

stopbox note "true"

exit

}

stopbox note "false"

END

I have here -isle- function but same happens with -islt-, -isgt-, and -isge- as well. The problem arises with numbers (-1, 1), if I put them with leading 0 (like 0.9 or -0.3) everything looks fine but if I put .9 or -.3 instead then -islt- and -isle- give wrong answer for positive fractions and -isgt- and -isge- make mistakes with negatives.

Does anyone have experienced something similar?

any thoughts would be appreciated.

Zurab

*

* 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/

* * 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/

**References**:**st: strange behavior of booleanfunctions in dialog if expressions***From:*"Zurab Sajaia" <zsajaia@hotmail.com>

- Prev by Date:
**st: Date: Wed, 2 Apr 2008 18:36:19 -0400** - Next by Date:
**RE: st: Likelihood function of uniform distribution** - Previous by thread:
**st: strange behavior of booleanfunctions in dialog if expressions** - Next by thread:
**st: substringing long, varying length text variables into individual variables** - Index(es):

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