Programming with the TestStand API in HTBasic
- Aktualisiert2025-07-23
- 2 Minute(n) Lesezeit
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.
| 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 |
SUB Test
REAL Realnum
CALL Getvalnumber("Step.Limits.High",0,Realnum)
CALL Setvalnumber("Step.Result.Numeric",0,Realnum)
SUBENDUsing 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.
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.
SUB Test2dstr
DIM Strings$ (2, 5) [30]
CALL Getvalstrarray ("Local.StringArray2",1,Strings$ (*) )
SUBENDThe 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]