Description
The State
property returns the state of the given job.
Declaration
JobObj.State
Read-Only Property | Integer |
JobObj | An expression, variable or parameter that specifies a reference to a Job object |
Applies To
The property is applied to the following object:
Property Value
An integer value that stands for the job state. Read the Network Suite States topic to learn about available job states.
Remarks
To delay script execution until the job reaches a particular state, use the Job.WaitForState
method.
Example
The code below checks whether a job is running using the State
property.
JavaScript, JScript
function JobStateExample()
{
// Specifies the name of a job
var jName = "Job_Name";
// Obtains information about the job
var Job = NetworkSuite.Jobs.ItemByName(jName);
// Checks whether the job is running
if ( Job.State == ns_Running )
Log.Message("The job is running.")
else
Log.Message("The job isn't running.");
}
Python
def JobStateExample():
# Specifies the name of a job
jName = "Job_Name"
# Obtains information about the job
Job = NetworkSuite.Jobs.ItemByName[jName]
# Checks whether the job is running
if Job.State == ns_Running:
Log.Message("The job is running.")
else:
Log.Message("The job isn't running.")
VBScript
Sub JobStateExample()
' Specifies the name of a job
jName = "Job_Name"
' Obtains information about the job
Set Job = NetworkSuite.Jobs.ItemByName(jName)
' Checks whether the job is running
If Job.State = ns_Running Then
Log.Message("The job is running.")
Else
Log.Message("The job isn't running.")
End If
End Sub
DelphiScript
function JobStateExample;
var jName, Job;
begin
// Specifies the name of a job
jName := 'Job_Name';
// Obtains information about the job
Job := NetworkSuite.Jobs.ItemByName[jName];
// Checks whether the job is running
if Job.State = ns_Running then
Log.Message('The job is running.')
else
Log.Message('The job isn''t running.');
end;
C++Script, C#Script
function JobStateExample()
{
// Specifies the name of a job
var jName = "Job_Name";
// Obtains information about the job
var Job = NetworkSuite["Jobs"]["ItemByName"](jName);
// Checks whether the job is running
if ( Job["State"] == ns_Running )
Log["Message"]("The job is running.")
else
Log["Message"]("The job isn't running.");
}