Boolean Fields

The Boolean field is a special character field that simplifies obtaining user answers to questions that have only two possible answers, such as yes/no, true/false, or quit/continue. The user may enter only one of two characters: a case insensitive yes character ('Y' or 'y' by default) or a case insensitive no character ('N' or 'n' by default).

The specifics for using a Boolean field are summarized below:

Field Type F_BOOL
Header File vv_bool.h
Data Variable UCHAR data

You can store Boolean data in one of two ways: as [1, 0] or as [yes_ch, no_ch]. yes_ch and no_ch are the yes and no characters (['y','n'] by default). Vermont Views will process either Boolean set appropriately.

Caution: You must initialize a Boolean field before you process the data form containing that field. Initialize the data variable to 1 or 0 if you want to use the Boolean set [1, 0] in your application code; initialize the data variable to 'y' or 'n' if you want to use the default Boolean character set ['y', 'n'] in your application code. If you initialize the field to either 1 or 'y', 'y' will be displayed initially in the field at the position of the picture control character. If, for example, the user then enters 'N' or 'n' and exits the form, Vermont Views checks to see how the data variable was initialized. If the variable was initialized to 0 or 1, then the contents of the field are converted to 0 and stored in the data variable. If the variable was initialized to 'y' or 'n', then the contents of the field are converted to 'n' and stored in the data variable.

Picture Control The control characters X, A, Z, *, and ! are allowed in Boolean fields. You can have as many protected characters as you desire in Boolean fields, but there must be only one picture control character.
Code Example /* Initialize variable associated with Boolean field*/
UCHAR choice = 1;

bool_fldp = fld_def(4, 1, "Continue? (Y/N): ", FADJACENT,
"A", F_BOOL, (PTR) &choice, dfmp);

The field will be initially displayed with a 'Y' 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 'y', 'Y', 'n', or 'N'.

   
   
   
   
   

More:

Setting the Default Allowed Characters for All Boolean Fields

Setting the Allowed Characters for a Boolean Field


Home Contents Previous Next