The ScriptWrapper defines a global object for all scripts: wrapper. This object supports the following methods and properties:
Property/Method Description addMethod( name, [optional]fullName, [optional]downloadInputs )style="font-weight: bold;">addMethod( name )
NOTE: In Analysis Server 3.1 and beyond you can now specify methods in the header using the "method:" syntax. This is the preferred technique.
Registers a method that can be invoked by the client application (e.g. ModelCenter). The method specified should match a method defined in the script that takes no arguments.wrapper.addMethod "reinitialize" sub reinitialize x = 0 end sub
If the optional fullName argument is passed, clients may choose to display that text instead of the method name in their GUI's.
If the optional downloadInputs argument is passed, the value is returned to the client as a hint for whether to re-download component input values after calling the method. If you are using ModelCenter or ModelRunner as your client, you must be using v6.1 or greater for this to take effect. The optional downloadInputs argument was added in Analysis Server v4.1 variable addVariable( name, type, isInput )
Adds a variable to the script environment at run time. For example, to add a variable named cost to the wrapper, use the following code: dim cost set cost = wrapper.addVariable( "cost", "double", false ) cost.value = volume*1.3Note that the variable returned from the addVariable() function must be stored by the user if it is needed later. Also note that to access the value of the variable, the .value sub property must explicitly be used.Valid variable types include:
- double
- double[]
- int
- int[]
- file
- string
- string[]
- boolean
- boolean[]
variable getVariable( name )
Retrieves a variable from the wrapper. This function needs to be used to access variables that are in sub-groups. For example, to modify the value of a variable named outputs.cost, use the following code: dim cost set cost = wrapper.getVariable( "outputs.cost" ) cost.value = 10Note that to access the value fo the variable, the .value sub property must explicitly be used. removeVariable( name )
Removes a variable from the wrapper sleep( milliseconds )
Sleeps for a period of time directory
A read-only property containing the directory that the wrapper is stored in.
Property Type Description descriptionstring A short, one-line description of the variable. valueboolean The value of the variable. This is the default property.
Property Type Description array
array
Gets or sets the entire array at once.
descriptionstring A short, one-line description of the variable. length( dim )integer The number of elements in the array.
- dim The dimension to read. Optional (defaults to 0)
numDimensionsinteger
Read only attribute which returns the number of dimensions in the n-D array
size ( dim )integer The same as length value( index1, index2, ... )boolean The value of the variable. This is the default property.
- index1 The first index in the array or a string representation of the entire multi-dimensional array index of the form "[3,2,4]", or an array of integers representing all the dimensions of the array.
- index2 If index1 is the first index, this and further arguments can optionally be filled in for further dimensions of the array.
Method Description getNumDimensions()Returns the number of dimensions of the array setDimensions( 1stDimSize, 2ndDimSize, ... , 10thDimSize )Sets the lengths of the various dimensions of the array. The array will have as many dimensions as it is given parameters in this function (i.e. 1-10).
- 1stDimSize - the size of the 1st dimension
- 2ndDimSize - the size of the 2nd dimension
- ...
- 10thDimSize - the size of the 10th dimension
getArray()Returns the array setArray( array )Sets the contents of the array to equal that of the given array
- array - the array to copy from
Property Type Description descriptionstring A short, one-line description of the variable. enumAliasstring A comma-separated list of user-friendly string values corresponding to each enumerated value. The alias value may be used to set the value of the variable instead of the actual enumerated value. If alias values are specified, ModelCenter will display the alias value rather than the enumerated value. enumValuesstring A comma-separated list of values. lowerBounddouble The lower bound for the variable. If not specified, there is no bound. unitsstring The units value upperBounddouble The upper bound for the variable. If not specified, there is no bound. valuedouble The value of the variable. This is the default property.
Property Type Description array array Gets or sets the entire array at once. descriptionstring A short, one-line description of the variable. enumAliasstring A comma-separated list of user-friendly string values corresponding to each enumerated value. The alias value may be used to set the value of the variable instead of the actual enumerated value. If alias values are specified, ModelCenter will display the alias value rather than the enumerated value. enumValuesstring A comma-separated list of values. length( dim )integer The number of elements in the array.
- dim The dimension to read. Optional (defaults to 0)
lowerBounddouble The lower bound for the variable. If not specified, there is no bound. size( dim )integer The same as length unitsstring The units value upperBounddouble The upper bound for the variable. If not specified, there is no bound. value( index1, index2, ... )double The value of the variable. This is the default property.
- index1 The first index in the array or a string representation of the entire multi-dimensional array index of the form "[3,2,4]", or an array of integers representing all the dimensions of the array.
- index2 If index1 is the first index, this and further arguments can optionally be filled in for further dimensions of the array.
Method Description getNumDimensions()Returns the number of dimensions of the array setDimensions( 1stDimSize, 2ndDimSize, ... , 10thDimSize )Sets the lengths of the various dimensions of the array. The array will have as many dimensions as it is given parameters in this function (i.e. 1-10).
- 1stDimSize - the size of the 1st dimension
- 2ndDimSize - the size of the 2nd dimension
- ...
- 10thDimSize - the size of the 10th dimension
getArray()Returns the array setArray( array )Sets the contents of the array to equal that of the given array
- array - the array to copy from
Property Type Description descriptionstring A short, one-line description of the variable. enumAliasstring A comma-separated list of user-friendly string values corresponding to each enumerated value. The alias value may be used to set the value of the variable instead of the actual enumerated value. If alias values are specified, ModelCenter will display the alias value rather than the enumerated value. enumValuesstring A comma-separated list of values. lowerBoundinteger The lower bound for the variable. If not specified, there is no bound. unitsstring The units value upperBoundinteger The upper bound for the variable. If not specified, there is no bound. valueinteger The value of the variable. This is the default property.
Property Type Description array array Gets or sets the entire array at once. descriptionstring A short, one-line description of the variable. enumAliasstring A comma-separated list of user-friendly string values corresponding to each enumerated value. The alias value may be used to set the value of the variable instead of the actual enumerated value. If alias values are specified, ModelCenter will display the alias value rather than the enumerated value. enumValuesstring A comma-separated list of values. length( dim )integer The number of elements in the array.
- dim The dimension to read. Optional (defaults to 0)
lowerBoundinteger The lower bound for the variable. If not specified, there is no bound. size( dim )integer The same as length unitsstring The units value upperBoundinteger The upper bound for the variable. If not specified, there is no bound. value( index1, index2, ... )double The value of the variable. This is the default property.
- index1 The first index in the array or a string representation of the entire multi-dimensional array index of the form "[3,2,4]", or an array of integers representing all the dimensions of the array.
- index2 If index1 is the first index, this and further arguments can optionally be filled in for further dimensions of the array.
Method Description getNumDimensions()Returns the number of dimensions of the array setDimensions( 1stDimSize, 2ndDimSize, ... , 10thDimSize )Sets the lengths of the various dimensions of the array. The array will have as many dimensions as it is given parameters in this function (i.e. 1-10).
- 1stDimSize - the size of the 1st dimension
- 2ndDimSize - the size of the 2nd dimension
- ...
- 10thDimSize - the size of the 10th dimension
getArray()Returns the array setArray( array )Sets the contents of the array to equal that of the given array
- array - the array to copy from
Property Type Description isBinaryboolean Specifies the file as binary (true) or ascii (false). Default is false. fileExtensionstring The file extension of a binary file. ModelCenter will open the file using the program associated with this file extension when the file is double-clicked in the Component Tree.
Method Description readFile( fileName ),
fromFile( fileName )Reads the specified file.
- fileName - the name of the file to load.
writeFile( fileName ),
toFile( fileName )Writes to the specified file.
- fileName - the name of the file to load.
Property Type Description descriptionstring A short, one-line description of the variable. enumAliasstring A comma-separated list of user-friendly string values corresponding to each enumerated value. The alias value may be used to set the value of the variable instead of the actual enumerated value. If alias values are specified, ModelCenter will display the alias value rather than the enumerated value. enumValuesstring A comma-separated list of values. valuestring The value of the variable. This is the default property.
Property Type Description array array Gets or sets the entire array at once. descriptionstring A short, one-line description of the variable. enumAliasstring A comma-separated list of user-friendly string values corresponding to each enumerated value. The alias value may be used to set the value of the variable instead of the actual enumerated value. If alias values are specified, ModelCenter will display the alias value rather than the enumerated value. enumValuesstring A comma-separated list of values. length( dim )integer The number of elements in the array.
- dim The dimension to read. Optional (defaults to 0)
size( dim )integer The same as length value( index1, index2, ... )double The value of the variable. This is the default property.
- index1 The first index in the array or a string representation of the entire multi-dimensional array index of the form "[3,2,4]", or an array of integers representing all the dimensions of the array.
- index2 If index1 is the first index, this and further arguments can optionally be filled in for further dimensions of the array.
Method Description getNumDimensions()Returns the number of dimensions of the array setDimensions( 1stDimSize, 2ndDimSize, ... , 10thDimSize )Sets the lengths of the various dimensions of the array. The array will have as many dimensions as it is given parameters in this function (i.e. 1-10).
- 1stDimSize - the size of the 1st dimension
- 2ndDimSize - the size of the 2nd dimension
- ...
- 10thDimSize - the size of the 10th dimension
getArray()Returns the array setArray( array )Sets the contents of the array to equal that of the given array
- array - the array to copy from