
API Delphi Client
247
TRosApiResult
This class gives you an ability to work with data returned from queries. Each command execution is "isolated" in it's
TRosApiResult object, so you can do parallel requests by calling TRosApiClient.Query and receiving several
TRosApiResult objects.
• property ValueByName[Name: String]: String; default;
Returns the value of Name parameter (word in terms of API) in current sentence. The preferred way of getting the
result is the following: ApiResult['ParmName'] instead of ApiResult.ValueByName('ParmName'). You can use
param name both with and without leading '=' character (ApiResult['address'] and ApiResult['=address'] will return
the same result).
• property Values: TRosApiSentence;
Returns current sentence of query result (type is TRosApiSentence).
• function GetOne(Wait: Boolean): Boolean;
Receives one sentence from the router. If Wait parameter is True, function will wait until sentence is received. If
Wait is False and no sentences were received for now, function returns False. This is helpful when executing
infinite commands (like 'listen') in GUI, when you need to process other user's actions: you should periodically call
GetOne with Wait = False, and in case of negative result just do something else for a time.
• function GetAll: Boolean;
Receives all sentences upto '!done', then returns True (or False in case of a timeout).
• property RowsCount: Integer;
Returns number of received sentences after calling GetAll.
• property Eof: Boolean;
Returns True if there's a more sentence(s) in query result.
• property Trap: Boolean;
Returns True if there were trap(s) during GetAll
• property Done: Boolean;
Returns True if '!done' sentence was received in GetOne
• procedure Next;
Shifts to the next sentence, received in GetAll
• procedure Cancel;
Cancels current command execution.
Examples
Sample application APITest you can download at Downloads and suggestions section
Creating connection to router
At first, we should declare a variable and create an instance of TRosApiClient:
var
RouterOS: TRosApiClient;
RouterOS := TRosApiClient.Create;
Now we connect to router and perform login procedure:
Komentáře k této Příručce