The WEAPArea class represents a single WEAP area (dataset), whereas WEAPAreas is the collection of all WEAP areas.
The WEAPAreas collection is a property of the WEAPApplication class, e.g., WEAP.Areas
You can get access to a WEAPArea in three different ways:
WEAPApplication.Areas(AreaName or Index), specifying either the name of the area or a number from 1 to WEAP.Areas.Count, e.g., WEAP.Areas("Weaping River Basin") or WEAP.Areas(1)
WEAPApplication.ActiveArea, e.g., WEAP.ActiveArea
Iterate through the collection of areas, e.g., For Each Area in WEAP.Areas
WEAPAreas Properties and Methods |
Example (using VB script) |
Count: Get the number of WEAP areas. Read only. |
PRINT "There are "; WEAP.Areas.Count; " areas." FOR i = 1 to WEAP.Areas.Count |
Exists(AreaName): Returns true if AreaName exists. |
IF WEAP.Areas.Exists("Weaping
River Basin") THEN END IF |
Item(AreaName or Index): Get the area identified by name or index (from 1 to Areas.Count). Item is the "default" property, and therefore is usually omitted. Thus, the first two examples to the right are equivalent. |
WEAP.Areas.Item("Weaping River Basin").Open WEAP.Areas("Weaping River Basin").Open WEAP.Areas(5).Open |
NameList: Get a list of area names separated by character specified by optional parameter ListSeparator (which defaults to comma). Read only. |
PRINT "Areas: " & WEAP.Areas.NameList |
WEAPArea Properties and Methods |
Example (using VB script) |
Backup(BackupFolder, IncludeResults): Backup the area to a .WEAP file in the specified BackupFolder. Optionally include results. |
WEAP.ActiveArea.Backup("C:\Backup", true) FOR EACH Area IN WEAP.Areas |
Directory: Get the folder for the area (e.g. C:\Program Files\WEAP21\Weaping River Basin). Read Only. |
FOR EACH Area IN WEAP.Areas |
Name: Get the name of the area. Read only. |
PRINT WEAP.Areas(1).Name |
Open: Make this area the active area. |
WEAP.Areas("Weaping River Basin").Open Note: This is equivalent to WEAP.ActiveArea = "Weaping River Basin" |
Save: Save all changes to the area. This only works if the area is the active area. |
WEAP.ActiveArea.Save Note: This is equivalent to WEAP.SaveArea |