APGen Documentation Previous Topic: Script Object Next Topic: Script.Arguments Collection Parent Topic: Script Object    Script Object
Script.Values Collection
See Also:

The Script.Values collection contains values associated with a Script object.  It is of type Collection.

Syntax

VBScript:

Script.Values.[property | method]

JScript:

Script.Values.[property | method];

Objects

Script A Script object.
Script.Values A Collection object.

Collection Syntax

There are several ways to access items in the Script.Values collection:

VBScript:

Script(key | index) [= value]
or
Script.Value(key | index) [= value]
or
Script.Values.Item(key | index) [= value]

JScript:

Script(key | index) [= value];
or
Script.Value(key | index) [= value];
or
Script.Values.Item(key | index) [= value];

Collection Parameters

key A string key to the collection.
index A zero-based index to the collection.
value A variant value that is stored in the collection.

Notes

See the Collection Object topic for the properties and methods exposed by the Script.Values collection.

The Script.Values collection is typically used for passing named values in and out of APG scripts.  Before the script is run, script-specific parameters are placed in the APGScript.Values collection by an external program.  When the script is run, those parameters are accessed and modified by script code using the Script.Values collection.  After the script is run, the external program may read any output parameters from the APGScript.Values collection.  For an example, see the Passing Data to APG Scripts topic.

Information stored in a script object is available until the APGScript object is released. The following script demonstrates the storage of two types of variables.

<%#
Script("username") = "Fred"
Script("age") = 24
#%>

If you store an object in a script object and use VBScript as your primary scripting language, then you must not use the Set keyword. This is shown in the following script.

<%#
' Store a 'progID' object in the Script object
' Not that the Set keyword is not used
Script("Obj1") = Script.CreateObject("progID")

' Store another 'progID' object in a variable
' This time, the Set keyword is used
Set obj = Script.CreateObject("progID")

' Retrieve obj1 from the Script object
' The Set keyword is used
Set obj1 = Script("Obj1")
#%>

If you store an array in a script object, then you should not alter the elements of the stored array. For example, the following script is broken.

<%# Script("StoredArray")(3) = "new value" #%>

This script is broken because the Script object is implemented as a collection. The array element StoredArray(3) will not receive the new value.

If you store an array in a script object, then you should retrieve a copy of the array before retrieving or changing any of the elements of the array. When you are finished with the array, you should store the array in the script object once again so that any changes are saved.

Applies To

Script Object