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

The APGen.Values collection contains values associated with an APGen object.  The collection is of type Collection.

Syntax

VBScript:

oAPGen.Values[.property | method]

JScript:

oAPGen.Values[.property | method];

Objects

oAPGen An APGen object.  In an APG script, this can be the intrinsic APGen object.
oAPGen.Values A Collection object.

Collection Syntax

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

VBScript:

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

JScript:

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

Collection Parameters

oAPGen An APGen object.
key A unique string key to the collection.  String keys are case insensitive, thus oAPGen("val") and oAPGen("Val") refer to the same object in 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 APGen.Values collection.

This collection is useful for passing named values to multiple APG scripts, and sharing values between multiple APG scripts.  APG scripts can access their parent APGen object's collection using the APGen(key) syntax.

This collection provides a type of application level data sharing, similar to the Application object in ASP.  In ASP, the scope of an application is determined by a virtual directory as managed by IIS.  In APGen, the scope of data sharing and data lifetime is different: Values stored in an APGen object are available to all code with access to the same APGen object - this includes all APG scripts opened and run by the APGen object.  The APGen object and its contained data are destroyed when all references to the APGen object and all its child APG scripts are released.

For additional tips on using this collection, see the Script.Values topic.

Example

Using the APGen.Values collection, application level data can be stored in an APGen object, and accessed in any child APG script.  This example stores an ADO connection string in the APGen object, and sets the output directory for all child scripts.

' Create a new APGen object
Dim oAPGen
Set oAPGen = CreateObject("APGen")

' Set the root output directory
oAPGen.OutputDir = "C:\InetPub\wwwroot\app\"

' Pass in the database connection string
oAPGen("conn_str") = "Provider=SQLOLEDB;Server=(local);" & _
              "Initial Catalog= Northwind;UserID=sa;Password="

' Run a couple APG scripts
oAPGen.Run "default.apg"
oAPGen.RunArgs "product.apg", 11

Within the APG scripts, the output directory is already set, and the connection string variable can be accessed using the APGen intrinsic object:

<%# ' --- default.apg ---
Output.Filename = "default.htm"

. . .

' Open a database connection
' Use the connection string stored in the APGen object
Dim cn
Set cn = Script.CreateObject("ADODB.Connection")
cn.Open APGen("conn_str")

. . .
#%>

Applies To

APGen Object