Skip to content

LFunc.ResultType:='array of Boolean'; can not used when run script. #22

Description

@wqmeng

Hello,

I add a custom function and register it to DWScript.

  LFunc:=FdwsUnit.Functions.Add;
  LFunc.Name:='Add_Array';
  LFunc.Overloaded := True;
  LFunc.OnEval:=dwsUnitAdd_Array_Eval;
  LFunc.ResultType:='array of Boolean';
  LParam:=LFunc.Parameters.Add;
...

And in the dwsUnitAdd_Array_Eval function, I use the following code to return the result array.

  Res := Info.ResultVars.ScriptDynArray;
  Res.ArrayLength := Count;

  for I := 0 to Count - 1 do
    Res.SetAsBoolean(I, ResultArray[i]);

Then will get error report
Message: Syntax Error: TdwsUnit: "TradeBase" -- TdwsFunction: "Add_Array" -- DataType "array of Boolean" not found

So I'm confused, is the absence of "array of Boolean" a result of design, or is it a bug?

As if I change the result type as 'array of float', that fine, but when use the function BoolToStr(res_array[0]) in script side, it will report except a Bool value but get a Float value, So have to compare to 0
BoolToStr(res_array[0] <> 0), and could get the 'True' or 'Flase' string.

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