Use EncodeDate, IncMinute in script

Hi,

I'm triying to use EncodeDate, IncMinute and other DateUtils functions on a script but when I check the WorkFlow I get a Unknwon method or routine Error.

Any hints?

Thanks in advance,

Omar Zelaya

You can try to add ap_DateUtils unit to your project, and then use uses DateUtils in your script.

Hi,

I have added ap_DateUtils.pas to the project but I get INTERNAL ERROR Library 'DateUtils' not found.

Any hints?

Thanks in advance,

Omar Zelaya

Sorry, the Workflow Studio scripter is different from the original one. You can use something like this to manually register the IncDay method (and follow the same approach to register the other ones):

procedure TfmMain.__IncDay(AMachine: TatVirtualMachine);
var
  AResult: variant;
begin
  with AMachine do
  begin
    case InputArgCount of
      1:
        AResult := DateUtils.IncDay(GetInputArg(0));
      2:
        AResult := DateUtils.IncDay(GetInputArg(0),
          VarToInteger(GetInputArg(1)));
    end;
    ReturnOutputArg(AResult);
  end;
end;

procedure TfmMain.InitScripter(Sender: TObject);
var
  Scripter: TwfCustomScripter;
begin
  Scripter := TwfCustomScripter(Sender);
  Scripter.DefineMethod('IncDay', 2, tkVariant, nil, __IncDay, false, 1, 'AValue: TDateTime; ANumberOfMinutes: Int64 = 1');
end;

procedure TfmMain.FormCreate(Sender: TObject);
begin
  OnGlobalScripterCreate := InitScripter;
end;