String Intrinsic Functions - AsBoolean Method

Return a string as a Boolean

Member of String Intrinsic Functions (PRIM_LIBI.IStringIntrinsics)

Parameters

Name Type Data Type Description
Result *Result (Optional) Boolean Resulting Boolean
FalseCaption *Input (Optional) String Value to use as the false value
TrueCaption *Input (Optional) String Value to use as the true value

Details

AsBoolean converts a variable to a Boolean. By default, AsBoolean expects to receive a true or false string. Any other value will result in a runtime error. Optionally, you can override the defaults and specify the true and false values to be evaluated using the TrueCaption and FalseCaption parameters.

Example

In this example, Asboolean expects a string value of Y or N
#Button.enabled := #String.AsBoolean(N Y)
This is equivalent to writing
Case of_Field(#String)
 
When (= Y)
#Button.enabled := True
 
When (= N)
#Button.enabled := False
 
Endcase

See also

All Component Classes

Technical Reference

LANSA Version 15, April 2020