NameValue

Description

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. Exemple :

set sessionObj.NameValue "Obj", object

ou

set sessionObj.NameValue "CalendarHandle", param.ObjectItem

Dans l'exemple ci-dessus, param désigne le paramètre d'un crochet de script d'enregistrement et contient un identificateur d'objet.

Elsewhere, you can then manipulate the properties of the object. Exemple :

Dim Calender

'Get the object handle

Set Calender = MySession.NameValue("CalendarHandle")

'Do something with the object ...

Syntaxe

VBScript

session.NameValue (variable_name)
session.NameValue variable_name, newValue 

Perl

$session->GetNameValue(variable_name);
$session->SetNameValue(variable_name, newValue); 
Identificateur
Description
session
Objet Session représentant la session en cours d'accès à la base de données.
nom_variable
A String containing the name of the variable to get or set.
newValue
For Visual Basic, a Variant specifying the new value for the variable.

For Perl, a String specifying the new value for the variable.

Valeur de retour
For Visual Basic, a reference to a Variant containing the value for the variable.

For Perl, a String containing the value for the variable.

Exemple

VBScript

set sessionObj = GetSession 

' Get the old value of the session variable "test" 
testValue = sessionObj.NameValue("test") 

' Set the new value of "test" 
sessionObj.NameValue "test",bar 

Perl

$sessionObj = $entity->GetSession();

if ($sessionObj->HasValue("test")) {

# Get the old value of the session variable "test" 

$testValue = $sessionObj->GetNameValue("test");



# Set the new value of "test" 

$sessionObj->SetNameValue("test","bar"); 

Feedback