CREATE RADIO Examples


Example 1:

 

*

 

 

.Define the RADIO BUTTONs, COLORs,

. BUTTON, and other variables

.

 

 

RADIOS

RADIO

(3)

COLORS

COLOR

(3)

BUTTON1

BUTTON

 

RESULT

FORM

2

RBVAL

FORM

1(3)

*

 

 

.Create the Objects

.

 

 

  

CREATE

COLORS(1)=*RED

  

CREATE

COLORS(2)=*BLUE

  

CREATE

COLORS(3)=*GREEN

.

 

 

  

CREATE

RADIOS(1)=3:4:30:50,"Red":

  

  

FGCOLOR=COLORS(1)

  

CREATE

RADIOS(2)=5:6:30:50,"Blue":

  

  

FGCOLOR=COLORS(2)

  

CREATE

RADIOS(3)=7:8:30:50,"Green":

  

  

FGCOLOR=COLORS(3)

.

 

 

  

CREATE

BUTTON1=16:17:35:42,"Exit"

*

 

 

.Set the Blue Button On

.

 

 

  

SETITEM

RADIOS(2),0,1

*

 

 

.Activate the Objects

.

 

 

  

ACTIVATE

RADIOS Perform Default Action

.

 

 

  

ACTIVATE

BUTTON1,EXIT,RESULT

*

 

 

.Wait for an Event to Occur

.

 

 

  

LOOP

 

  

  EVENTWAIT

 

  

REPEAT

 

*

 

 

.Exit Button Selected - Retrieve and Display

. the Values of the Radio Buttons

.

 

 

EXIT

 

 

  

GETITEM

RADIOS(1),0,RBVAL(1)

  

GETITEM

RADIOS(2),0,RBVAL(2)

  

GETITEM

RADIOS(3),0,RBVAL(3)

.

 

 

  

DISPLAY

*P10:10,"Value of the RADIO ":

  

  

"objects upon exit: ",RBVAL(1):

  

  

", ",RBVAL(2),", ",RBVAL(3),*W3;

  

STOP

 

 

This example creates three (3) RADIO buttons on the screen. The second button is initialized to an 'On' state (value of 1). During program execution, the buttons may be clicked to change selections. Since no activation routine is specified with the radio button objects, the default action of changing the buttons' states is performed. When the Exit BUTTON is clicked, the value of each RADIO button is displayed and the program terminates.

 

Example 2:

 

*

 

 

.Define the RADIO button, BUTTON and other variables

.

 

 

RADIO1

RADIO

 

BUTTON1

BUTTON

 

RESULT

INTEGER

1

VALUE

FORM

1

*

 

 

.Create the Objects

.

 

 

  

CREATE

RADIO1=3:4:35:50,"Click Me!"

  

CREATE

BUTTON1=6:7:35:42,"Exit"

*

 

 

.Activate the Objects

.

 

 

  

ACTIVATE

RADIO1,ROUTINE,RESULT

  

ACTIVATE

BUTTON1,EXIT,RESULT

*

 

 

.Wait for an Event to Occur

.

 

 

  

LOOP

 

  

  EVENTWAIT

 

  

REPEAT

 

*

 

 

.Radio Button Clicked

.

 

 

ROUTINE

 

 

  

ALERT

NOTE,"Radio Button Clicked!",RESULT

.

 

 

  

GETITEM

RADIO1,0,RESULT // Get the Current State

  

XOR

0x1,RESULT // Toggle it

  

SETITEM

RADIO1,0,RESULT // Update the object

  

RETURN

 

*

 

 

.Exit Button Selected - Retrieve and

.Display the Value of the Radio Button

.

 

 

EXIT

 

 

  

GETITEM

RADIO1,0,VALUE

  

DISPLAY

*P10:10,"Value of the RADIO ":

  

  

  "object upon exit: ",VALUE,*W3;

  

STOP

 

 

This example creates a RADIO button and command BUTTON on the screen. During activation of the RADIO button, a user-defined routine is provided. The user provided routine simply reports that the button has been clicked using an ALERT box and changes the state of the RADIO object. Note that no automatic changing of the RADIO button state occurs by the runtime since user code was provided during the activation of the object.

 

 



PL/B Language Reference CREATE PROGRESS Example CREATE RADIOGRP Example