10 6 1 AsBoolean

LANSA Technical

10.6.1 AsBoolean

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

Input Parameters

Falsecaption - Value to be converted to a Boolean state of False

Truecaption - Value to be converted to a Boolean state of True

Example

In this example, AsBoolean expects a string value of true or false:

#Button.enabled := #String.AsBoolean

 

This is equivalent to the following:

Case of_Field(#String)

 

When (= True)

#Button.enabled := True

 

When (= False)

#Button.enabled := False

 

Otherwise

Abort Msgtxt('String value cannot be converted to a Boolean')

 

Endcase

  

In this example, Asboolean expects a string value of Y or N:

#Button.enabled := #String.AsBoolean(N Y)

 

This is equivalent to the following:

Case of_Field(#String)

 

When (= Y)

#Button.enabled := True

 

When (= N)

#Button.enabled := False

 

Otherwise

Abort Msgtxt('String value cannot be converted to a Boolean')

 

Endcase

 

Also see

10.6.26 IsBoolean

Ý 10.6 Alphanumeric/String Intrinsic Functions