WEAPVersion and WEAPVersions API Classes

The WEAPVersion class represents a single WEAP version, whereas WEAPVersions is the collection of all versions in the active area. (To see the list of versions in WEAP, on the menu choose Area, Revert to Version. The versions will be listed in the following format: AreaName: VersionDateTime - VersionName.)

The WEAPVersions collection is a property of the WEAPApplication class:

  1. WEAPApplication.Versions, e.g., WEAP.Versions

You can get access to a WEAPVersion in two different ways:

  1. WEAPVersions(VersionComment or Index), specifying either the comment associated with a version or a number from 1 to WEAPApplication.Versions.Count, e.g., WEAP.Versions("Finished with Current Accounts") or WEAP.Versions(1)

  2. Iterate through the collection of versions, e.g., For Each Version in WEAP.Versions

WEAPVersions Properties and Methods

Example (using VB script)

Count: Get the number of WEAP versions in the active area. Read only.

FOR i = 1 to WEAP.Versions.Count;
  PRINT WEAP.Versions(i).Name
NEXT

Exists(VersionComment): Returns true if VersionComment exists.  Read only.

IF WEAP.Versions.Exists("Finished Reference Scenario") THEN
WEAP.Versions("Finished Reference Scenario").Revert
END IF

Item(VersionComment or Index): Get the version identified by comment or index (from 1 to Versions.Count). If more than one version has the same comment, then the latest version is chosen.  Item is the "default" property, and therefore is usually omitted. Thus, the first two examples to the right are equivalent. Read only.

PRINT WEAP.Versions.Item(1).Date
PRINT WEAP.Versions(1).Comment
PRINT WEAP.Versions("Finished Reference Scenario").Name

NameList: Get a list of versions separated by character specified by optional parameter ListSeparator (which defaults to comma). Read only.

PRINT "Versions: " & WEAP.Versions.NameList

 

WEAPVersion Properties and Methods

Example (using VB script)

Comment: Set or get the comment associated with the version. The comment can be blank.

WEAP.Versions(1).Comment = "Finished Reference Scenario"

PRINT WEAP.Versions(1).Comment

Date: Get the date the version was saved. Read only.

PRINT WEAP.Versions(1).Date

Filename: Get the filename, including path, of the version. Read only.

PRINT WEAP.Versions(1).Filename

Name: Get the full name (both date and comment) of the version. Read only.

FOR Each Version in WEAP.Versions

   PRINT Version.Name

END IF

Revert: Revert to this "version" of the active area. Use with caution: when you revert to a version, it will overwrite everything in the active area, so that the area will be just as it was when the version was originally saved.

WEAP.Versions(1).Revert

WEAP.Versions("Finished Reference Scenario").Revert