COLLECTION Example


Example:

 

*

 

 

.Define the Collection Objects

.

 

 

BUTTON1

BUTTON

 

BUTTON2

BUTTON

 

CB1

CHECKBOX

 

RADIO1

RADIO

 

*

 

 

.Define the Collection

.

 

 

COLL1

COLLECTION

 

*

 

 

.Define the Program Control Buttons

.

 

 

QUIT

BUTTON

 

ENABLE

BUTTON

 

DISABLE

BUTTON

 

*

 

 

.Other Program Variables

.

 

 

GB

GROUPBOX

 

RESULT

INTEGER

1

*

 

 

.Create a Groupbox Containing Some Objects

.

 

 

  

CREATE

GB=2:13:8:30,STYLE=1

  

CREATE

BUTTON1=3:4:10:20,"Button 1"

  

CREATE

BUTTON2=6:7:10:20,"Button 2"

  

CREATE

CB1=9:10:10:20,"Checkbox"

  

CREATE

RADIO1=11:12:10:25,"Radio Button"

*

 

 

.Place the Objects into the Collection

.

 

 

  

LISTINS

COLL1,GB,BUTTON1,BUTTON2,CB1,RADIO1

*

 

 

.Create the Program Control Buttons

.

 

 

  

CREATE

ENABLE=4:5:40:55,"Enable Objects",ENABLED=0

  

CREATE

DISABLE=7:8:40:55,"Disable Objects"

  

CREATE

QUIT=11:12:40:55,"Quit"

*

 

 

.Activate the Objects in the Collection

.

 

 

  

ACTIVATE

COLL1

*

 

 

.Activate the Control Buttons

.

 

 

  

ACTIVATE

QUIT,QUITR,RESULT

  

ACTIVATE

ENABLE,ENABLER,RESULT

  

ACTIVATE

DISABLE,DISABLER,RESULT

*

 

 

.Wait for an Event to Occur

.

 

 

  

LOOP

 

  

WAITEVENT

 

  

REPEAT

 

*

 

 

.Enable Button Clicked - Enable the Entire Collection

.

 

 

ENABLER

 

 

  

SETPROP

COLL1,ENABLED=1

.

 

 

  

SETPROP

ENABLE,ENABLED=0

  

SETPROP

DISABLE,ENABLED=1

.

 

 

  

RETURN

 

*

 

 

.Disable Button Clicked - Disable the Entire Collection

.

 

 

DISABLER

 

 

  

SETPROP

COLL1,ENABLED=0

.

 

 

  

SETPROP

ENABLE,ENABLED=1

  

SETPROP

DISABLE,ENABLED=0

.

 

 

  

RETURN

 

*

 

 

.Quit Button Clicked - Terminate

.

 

 

QUITR

 

 

  

STOP

 

 

This example creates two buttons, a checkbox and a radio control within a GROUPBOX. These objects are then inserted into a COLLECTION using the LISTINS verb. This allows the ACTIVATE and SETPROP instructions to access all four objects as a group (COLL1) using a single statement. The control buttons illustrate this capability by collectively enabling or disabling the objects.

 

 



PL/B Language Reference CMOVE Examples COMOPEN Examples