Xbasic

ON_CONDITION Function

Syntax

V ON_CONDITION(C expression,C code)

Arguments

expressionCharacter

An Xbasic expression that resolves to either .T. (TRUE) or .F. (FALSE).

codeCharacter

The name of an Xbasic script or function to run.

Description

Run code (once) when condition is met.

Discussion

The ON_CONDITION() function registers some Code to be executed when a Logical_Expression is true. When the Logical_Expression is true, the Code is executed. After the code is executed, the ON_CONDITION() event is de-registered, so that the next time the Logical_Expression is true, the code no longer executed. You can register as many ON_CONDITION() events as you want. Generally, the ON_CONDITION() events will impose very little overhead on Alpha Anywhere. However, if your Logical_Expression is complex, and/or involves User Defined Functions, it is possible that the ON_CONDITION() events will represent a drain on performance.

It is important to recognize that when the condition is true the code executes, and then the condition is cleared. If you want something to happen every time a condition is met, then you must rerun the ON_CONDITION() command after the condition is met.

Example

The following example displays a message box the first time that the firstname field on the Customer_Information form gets focus:

Code = <<%code%
ui_msg_box("Notice", "Firstname is selected.")
%code%
on_condition("Customer_information.active() = 'firstname'", code)

See Also