ITsCalculationContext.UserData

Syntax

UserData: ITsUserData;

Description

The UserData property returns user data connected to method calculation.

Comments

Custom method data will be available when the function block method is used in the identifier calculation algorithm.

Example

Below is the example of the custom method that can be used in the block of functions of the algorithm for calculating identifiers. The method can be executed in cycles.

Add a link to the Transform system assembly.

Public Function CalcFunction(Paramarray arr: array Of Variant): Variant;
Const BREAK_ITERATION = 10// Possible condition of execution break
Var
    pContext: ITsCalculationContext;
    pUserData: ITsUserData;
    CurrentIteration: Integer;
    MaxIteration: Integer = -1;
Begin
    // Calculation method context and custom data
    pContext := TsCalculation.Current;
    pUserData := pContext.UserData;
    // Check execution conditions
    If pUserData.Contains("CURRENT_ITERATION"Then
        CurrentIteration := pUserData.Data("CURRENT_ITERATION"As Integer;
        Debug.Write("cyclic calculation. ");
        Debug.Write("Iteration: " + CurrentIteration.ToString);
        If pUserData.Contains("MAX_ITERATION"Then
            MaxIteration := pUserData.Data("MAX_ITERATION"As Integer;
            Debug.WriteLine(" from " + MaxIteration.ToString);
        End If;
        If CurrentIteration = 1 Then
            Debug.WriteLine("Interval between iterations: " + (pUserData.Data("ITERATION_INTERVAL"As Integer).ToString + " seconds");
        End If;
        If CurrentIteration = BREAK_ITERATION Then
            pUserData.Data("BREAK_CYCLE") := True;
            Debug.WriteLine("Exit from cycle condition terminated.");
        Elseif CurrentIteration = MaxIteration Then
            pUserData.Data("BREAK_CYCLE") := True;
            Debug.WriteLine("The maximum iteration is reached.");
        Else
            pUserData.Data("BREAK_CYCLE") := False;
        End If;
    End If;
    Return Null;
End Function CalcFunction;

After executing the method, availability of user data is checked and user data is read. Depending on the values of the read parameter values, the method continues to run or terminates.

See also:

ITsCalculationContext