7.3 Jobs Collection

Represents a collection of Job objects.

7.3.1 AddElement method

Submits a job to the queue.

Syntax

object.AddElement(
   fileName As String, 
   [format As String])

Parameters

fileName

The name of the file that contains the job.

format

Optional. The printer-specific format in which to print the job.

Return Values

Boolean. Returns TRUE if successful. Otherwise, FALSE.

Remarks

An optional format string that can be specified for the job server to use. The nature of the contents of this parameter depend on the job server. The maximum size for this parameter is 152 bytes.

Example

This example adds textfile.txt to the queue Sample_Job_Queue. Ensure that the specified queue is existing.

Set Queue = CreateObject("ucx:Queue") 
Queue.Name = "Sample_Job_Queue" 
Set Jobs = Queue.Jobs 
Jobs.AddElement("sys:temp\textfile.txt")

7.3.2 Create method

Creates a new job in the queue.

Syntax

object.Create()

Parameters

None.

Return Values

Job.

Remarks

You may need to use the JobFile property to get the File object, and then write the data. Use the Post method to submit the Job.

Example

This example creates a new job in the queue Sample_Job_Queue. Ensure that the specified queue is existing.

Set Queue = CreateObject("ucx:Queue") 
Queue.Name = "Sample_Job_Queue" 
Set Jobs = Queue.Jobs 
Set Jobobj = Jobs.Create()

See Also

7.3.3 Element method

Finds a Job object by job number.

Syntax

object.Element(
   JobNumber As Long)

Parameters

JobNumber

The number of the job to find.

Return Values

Job. Returns the job associated with the specified job number.

Example

This example finds the job associated with job number 1in the queue Sample_Job_Queue. Ensure that the specified queue is existing.

JobNumber = 1 
Set Queue = CreateObject("ucx:Queue") 
Queue.Name="Sample_Job_Queue" 
Set Jobs=Queue.Jobs 
Set Job=Jobs.Element(JobNumber) 
Print("Name of the first job is: & Job.JobName) 

7.3.4 HasMoreElements method

Determines whether or not the collection contains any more Job objects.

Syntax

object.HasMoreElements()

Parameters

None.

Return Values

Boolean. Returns TRUE if the collection contains more Job objects. Otherwise, FALSE.

Example

This example determines whether there are any more jobs objects in the queue Sample_Job_Queue. Ensure that the specified queue is existing.

Set Queue = CreateObject("ucx:Queue") 
Queue.Name = "Sample_Job_Queue" 
Set Jobs = Queue.Jobs 
Jobs.Reset 
Print("The queue has the following jobs:") 
While(Jobs.HasMoreElements=TRUE) 
     Set Job=Job.Next 
     Print(Job.JobName) 
Wend

7.3.5 Next method

Returns the next Job object in the collection.

Syntax

object.Next()

Parameters

None.

Return Values

Job. Returns the next Job object in the collection.

Example

This example returns the next Job in the queue Sample_Job_Queue. Ensure that the specified queue is existing.

Set Queue = CreateObject("ucx:Queue") 
Queue.Name = "Sample_Job_Queue" 
Set Jobs = Queue.Jobs 
Jobs.Reset 
Print("The queue has the following jobs:") 
While(Jobs.HasMoreElements=TRUE) 
     Set Job=Job.Next 
     Print(Job.JobName) 
Wend

7.3.6 Open method

Opens a queued job.

Syntax

object.Open(
   [JobType As Integer])

Parameters

JobType

Optional. A specific job to open. If this parameter is not specified, the first job in the queue is opened.

See Remarks below.

See Section A.28, Queue Constants.

Return Values

Job. Returns the job name if it is successfully opened.

Remarks

You may need to (1) use the JobFile property to get the FILE object, (2) read the data from file object, then (3) call the Close method to remove the job from the queue.

The JobType value depends on the job server and client. JobType is a number that tells the job server what type of job is represented by the job entry. A job server can request specific job types from a queue when making a request to service a job. The JobType is a value agreed upon by the client and the job server. For example, JobType could be used to signal which paper tray to use in a printer.

See Section A.28, Queue Constants.

Example

This example opens the first job in the queue Sample_Job_Queue. Ensure that the specified queue is existing

Set Queue = CreateObject("ucx:Queue") 
Queue.Name = "Sample_Job_Queue" 
Set Jobs = Queue.Jobs 
Set Job.Open

7.3.7 RemoveElement method

Deletes the specified job from a queue.

Syntax

object.RemoveElement(
   [JobNumber As Long])

Parameters

JobNumber

Optional. The number of the job to remove. If this parameter is not specified, it removes the first job in the queue.

Return Values

Boolean. Returns TRUE if the job is successfully removed. Otherwise, FALSE.

Example

This example removes the first job from the queue.

Set Queue = CreateObject("ucx:Queue") 
Set Jobs = Queue.Jobs 
Jobs.RemoveElement()

7.3.8 Reset method

Resets the collection of Job objects.

Syntax

object.Reset()

Parameters

None.

Return Values

Void.

Example

This example resets the collection of Job objects in the queue Sample_Job_Queue. Ensure that the specified queue is existing.

Set Queue = CreateObject("ucx:Queue") 
Queue.Name = "Sample_Job_Queue" 
Set Jobs = Queue.Jobs 
Jobs.Reset 
Print("The queue has the following jobs:") 
While(Jobs.HasMoreElements=TRUE) 
     Set Job=Job.Next 
     Print(Job.JobName) 
Wend

See Also

7.3.9 Retrieve method

Retrieves a job from the queue into a file.

Syntax

object.Retrieve(
   FileName As String, 
   [JobType As Integer])

Parameters

FileName

The name of the file in which the job is to be retrieved.

JobType

Optional. The type of job to retrieve. If this parameter is not specified, this method retrieves the first job in the queue. See Remarks below.

Return Values

Boolean. Returns TRUE if the file is successfully retrieved. Otherwise, FALSE.

Remarks

The JobType value depends on the job server and client. JobType is a number that tells the job server what type of job is represented by the job entry. A job server can request specific job types from a queue when making a request to service a job. The JobType is a value agreed upon by the client and the job server. For example, JobType could be used to signal which paper tray to use in a printer.

See Section A.28, Queue Constants.

Example

This example retrieves the first job in the queue and places it in file text.txt.

Set Queue = CreateObject("ucx:Queue") 
Set Jobs = Queue.Jobs 
Jobs.Retrieve("text.txt",JobType)