Button linked field

field = field_id

This clause may be used to specify a field that is linked to a multi button (radio or checkbox type). It may be set at group level or at button level. Whilst it is possible to set a field at both button and group level it is more logical to use one or the other.

If a multi button group has linked field(s), the display command refers to them in order to determine the multi button’s state.

Linked fields are updated at run time as the user checks and unchecks buttons. For a field defined at group level the value of the field is determined by which button(s) are checked. For fields defined at button level the default unchecked value is zero, and the default checked value non-zero. Other values may be specified by means of the checked_value and unchecked_value clauses.

The field_id may be the name of a field from a Sculptor file declared in the program, a temporary field, declared within the program by means of the !temp or !record declarations, or a Sculptor system variable. It is recommended that the name is qualified (e.g. tmp.field_id). The field will normally be an integer type.

The same field may be linked to more than one button.

If the linked field is assigned to a group rather than to an individual button, the field must be an integer type. The value of a button within the group is determined from the field as follows:

Radio buttons: the field contains the number of the currently checked button. Buttons are numbered in order of their definition in the group, starting from 1.

Checkbox buttons: bits are set corresponding with the checked buttons. These may be tested as follows:

!temp CheckField,,i2
     ...

     checkbox group CheckGrp {
          field = CheckField
          ...
     }

     if (CheckField & 0x01) then info "First button checked"
     if (CheckField & 0x02) then info "Second button checked"
     if (CheckField & 0x04) then info "Third button checked"
     if (CheckField & 0x08) then info "Fourth button checked"
     if (CheckField & 0x10) then info "Fifth button checked"

The checked clause may also be used to change or retrieve a button’s state at run time.


EXAMPLE

+button Tooltips at 667,152 {
     label = "Tooltips"
     field = tmpConfig.Tooltips
     style = WS_LJT
     tooltip = "Check this box to include tooltips"
     checked_value = "1"
     unchecked_value = "0"
}

EXAMPLE define a radio group as shown

radio group RadioTest {

    field = grp_field

    +button Button1 at 78,59 {
        label = "B1"
    }

    +button Button2 at 79,101 {
        label = "B2"
    }
}


... later we then execute the follwing code, grp_field will have the value 2
... and Button 2 will be checked.

Button2->checked = TRUE
display RadioTest

RELATED TOPICS

Buttons

Button value clauses