Download WEAP User Guide
Transcript
Advanced Topics
WEAP.LogFile. Calculation errors are those that
appear on the Messages tab in the Results View.
Logfile: Set or get the file to which errors and
warnings are logged (only if Verbose is 0, 1 or
2). Note: these errors and warning are not the
same as "calculation" errors -- those that appear
on the Messages tab in the Results View.
WEAP.Logfile = WEAP.Directory +
"WEAPErrors.txt"
IF WEAP.NumErrors > 0 THEN PRINT
NumErrors: Get or reset the number of errors
WEAP.NumErrors; " Errors"
this session from using API property and method
calls..
NumTimeSteps: Get the number of time steps in PRINT WEAP.NumTimeSteps
each year (e.g., 12). Read only.
Note: This is equivalent to WEAP.Timesteps.Count
PrevTSCalcTS: Integer: Get the timestep of the PRINT WEAP.BranchVariable("\Demand
Sites\South
previous calculation timestep. Read only
City:Supplied").Value(WEAP.PrevTSCa
lcYear, WEAP.PrevTSCalcTS)
PrevTSCalcYear: Integer: Get the year of the
previous calculation timestep. Read only.
PRINT WEAP.BranchVariable("\Demand
Sites\South
City:Supplied").Value(WEAP.PrevTSCa
lcYear, WEAP.PrevTSCalcTS)
Print(Number or text): Prints a number or a text WEAP.Print("The current calculation
year is " & WEAP.CalcYear)
string. Print statements are sent to the
APIPrint.txt file. This file is automatically
monitored and displayed in WEAP's Script
Editor.
PrintToFile(FileName, Number or text,
Append): Prints a number or a text string to a
named text file. The value of the optional
parameter Append will determine what WEAP
will do if the file already exists: if Append is
TRUE (or not specified), WEAP will add the
number or text to the end of the existing file.
Otherwise, the file will be cleared before writing
the number or text to it.
WEAP.PrintToFile("C:\Results.txt",
"Results from scenario: " +
WEAP.ActiveScenario.Name, TRUE)
ProgramDirectory: Gets the full path of the
folder in which WEAP is installed. Read only.
PRINT WEAP.ProgramDirectory
ProgramStarted: Determine if WEAP has
finished starting up. Can be used to make sure
WEAP is loaded before continuing in the script.
Read only.
WEAP =
CreateObject("WEAP.WEAPApplication")
WHILE NOT WEAP.ProgramStarted
' do nothing
WEND
WEAP.PrintToFile("C:\AreaCount.txt",
WEAP.Areas.Count, FALSE)
315