dc_tobool()

Converts a string in a field to a Boolean variable

Call
#include <vv_bool.h>
int dc_tobool(stp, datap, dfldp, cvbufp)

UCHAR *stp

Pointer to string with user's field input

PTR datap Pointer to variable to receive converted field input
DFIELDPTR dfldp Pointer to a data field structure
PTR cvbufp Pointer to a data conversion buffer
Returns  
1 Success. This is the only return value for this function
Description

If the field is not a toggle field, the character in the string buffer is converted to its lowercase value and compared to the lowercase value of the allowed Boolean characters for the field. If the character in the string buffer equals the boolyes_ch, the string represents a TRUE value. Otherwise, the string represents a FALSE value.

If the field is a toggle field, the current value of the specified string is compared to the Boolean yes string in the toggle structure. If they are the same, the string represents a TRUE value. Otherwise, the string represents a FALSE value.

The value that is placed into the data variable is dependent upon the original contents of the field data variable. If the original value of the field data variable was either TRUE or FALSE, then TRUE or FALSE is placed in the variable, as appropriate. If the field data variable was originally some other value, or the field has no data variable associated, then the character entered in the field is placed into the data variable.

The system default for the allowed Boolean characters for a Boolean field are 'y' and 'n'. You can change the default allowed Boolean characters with se_boolch(). (se_boolch() does not change the valid response characters for the Vermont Views system prompts; use se_responsech() for this.) To change the allowed Boolean characters for a particular field, use sf_boolch().

Related Functions

dc_frbool(), se_boolch(), sf_boolch(), vf_bool()

Cautions

dc_tobool() expects a valid, allowed Boolean character in the field; therefore, no error checking is performed on the input string. dc_tobool() assumes that vf_bool() has already validated the string.


Home Contents Previous Next