The
ptdoutput variable type is provided by PTD for interaction between
Phantom scripts and the PTD application. It is used to control certain
aspects of PTD during preprocessor and postprocessor
operations. As such, it is only available during pre- and post- processor
runs.
When a processor is run, a ptdoutput variable is automatically created
and inserted in the script. The variable is called PTDOutput. It does
not need to be declared manually inside the script since it is inserted
automatically at the beginning of the script.
The PTDOutput variable represents the output for the current testcase
or suite the processor is associated with. It can be used to access
properties of the output, such as output text or error and warning
counts. Other PTD outputs can be accessed as well (child outputs and
parent outputs if the suite or testcase has children or a parent,
respectively).
There are several member functions associates with the ptdoutput variable
type. They are listed below:
Member Functions
getChild
Syntax:
ptdoutput ptdoutput.getChild(int)
Return Type: ptdoutput
Parameters: int index
Description:
This function retrieves the child output indicated by 'index'. The input
('index') is a zero based number identifying a child output to this
output. A child output is an output created by a suite or testcase that
is a child to the suite represented by this output. The first child
is represented by a 0, the second by a 1, and so on. The function returns
a ptdoutput variable that can be used to access the output of the child.
Example
Code |
int
i = PTDOutput.getChildCount();
disp(i);
ptdoutput Child;
if(i > 0){
Child = PTDOutput.getChild(1);
}
|
getChildCount
Syntax:
int ptdoutput.getChildCount()
Return Type: int
Parameters: none
Description:
This function returns the number of child outputs belonging to this
output. An output is a child output if it is the output of a suite or
testcase that is a child to the suite represented by this output. Only
suites can have child items, therefore only a suite output can have
child outputs. This function returns the count of only direct children,
not any children of the children.
Example
Code |
int
i = PTDOutput.getChildCount();
disp(i); |
getErrorCount
Syntax:
int ptdoutput.getErrorCount()
Return Type: int
Parameters: none
Description:
This function returns the total number of errors that occurred in this
output. If this output has child outputs, this is the sum of all error
counts of the child outputs.
Example
Code |
int
i = PTDOutput.getErrorCount(); |
getName
Syntax:
string ptdoutput.getName()
Return Type: string
Parameters: none
Description:
This function returns a string with the name of the current output.
The name corresponds to the name of the suite or testcase the output
is associated with.
Example
Code |
string
s = PTDOutput.getName();
disp(s); |
getOutput
Syntax:
string ptdoutput.getOutput()
Return Type: string
Parameters: none
Description:
This function returns a string containing the output from the suite
or testcase. For a suite, this includes the output of all child suites
or testcases. If this is used in a preprocessor, no output has occurred
yet so this function will return an empty string. This returned string
does not contain the output for any pre- and post-processors associated
with any child suites or testcases.
Example
Code |
string
s = PTDOutput.getOutput();
disp(s); |
getParent
Syntax:
ptdoutput ptdoutput.getParent()
Return Type: ptdoutput
Parameters: none
Description:
This function will return the parent output of this output. A parent
output exists if this output belongs to a child suite or testcase that
was run along with its parent suite. If no parent output exists an error
is produced. To determine if the output has a parent, use the hasParent
function.
Example
Code |
ptdoutput
parent;
if(PTDOutput.hasParent()){
parent = PTDOutput.getParent();
disp("Parent retrieved");
} |
getRemoteMachine
Syntax:
string ptdoutput.getRemoteMachine()
Return Type: string
Parameters: none
Description:
This function returns a string representing the name of the remote machine
the current suite or testcase is being run on. This name corresponds
to the name used in the Remote Execution
dialog. If the suite or testcase is being run on the local machine,
this function returns an empty string.
Example
Code |
string
s = PTDOutput.getRemoteMachine();
disp("Running on " + s); |
getWarningCount
Syntax:
int ptdoutput.getWarningCount()
Return Type: int
Parameters: none
Description:
This function returns the total number of warnings that occurred in
this output. If this output has child outputs, this is the sum of all
warning counts of the child outputs.
Example
Code |
int
i = PTDOutput.getWarningCount();
disp(i); |
haltExecution
Syntax:
void ptdoutput.haltExecution()
Return Type: void
Parameters: none
Description:
This function can be used to stop the execution of PTD. This will halt
execution of the processor, the testcase, and the suite. If the suite
is run on a remote machine, this will halt execution only for that machine.
If this is used in a preprocessor, the script associated with the testcase
will not be run.
Example
Code |
PTDOutput.haltExecution();
disp("Wont get here"); |
hasParent
Syntax:
bool ptdoutput.hasParent()
Return Type: bool
Parameters: none
Description: .
This function returns true if the output has a parent output, false
otherwise. See the getParent function for more information and an example.
saveAsHTML
Syntax:
bool ptdoutput.saveAsHTML(string)
Return Type: bool
Parameters: string FileName
Description:
This function saves the current output and all child outputs to a HTML
file indicated by the parameter (FileName). The function returns true
if the save succeeded, false otherwise. If a relative path is given,
the file will be saved relative to the current PTD directory, not the
testcase directory.
Example
Code |
PTDOutput.saveAsHTML("output.htm"); |
saveAsText
Syntax:
bool ptdoutput.saveAsText(string)
Return Type: bool
Parameters: string FileName
Description:
This function saves the current output and all child outputs to the
ASCII text file indicated by the parameter (FileName). This function
returns true if the save succeeded, false otherwise. If a relative path
is given, the file will be saved relative to the current PTD directory,
not the testcase directory.
Example
Code |
PTDOutput.saveAsText("output.htm"); |