Toggle box state

Posted by Ab Himmit on 25-Jul-2016 08:19

How and where to set the checked state of a toggle box before the screen is displayed?

Thanks,

Ab

All Replies

Posted by Matt Gilarde on 25-Jul-2016 08:43

Set the value of the variable to YES before displaying it. If this doesn't help, please provide a short example showing what you're trying to do so we can see where the problem might be.

DEFINE VARIABLE a AS LOGICAL VIEW-AS TOGGLE-BOX NO-UNDO.
DEFINE FRAME f
    a
    WITH THREE-D SIDE-LABELS.

a = YES.

UPDATE a WITH FRAME f. /* UPDATE does DISPLAY, ENABLE, and WAIT-FOR */

Posted by Ab Himmit on 25-Jul-2016 08:49

I have a toggle-box on the screen with initial value of "no".

I have this code in the main block;

ASSIGN chb_addrtype:CHECKED IN FRAME {&FRAME-NAME} = TRUE.

But when the screen is displayed, the toggle-box is still un-checked. Do you know of a reason?

Thanks,

Posted by Matt Gilarde on 25-Jul-2016 08:56

Setting the CHECKED attribute doesn't change the value of chb_addrtype. The DISPLAY statement will set the state of the toggle-box based on the current value of the variable.

Posted by Ab Himmit on 25-Jul-2016 09:01

New to programming in progress. Do you have an example please?

And is the place to change the state of this toggle-box the main-block? I mean before the screen is shown.

Thanks,

Posted by ecsousa on 25-Jul-2016 09:01

You need to set the value of the variable, not the property checked.

The display statement displays the data on the screen...if the value of your variable is false, it will be displayed unchecked.

Posted by ecsousa on 25-Jul-2016 09:02

DEFINE Variable chb_addrtype AS LOGICAL VIEW-AS TOGGLE-BOX NO-UNDO.

DEFINE FRAME f

   chb_addrtype

   WITH THREE-D SIDE-LABELS.

ASSIGN chb_addrtype = Yes.

Display chb_addrtype With Frame f.

Wait-for Close Of This-procedure.

Posted by Ab Himmit on 25-Jul-2016 09:07

Why should I define the variable & the frame. I already have designed the screen with it's components.

All I want is to change the state of the toggle-box before the screen is displayed when the program is run.

Posted by Matt Gilarde on 25-Jul-2016 09:11

Setting chb_addrtype = TRUE before the screen is displayed will display the toggle-box with a check. You can do this in the main block of your program.

Posted by Ab Himmit on 25-Jul-2016 09:18

That is exactly what I'm doing, but the toggle-box does not appear to be checked when the screen is displayed.

What could be the cause?

Posted by Matt Gilarde on 25-Jul-2016 09:20

Could you attach your code so we can see it?

Posted by ecsousa on 25-Jul-2016 09:22

You have to use:

ASSIGN chb_addrtype = true.

Not  this:

ASSIGN chb_addrtype:CHECKED IN FRAME {&FRAME-NAME} = TRUE.

Posted by Ab Himmit on 25-Jul-2016 09:29

Thanks My Dear,

That worked fine. No where on the internet or documentation I could find this simple example.

This thread is closed