    

 ## On this page

  

 

 # VBScript Object scriptWrapper API

 Last update: 22.06.2026 

## Wrapper Object

The ScriptWrapper defines a global object for all scripts: **wrapper**. This object supports the following methods and properties:

### Properties and Methods

Property/MethodDescription`addMethod( name, [optional]fullName, [optional]downloadInputs )`  
`addMethod( name )`You can 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 (for example, 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 GUIs.  
  
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.`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.3`  
  
Note that the variable returned from the `addVariable()` function must be stored 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 must 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 = 10`  
  
Note that to access the value of 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.## Boolean Variable Object

### Properties

PropertyTypeDescription`description`stringA short, one-line description of the variable.`value`booleanThe value of the variable. This is the default property.## Boolean Array Object

### Properties

PropertyTypeDescriptionarrayarrayGets or sets the entire array at once.`description`stringA short, one-line description of the variable.`length( dim )`integerThe number of elements in the array.  
- `dim` - The dimension to read. Optional (defaults to 0).`numDimensions`integerRead only attribute which returns the number of dimensions in the n-D array`size ( dim )`integerThe same as `length`.`value( index1, index2, ... )`booleanThe 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.### Methods

MethodDescription`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 (for example, 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## Double Variable Object

### Properties

PropertyTypeDescription`description`stringA short, one-line description of the variable.`enumAlias`stringA 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.`enumValues`stringA comma-separated list of values.`lowerBound`doubleThe lower bound for the variable. If not specified, there is no bound.`units`stringThe units value`upperBound`doubleThe upper bound for the variable. If not specified, there is no bound.`value`doubleThe value of the variable. This is the default property.## Double Array Object

### Properties

PropertyTypeDescription`array`arrayGets or sets the entire array at once.`description`stringA short, one-line description of the variable.`enumAlias`stringA 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.`enumValues`stringA comma-separated list of values.`length( dim )`integerThe number of elements in the array.  
- `dim` - The dimension to read. Optional (defaults to 0).`lowerBound`doubleThe lower bound for the variable. If not specified, there is no bound.`size( dim )`integerThe same as `length``units`stringThe units value`upperBound`doubleThe upper bound for the variable. If not specified, there is no bound.`value( index1, index2, ... )`doubleThe 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.### Methods

MethodDescription`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 (for example, 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## Integer Variable Object

### Properties

PropertyTypeDescription`description`stringA short, one-line description of the variable.`enumAlias`stringA 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.`enumValues`stringA comma-separated list of values.`lowerBound`integerThe lower bound for the variable. If not specified, there is no bound.`units`stringThe units value`upperBound`integerThe upper bound for the variable. If not specified, there is no bound.`value`integerThe value of the variable. This is the default property.## Integer Array Object

### Properties

PropertyTypeDescription`array`arrayGets or sets the entire array at once.`description`stringA short, one-line description of the variable.`enumAlias`stringA 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.`enumValues`stringA comma-separated list of values.`length( dim )`integerThe number of elements in the array.  
- `dim` - The dimension to read. Optional (defaults to 0).`lowerBound`integerThe lower bound for the variable. If not specified, there is no bound.`size( dim )`integerThe same as `length``units`stringThe units value`upperBound`integerThe upper bound for the variable. If not specified, there is no bound.`value( index1, index2, ... )`doubleThe 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.### Methods

MethodDescription`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 (for example, 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## File Variable Object

### Properties

PropertyTypeDescription`isBinary`booleanSpecifies the file as binary (true) or ascii (false). Default is false.`fileExtension`stringThe 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.### Methods

MethodDescription`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.## String Variable Object

### Properties

PropertyTypeDescription`description`stringA short, one-line description of the variable.`enumAlias`stringA 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.`enumValues`stringA comma-separated list of values.`value`stringThe value of the variable. This is the default property.## String Array Object

### Properties

PropertyTypeDescription`array`arrayGets or sets the entire array at once.`description`stringA short, one-line description of the variable.`enumAlias`stringA 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.`enumValues`stringA comma-separated list of values.`length( dim )`integerThe number of elements in the array.  
- `dim` - The dimension to read. Optional (defaults to 0).`size( dim )`integerThe same as `length``value( index1, index2, ... )`doubleThe 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.### Methods

MethodDescription`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 (for example, 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