When manually running an Event Code, data may be passed to it for operation. For example, a Function control called funcFoo has the following Event Code:
? First argument is [arg0] and the second is [arg1]
When funcFoo is manually ran with .run, parameters may be passed to be used by the Event Code:
!funcFoo.run 10,20
The first value is parsed into arg0, the second into arg1 and so on such that in the Debug/CLI it would show: First argument is 10 and the second is 20
This concept may be combined with creating your own event code triggers, such as the following for funcFoo's Event Code: <avg> ? { ([arg0] + [arg1]) /2 } <diff> ? { [arg1] - [arg0] }
Each may be called and passed data for operation: !funcFoo.run <add>,10,20 !funcFoo.run <diff>,10,20
Returning Results to Calling Code
There is no direct way to return the results of a called event to the caller, but it can be done through the use of variables or accessing a property of the control.
The Function Control can be set to the result then accessed by calling code (the result is also shown on the control): <avg> !this={ ([arg0] + [arg1]) /2 } <diff> !this= { [arg1] - [arg0] }
To access the result, call it passing data, then request the resulting value: !funcFoo.run <add>,10,20 ? [funcFoo]
All interfaces and controls have a property called user which may be used to hold any data desired such as the result of an operation. The following example code can be used by any control or interface to set the user property then access it: <avg> !this.user={ ([arg0] + [arg1]) /2 } <diff> !this.user={ [arg1] - [arg0] }
Call and access result: !controlName <avg>,10,20 ? [controlName.user]
|