Skip to content

Custom function registered to DWScript and support nested parameters and nested eval? #19

@wqmeng

Description

@wqmeng

Hello,

I have try to add my custom functions such as Func_A, Func_B and Func_C to DWScript and use them in a Script. By adding TdwsFunction, It seems not work well with nested paramters eval.

          LFunc := Self.dwsUnit.Functions.Add;
          LFunc.Name := 'Func_A';
          LFunc.Overloaded := true;
          LFunc.ResultType := 'Integer';
          LFunc.OnEval := dwsUnitFunctions_Func_A_Eval;   //
          LFunc.Parameters.Add('P1', 'String');
          LFunc.Parameters.Add('P2', 'String');
          LFunc.Parameters.Add('P3', 'Integer');

If the above function Func_A, I would like to call it in script as Func_A(Func_B, Func_C, 10); And even more nested as FuncA(Func_B + Func_C, 'Hello', .... , Seems that the parameter could not pass in as a Expression but a 'String'.

Should I use TFuncSymbol and assign a implmentation of the IExecutable to support the nest eval, or Should I use Something from dwsExprs such as TExprBase to support nested eval in my custom functions Func_A, ...?

Do you have a example to achieve it?

Thank you very much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions