Datasheet

API Delphi Client
248
if RouterOS.Connect('192.168.0.1', 'admin', 'password') then
begin
//we are connected successfully
end
else
begin
//an error occured; text error message is in LastError property
end;
Executing queries
All queries are done by calling Query function of TRosApiClient. It returns an instance of TRosApiResult, from
which all data are fetched.
var
Res: TRosApiResult;
Res := RouterOS.Query(['/system/resource/print'], True);
Obtaining the result with GetAll
Res := ROS.Query(['/ip/arp/print', '?interface=ether2'], True);
while not Res.Eof do
begin
SomeProcessingFunction(Res['.id'], Res['address']);
Res.Next;
end;
Res.Free;
Obtaining the result with GetOne
First, place a Timer on form and name it tmrListen, set Enabled to False. Then we make a query and enable timer:
ResListen := ROS.Query(['/log/listen'], False);
tmrListen.Enabled := True;
Then we check for new data on timer event:
procedure TForm1.tmrListenTimer(Sender: TObject);
begin
repeat
if not ResListen.GetOne(False) then Break;
if ResListen.Trap then
begin
ShowMessage('Trap: ' + ROS.LastError);
Break;
end;
if ResListen.Done then