Show/Hide Toolbars

CatchmentSIM Help

 

User variables are variables that are setup by the script author to hold values from other procedures or project variables.  In particular, all the Result Variable fields in the CSTalk procedures listed in the CSTalk Procedures need to hold a reference to a user variable.  

All user variables must begin with the '&ยด symbol.  User variables can be single value user variables, eg., &Value or array variables such as &ArrayValues[0], &ArrayValues[1], &ArrayValues[2] etc.  These are described in the following sections.

 

Single Value User Variables

 

User variables do not need to be declared and can be setup on the fly.

 

EXAMPLE

 

SaveDialogBox(&HMSFile,"HEC-HMS Project (*.hms)",".hms","")
 
StartPrintToFile(&HMSFile,ASCII,WINDOWS,OVERWRITE)
  {Text Output Files}
EndPrintToFile(&HMSFile)

 

 

The &HMSFile user variable has been initialised by simply placing it in the Result Variable field of the SaveDialogBox and was then used in the StartPrintToFile and EndPrintToFile procedures.

 

Array Type User Variables

 

Array type user variables store any number of values in a list.  To access an array value at a certain position the terminology &Array_Variable_Name[Array_Position (integer)] should be used.  Errors will be generated if the Array_Position is outside of the range of values in the array or if the &Array_Variable_Name user variable is not found.

To help trace typographic errors, array type user variable must be initialised using the SetArrayLength procedure.  Array initialisation takes the form of SetArrayLength(&ArrayVariable,0).  Array lengths are automatically adjusted to accommodate assignment of array position values.  For example, if an array has a current length of 2 and the procedure AssignVariable(&ArrayVariable[6],%Subcatchment[1].Area) is called then the array length will be extended to six, positions 3-5 will be left empty and position 6 will hold the area of subcatchment 1.  More details regarding array procedures are given below.

 

GetArrayLength ( Result Variable , Array Type User Variable )

 

Returns the length of the Array Type User Variable as an integer in the Result Variable.

 

SetArrayLength ( Array Type User Variable , New Length )

 

Sets the length of the Array Type User Variable to New Length.  This can be used to initialise, extend or shorten an array.   For example to delete the last two entries in an array the following code could be used.

 

GetArrayLength(&ArrayLength,&ArrayVariable)

SetArrayLength(&ArrayVariable,&ArrayLength-2)