User manual

Table Of Contents
Part 2: Automation Programming Reference
Each of the D:\Scripts\Automation\ExampleTable*.vbs scripts contain code used to iterate over a table to
determine its actual structure and cell types. We recommend that you adapt this code to your programs
whenever accessing results from table objects.
Tip: The file D:\Scripts\TableExport.lss also includes code for determining whether CellType 0
cells contain an array and uses the appropriate method for reading the data.
Error Handling for Table Results
Error handling is especially important for tables with Parameter and Boolean cell types, as an error is
generated if a cell has no data. The following snippet shows the use of VBS function "on error resume next"
applied to table data:
' get the Parameter or Boolean Value property (handle error case if no data in the
value)
strThisVal = "-"
on error resume next
set cellVal = myResult.CellValue(rowIdx, columnIdx)
strThisVal = cellVal.value
on error goto 0 ' Reset Error handling state
strRowData = strRowData & strThisVal
Discovering Number of Array Dimensions
You can discover the number of dimensions in a table array by adding the following helper function to
VBScripts:
function getArrayDims(arr1)
dimensions = 0
if IsArray(arr1) then
on error resume next
Err.clear
do while Err.number = 0
dimensions = dimensions + 1
UBound arr1, dimensions
loop
Err.clear
dimensions = dimensions - 1
end if
getArrayDims = dimensions
end function
Tip: This function appears at the end of the sample scripts
D:\Scripts\Automation\ExampleTable*.vbs, from which you can copy it.
Note: This function will not work in VBA scripts.
2-37