<< Prev        Next >>

ID : 1882

Radio Button

A group (described below) of these parts provides a set of mutually exclusive settings.

These parts have ON/OFF properties (.state) and CLICKED, RELEASED event similar to those for lamps and check boxes.

Radio Button Example

1

The following example uses radio buttons for three mutually exclusive settings.

Load the editor and place a group with three radio buttons on the panel layout.

2

Set the property group for all radio buttons to the group number for the group to ensure mutually exclusive operation of the radio buttons within the group. This example uses group number 0.

3 Adding Action Source Code

This part has CLICKED and RELEASED events similar to those for buttons.

4 Changing Radio Button Properties

Radio buttons have properties similar to those for buttons and labels.

This example shows how pressing a button (PB1) on the same screen can update both the corresponding output (IO[24] to IO[26]) and a numerical input box from the corresponding global float variable (F[10] to F[12]) based on the current states of the radio buttons (RB1 to RB3).

Add the button and numerical input box to the panel layout.

5

Open the Source Code Edit window, select PB1 and CLICKED to create the action source code skeleton, and add the following IF statement branching on the radio button properties (.state).

If RB1.state=1 then

Io[24] = 1

NB1.value = F[10]

Elseif RB2.state=1 then

Io[25] = 1

NB1.value = F[11]

Elseif RB3.state=1 then

Io[26] = 1

NB1.value = F[12]

End if

Compile this panel layout, download it to the controller, and test.

ID : 1882

<< Prev        Next >>