IDADataTableScriptingProvider

Overview

The IDADataTableScriptingProvider is used to call a method in a script on the client side.

data table uses it inside its events to call them from the script:

procedure TDADataTable.CallScript(const aEvent: string);
begin
  if Assigned(ScriptingProvider) and (ScriptCode.Count > 0) then begin
    (ScriptingProvider as IDADataTableScriptingProvider).RunDataTableScript(self, ScriptCode.Text, aEvent, rslPascalScript);
  end;
end;

procedure TDADataTable.InternalAfterInsert(Sender: TDataset);
begin
  CallScript('AfterInsert');
  //.........................
end;

If you want to call a method from your own script, perform the following steps:

var AScript:TStringList;
begin
  AScript := TStringList.Create();
  try
    AScript.Add('procedure MyScript;');
    AScript.Add('begin');
    AScript.Add('  ShowMessage(`This is my script`);');
    AScript.Add('end;');
    (DAPSScriptingProvider as IDADataTableScriptingProvider).RunDataTableScript(MyDataTable, AScript.Text, 'MyScript', rslPascalScript);
  finally
    AScript.Free();
  end;
end;

Location


Required Methods


RunDataTableScript

Calls the specified method aMethod from the script aScript. You can access aDataTable fields here.

procedure RunDataTableScript(aDataTable: TDADataTable; const aScript: string; const aMethod: string; aLanguage: TROSEScriptLanguage)

Parameters:

  • aDataTable: Table that will be used for providing fields in the script.
  • aScript: Script text
  • aMethod: Method that will be called
  • aLanguage: Script language. By default this is rslPascalScript.