To create a Boolean toggle field, you must first create a Boolean field. See Chapter 7, "Standard Data Field Types," to learn how to create a Boolean field.
Designer: You can create a Boolean toggle field using the Designer. (See the Designer User's Guide for more information.) You can also convert a Boolean field to a Boolean toggle field in your code at any point after you have read the form from the Designer library.
Code: Using a pointer to the Boolean field, call the set field to Boolean toggle function, sf_booltoggle():
|
Neither toggle string can be NULLP. Calling sf_booltoggle() with either or both strings NULLP will turn the Boolean toggle option off and free the toggle structure.
Caution: When creating a Boolean toggle field, the Vermont Views system will change the field length so that the longer of the two strings will fit in the field. You should take care that these strings will fit on the form.
The following code fragment creates a Boolean toggle field. Note that the data variable associated with the Boolean toggle field is initialized to 1 (TRUE), which means that the yes string (yes_stp) will be displayed initially in the field.
|
|
|
|
|
|
The attributes specified are only in effect when the cursor is not in the field. When the form is displayed, "Female" will be displayed after the prompt with the video attribute LNORMAL. When the user moves the cursor into the Boolean field, the field is redisplayed with the active field attribute. To change the value of the field, the user presses the Space bar (KEY_SPACE). "Male" would then appear in the field; the attribute would stay the same. After the user moves the cursor out of the field, "Male" would appear with the video attribute LSYS. Pressing Enter (KEY_ENTER) selects the current string displayed in the field.