Sets or returns the value associated with a given variable name.
Use this property to get and set the values for session-wide variables. Because this property consists of an array of values, you must specify the name of the variable you are interested in. If you set the value of a variable that does not exist, it is created with the specified value assigned to it. If you try to get the value of a variable that does not exist, an empty Variant is returned (for Visual Basic).
IBM Rational ClearQuest supports the use of session-wide variables for storing information. Once created, you can access session-wide variables through the current Session object at any time and from functions or subroutines, including hook routines, that have access to the Session object. When the current session ends, either because the user logged out or you deleted the Session object, all of the variables associated with that Session object are deleted. A Session-wide variable is accessed through the NameValue property (GetNameValue and SetNameValue methods for Perl). In addition, the HasValue method can be used to check whether a variable exists.
For example, there is a _CQ_WEB_SESSION session variable that specifies if a Rational ClearQuest session is a web session or a full client session. If _CQ_WEB_SESSION exists, then the session is a Web session. You can check for this value using the HasValue method.
You can also store objects as session variables. For example:
set sessionObj.NameValue "Obj", object
set sessionObj.NameValue "CalendarHandle", param.ObjectItem
In the above example, param is the parameter to a record script hook and contains an object handle.
Elsewhere, you can then manipulate the properties of the object. For example:
Dim Calender 'Get the object handle Set Calender = MySession.NameValue("CalendarHandle") 'Do something with the object ...
VBScript
session.NameValue (variable_name) session.NameValue variable_name, newValue
Perl
$session->GetNameValue(variable_name); $session->SetNameValue(variable_name, newValue);
For Perl, a String specifying the new value for the variable.
VBScript
set sessionObj = GetSession ' Get the old value of the session variable "foo" fooValue = sessionObj.NameValue("foo") ' Set the new value of "foo" sessionObj.NameValue "foo",bar
Perl
$sessionObj = $entity->GetSession(); if ($sessionObj->HasValue("foo")) { # Get the old value of the session variable "foo" $fooValue = $sessionObj->GetNameValue("foo"); # Set the new value of "foo" $sessionObj->SetNameValue("foo","bar");