Programming with the TestStand API in HTBasic

HTBasic uses a CSUB library TestStand provides to access the TestStand ActiveX API. The CSUB library contains HTBasic subroutines for the GetVal and SetVal methods in the TestStand API.

Accessing Property Values in HTBasic

You can access the values of built-in properties using Get and Set subroutines in the TestStand API CSUB library. The name of each Get or Set subroutine starts with Getval or Setval, followed by the data type name.

Note Some type names are abbreviated because of HTBasic naming limitations.
Function Name TestStand Type HTBasic type
Getvalnumber Number REAL
Setvalnumber Number REAL
Getvalstring String STRING
Setvalstring String STRING
Getvalboolean Boolean INTEGER
Setvalboolean Boolean INTEGER
Getvalnumarray Array of Number Array of REAL
Setvalnumarray Array of Number Array of REAL
Getvalstrarray Array of String Array of STRING
Setvalstrarray Array of String Array of STRING
The following example subroutine demonstrates how to access step properties. The subroutine obtains the value of the upper limit in the current step and sets the measurement value to the upper limit.
SUB Test
 
REAL Realnum
CALL Getvalnumber("Step.Limits.High",0,Realnum)
CALL Setvalnumber("Step.Result.Numeric",0,Realnum)
 
SUBEND

Using Strings in HTBasic

You must choose HTBasic string variables that are large enough to contain the string property values from TestStand. If the HTBasic variable is not large enough, TestStand truncates the value of the string you obtain.

Note Strings you pass to TestStand have no size restrictions.

Using Arrays in HTBasic

You can use the CSUB library subroutines to exchange one- or two-dimensional arrays between TestStand and HTBasic. When retrieving an array from TestStand, you must choose HTBasic array variables as large as the TestStand array. If the HTBasic array is smaller, TestStand returns the ERROR 16 Improper or Inconsistent Dimensions error.

When retrieving a string array, you must ensure that the HTBasic strings are large enough to contain the TestStand strings. If the HTBasic strings are too short, TestStand truncates the string values. When you pass an array to TestStand, TestStand automatically adjusts its array to match the dimensions of the HTBasic array, as shown in the following example:
SUB Test2dstr
 
DIM Strings$ (2, 5) [30]
CALL Getvalstrarray ("Local.StringArray2",1,Strings$ (*) )
 
SUBEND

The following example shows the equivalent TestStand declaration for the numeric array, assuming that the HTBasic OPTION BASE is zero: StringArray2 Array of Strings [0 .. 2] [0 . . 5]