Radio Buttons

LANSA for i

Radio Buttons

A choice with text beside it. Radio buttons are combined to show a user a fixed set of choices from which only one can be selected.

  • It must be an alphanumeric field of length 1.
  • Radio buttons are defined through the RBnn input/output attribute, where nn = 01 to 99. The nn refers to the group that the radio button belongs to. The maximum number of radio buttons that may be defined for a function is 999.
  • Identification must be either label (*LABEL) or no identification (*NOID). Label is the default.
  • Within RDML the valid values for a radio button field are "1" for selected and " " for unselected. Use of other values may produce unpredictable results.
  • When on a NPT screen a radio button is selected with a "/" or country-designated character (defined in the DC@OSVEROP *SELECTCHAR=x option) and unselected with a " ". This character is locked in at compile time for the best performance when executing.
  • LANSA generated code handles the conversion between screen and RDML values for radio buttons (i.e. from "/" to "1" when selected).
  • There are certain restrictions enforced when using and initializing radio buttons. One and only one radio button per group MUST be selected, or unpredictable results may occur.
  • A new system value named *RADBUTTONSELECTED has been created to be used when testing the return value of a radio button field. Use of this system variable makes your RDML code "self-documenting".
  • A radio button may only contain one of two values. Therefore the best way to test its value is to check if it is *EQ (equal) or *NE (not equal) to the selected value (*RADBUTTONSELECTED).
  • To test if a radio button has been selected:

BEGIN_LOOP

  REQUEST    FIELDS(#SCREEN)

      IF         COND('#RADIO01 *EQ *RADBUTTONSELECTED')

  MESSAGE    MSGTXT('Radio button 1 is selected')

      ENDIF

      IF         COND('#RADIO02 *NE *RADBUTTONSELECTED')

  MESSAGE    MSGTXT('Radio Button 2 is not selected')

      ENDIF

END_LOOP

 

  • The correct way to initialize radio button:

    CHANGE     FIELD(#RADIO1 #RADIO2 #RADIO3 

                 #RADIO4) TO(*NULL)

 

        CASE       OF_FIELD(#TAXRATE)

        WHEN       VALUE_IS('= 0')

        CHANGE     FIELD(#RADIO1) TO(*RADBUTTONSELECTED)

        WHEN       VALUE_IS('= 10')

        CHANGE     FIELD(#RADIO2) TO(*RADBUTTONSELECTED)

        WHEN       VALUE_IS('= 20')

        CHANGE     FIELD(#RADIO3) TO(*RADBUTTONSELECTED)

        WHEN       VALUE_IS('= 30')

        CHANGE     FIELD(#RADIO4) TO(*RADBUTTONSELECTED)

        ENDCASE