Task Object
The Task object enables access to a subset of the functionality of the ComScript module from within an AMT Report. In order to be able to use the Task Object the ComScript module needs to be configured on the server running the Batch controller, see ComScript Module.
The subset of the total ComScript functionality is the major part of the general ComScript Connection Interface and the complete Job Interface. Excluded from the ComScript Connection Interface are the functions for creating most of the Interface objects. The only Interface object that can be created in the Task object is the Job Interface object.
Full descriptions of all the functionality of the Task Object is found in the Connection Interface, in the Job Interface and in the Print Interface help pages.
Below an extract from a report that uses the task object: (not all code has been inserted here, just the code needed to understand the task object)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
begin_definitions
var
st-path-extracts : string
mytask : task //define the task object
myjob : job //define the job object
myprint : print //define the print object
requestid : integer
sb-found : boolean
end_definitions
routine main
begin_routine
mytask.appname := 'TEST'
mytask.connect()
if not mytask.connected
gt-result &= ('ERROR TASK_OBJECT not connected, report exited without running!') + gac-crlf
goto (end)
endif
myjob := mytask.createjob()
myjob.user := 'USER'
myjob.usergroup := 'Administrators'
myjob.queuename := 'Default'
myjob.station := 'STATIONNAME'
myjob.wait := false //in case of error, REPORT should continue
//MyJob.addprinter ('PROUT', 'HP3015')
myjob.setdefaultdontprint (true)
//MyJob.setdontprint ('PROUT', True)
requestid := myjob.addjobrequest('RT_TASK_TEST', report)
// MyPrint := MyTask.CreatePrint()
end_routine
Lines 04/05:
In order to use the Task object inside a report it has to be defined as variable in the definitions section of the
report. And since it will be used to control jobs also a variable for the Job object has to be defined.
Lines 19/25:
Then the ComScript module needs to be connected to a specific application which needs not necessarily be the application
the report belongs toLine 27:
Next a Job Interface object has to be created to be able to start jobs.
Lines 29/36:
Finally a Job can be started. When the AddJobRequest failed, the returned RequestId will be -1, otherwise the returned RequestId can be used to
check the progress of the Job.
loop while MyJob.running
// waiting for the job to finish
endloop