<< Click to Display Table of Contents >> Navigation: 3. Script Language > Background Operation > GRS. - Get Result |
MiniRobotLanguage (MRL)
GRS. - Get Result
Get Result from Background Operation
Intention
Using "Background Operations" means, that your Script execution can continue while the Robot is doing something in the background.
How can I get the result of a background operation, if its running in the background?
The answer to this question is, that you get a "Ticket-Number", when you start the background operation. SMB. for example, will drop an "ticket number" on the TOS.
Or, if P2 is given, the ticket-number will be in the given variable.
Now you can get the result any time using the "ticket number" and the GRS.-command.
Just give GRS. the ticket-number, and in exchange you will get the result of the operation - when its already available.
And how do i know that the operation was finished and there is an Result available?
There are several ways to find that out. The easiest is to simply wait for the background Operation to finish, using the WRS.-command (Wait for Result). You can also use the IRS. / NRS. - Conditional statement.
And theoretically you could call GRS. and check the timeout-flag after that. If it was set, there was no such result available.
To wait for a background operation to be finished, the WRS.-command was made.
It can also collect the Results of multiple background operations.
The system works like this:
1. Start a background operation and get a "ticket number"
2. keep the ticket number in a variable
3. do whatever you want ...
4. and call WRS. with that "ticket number" as parameter
5. WRS. will wait until the background Operation has finished
6. Call GRS. to get the result of the background operation
Important Note:
Any result behind an "ticket-number" is stored as long, until you drop it using DRS.
You do not need to wait until the Operation is finished, to drop a result. If you do not need the result of an Operation, you can drop it immediately after you started the background-task. In this case, the robot will internally note that the result is been dropped and drop it immediately when it becomes available.
There is an exception:
Of course you only need to drop the Result of an Parallel-Robot (started with PRR. / PRE.) , if you use the PRS,-command to return a Result. If no Result is returned, it does not need to be dropped.
Use these commands together with Background Operations:
• GRS. - Get Result of Operation
• WRS. - Wait until (one or more) Operation(s) is/are finished
• DRS. - Drop Result of Operation if you do not need it.
• IRS. / NRS. Check if an Result is available
• JRS. / JNS. - Jump if an Result is/not available
to handle the result of the background mail-operation(s).
Example:
' Assume that a file "?path\MailConfig.dat"
' is available
SMP.
' It makes mostly sense with attachements
' SMP.attachment=?path\Send-Mail.zip
' Send the Mail, get the ticket number
SMB.
' If we do not specify a ticket number,
' WRS. will automatically remember the last ticket number
' and use it.
WRS.
' If we do not specify a ticket number,
' GRS. will automatically remember the last ticket number
' and use it.
GRS.
DBP.$$000
' If we do not specify a ticket number,
' DRS. will automatically remember the last ticket number
' and use it.
' DRS. free's the Memory location that was used to hold the
' Result of the background operation.
DRS.
ENR.
Syntax
GRS.[P1][|P2]
Parameter Explanation
P1 - (optional) Variable that contains the "Ticket-Number" which leads to the Return code of the background job. If omitted, the last Background Operation will be taken.
P2 - (optional) Variable for the the Result of the background job. If omitted, TOS is used.
Example
'***********************************
' SMB.-Sample
'***********************************
' Send away 25 Mails
' then wait until they are sent
' and then show the results of all 25 Mails.
'
'#EXE:?pfad\
'#SPI:ForceWrite
'
' Background Mailer-Demo
' Please provide a complete MailConfig.dat
SMP.?path\MailConfig.dat
' Try with attachement also!
' SMP.attachment=?path\Send-Mail.zip
$$HND=
' Be careful or you may end up with in
' an error 421 - too many connections
' from your provider
FOR.$$CNT|1|25
GSB.Lab
NEX.
DBP.$$HND
WRS.$$HND
' Display Results
FEM.Lab_dis|$$TXT|$$HND|,
MBX.!
ENR.
'-----------------------------------------------------------
:Lab_dis
GRS.$$TXT|$$RES
' Always drop Results you do not need anymore
DRS.$$TXT
DBP. Result from $$TXT = $$RES
RET.
'-----------------------------------------------------------
:Lab
SMB.
$$HND=$$HND,$$000
RET.
'-----------------------------------------------------------
Remarks
If you use Background Operations, always drop the result of the operation using DRS..
Otherwise it will be kept in Memory until the Script ends. This only applies to background operations that do post an result to the main script.
Limitations:
-
See also:
• ! Smart Package Robot 's Parallel Robot Operations
• IRS. / NRS. - If Result available
• PRE. - Parallelrobot-Run-End
• ! Smart Package Robot 's Send-Mail
•