DataValue Class for Scriptable Objects

The inputs and outputs for any Mathcad scripted component form a DataValue collection. Each item in the collection is of type DataValue, and has the following properties. Components can take any valid Mathcad data type as an input, so the DataValue object is capable of handling scalars, arrays, and strings, and is of type variant.

Value and IValue

The Value property is used to access the real portion of the data in the DataValue object, and the IValue property accesses the imaginary portion. The row and col parameters are optional. If these parameters are omitted, then the value is returned as a variant array of doubles or a scalar, depending on the type of data contained in the DataValue object. If the row and col parameters are specified, a scalar value at the specified row/column is returned.

x = objDataValue.Value( [row, col] )        x = objDataValue.IValue( [row, col]
objDataValue.Value( [row, col] ) = x       objDataValue.IValue( [row, col] ) = x

Element

Description

x

The real portion of the data at this position.

row

The integer index of the desired row.

col

The integer index of the desired column.

Notes

Outputs(0).Value(1,2) = 1

a 2 row, 3 column data value is created which contains the value "1" at row 1, col 2. If a value already exists and an assignment is made which exceeds the current maximum row or column, the value is automatically re-dimensioned to fit the new data. This feature of the Value property allows languages that do not directly support variant arrays (such as JScript) to create and access DataValue arrays.

Rows and Cols

The Rows and Cols properties are read-only values returning the number of rows or columns in the DataValue object. Can be used to determine the dimensions of a vector of array stored at a particular element at run-time. This provides flexibility and allows the programmer to avoid hard-coding a fixed number of rows.

x = objDataValue.Rows     x = objDataValue.Cols

Element

Description

x

The integer number of rows or columns

IsComplex

The IsComplex property is a read-only value which returns TRUE if the value has a valid imaginary portion (accessed through the IValue property), or FALSE if the value has only a real portion. This property can be used for error trapping if particular types of inputs or outputs are expected.

bool = objDataValue.IsComplex     

Element

Description

bool

TRUE (1) if the value has an imaginary part, FALSE (0) if it does not.

Example

'check a particular input and inform the user whether complex or real
if (Inputs(0).IsComplex ) then
      MsgBox( "Complex Value!" )
else
      MsgBox( "Real Value!" )
end if