Converting Numeric Values to Boolean values:
One way of testing if a number is a specific value is to execute the following code:
The result from executing the above code is vBoolean will equal True. A simpler way of testing the value of a number is:
The result from executing the above code is vBoolean will also equal True.
Converting Boolean Values to Numeric Values:
There is also a simple way of converting Boolean values to numbers using the Num function:
In this case Num(vBoolean) will return 1. And conversely if vBoolean is False, Num(vBoolean) will return 0.
Using a conversion in your database.
When 4D displays a Boolean value, it displays it as a checkbox. It takes more time to draw a picture, such as a checkbox, to the screen than text. A List Form which contains Boolean fields will draw faster when they are displayed as text instead of as checkboxes. The steps to do this are:
- Create a numeric variable, on the form, to display the format text.
- Create some code that converts the data. If this is for a List Form, it is best to limit when this code will be executed such as the On Display Detail form event. Such as:
`Object Method: vDisplayGender
If (Form event=On DIsplay Detail)
- Give the variable a format such as: Female;;Male
The result will be if the field has a value of True, it will display the word "Female" and when the value is False it will display the word "Male".