Setting the Allowed Characters for a Boolean Field

If you do not want to use the system's default Boolean characters for an individual field, you can set the allowed Boolean characters for that field. This can be done using the Designer or in code. If you do not set the allowed Boolean characters for a field, either in the Designer or by using sf_boolch(), the system defaults are used.

Designer: See the Designer User's Guide for more information. You can also modify the Boolean characters used for a Boolean field by calling sf_boolch() in your code, at any point after you have read the form from the Designer library.

Code: To do this in your code, call the set field Boolean character function, sf_boolch():

void sf_boolch(yes_ch, no_ch, dfldp)

UCHAR yes_ch;    /* Character to accept for "yes" value        */

UCHAR no_ch;    /* Character to accept for "no" value        */

DFIELDPTR dfldp;    /* Field to set Boolean characters for        */

As with all Boolean fields, you must initialize the underlying data variable. If you change the Boolean characters, initialize the data variable to one of the new characters (yes_ch or no_ch) or to 1 or 0, depending on how you are planning to use that data variable in your application.

The following code example demonstrates how to create a Boolean field that accepts 'F', 'f', 'M', or 'm' as valid entries:

/* Initialize data variable associated with Boolean field        */

UCHAR choice = 'F';



bool_fldp = fld_def(4, 1, "Gender of applicant? (M/F):", FADJACENT,

        "***A***", F_BOOL, (PTR) &choice, dfmp);

sf_boolch('M', 'F', bool_fldp);

The field will be initially displayed with an 'F' showing at the position of the picture control character. Only this position in the field can be changed by the user. The system validation function will permit the user to enter only 'm', 'f', 'M', or 'F'.


Home Contents Previous Next