Salesforce

Developer Function Runtime Behavior (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

Developer Function Runtime Behavior (Magic xpa 4.x)

A Developer function is evaluated at runtime like built-in functions.

Function syntax is executed in a manner similar to the execution of a synchronous event handler, where:

Generation = 0 in any task-related function refers to the task that evaluates the function. When a function is set in the parent task and evaluated from the child task, any generation-related calculations done by the function relate to the triggering task as the zero generation. Just like with handlers, any task called from a function is regarded as the child task of the task that evaluated the function.

The variable stack for the function begins from the Main Program to the task evaluating the function.

Once a value is set for a variable in a handler/function, it will remain and will not be cleared in other calls to this handler/function.

Passing Arguments

Generally, all arguments are passed as values to the function. When updating a parameter value, there is no reference for the function to pass back the updated value.

You can pass a variable reference that can be handled by various VAR functions, such as VarCurr and VarSet, or VarCurrN and VarIndex.

Returned Value

As the function is executed, the expression of the returned value is evaluated and the expression evaluator receives the value of that expression as the returned value of the function. If the function has no value set as the returned value, the function returns a Null.

A Developer function can be evaluated by using the EvalStr or EvalStrInfo functions.

For example: Let's say you have a function in the main program that increments its parameter by 1 (without returning a value).

You need to call the function sending a reference to the variable using the VAR literal, for example: increment ('G'VAR)

In the function itself, add a Numeric parameter that is the variable index (varindex), and then you can increment the variable value by using: VarSet(varindex, VarCurr (varindex)+1)

Developer Functions and a Triggered Task

If a Developer function is defined for a triggered task that has a handler of an ancestor task triggered from a descendent task, the user-defined task is available for the entire handler execution.

Recursive Function Call

Recursive behavior is when you call the Developer function from another operation defined within the same Developer function. For example, the ABC Developer function has an operation that calls the same Developer function.

Magic xpa does not let a Developer function call a built-in function with the same name.

Related Topics

Reference
Attachment 
Attachment