Accessing Arrays Using API - HTBasic
- Updated2025-07-23
- 2 minute(s) read
Purpose
This example demonstrates how to use the TestStand API from an HTBasic code module to access a one-dimensional array, two-dimensional array, and an array of strings in TestStand.
Example File Location
<TestStand Public>\Examples\TestStand API\Accessing Arrays Using API\HTBasic\Accessing Arrays Using API.seq
Highlighted Features
- HTBasic Adapter
- TestStand API
Major API
- PropertyObject.GetValNumberByOffset
- PropertyObject.SetValNumberByOffset
- PropertyObject.GetValStringByOffset
- PropertyObject.SetValStringByOffset
Prerequisites
When you use the demo version of HTBasic, you must configure the HTBasic Adapter to use the HTBasic demo server. Select the Use HTBasic Runtime Server option in the HTBasic Adapter Configuration dialog box and specify the path and filename for HTBwin.exe.
How to Use This Example
Open the following ArraySubs.prg file, located in the <TestStand Public>\Examples\TestStand API\Accessing Arrays Using API\HTBasic directory, and review the following defined subroutines and the TestStand API calls used to get and set the TestStand local variables:
- Filllocalarray—Demonstrates how to use the TestStand API from HTBasic to populate an array stored in a TestStand local variable.
- Accessarray—Demonstrates how to use the TestStand API from HTBasic to read an array stored in a TestStand local variable and display a graph of the data.
- Fill2darray—Demonstrates how to use the TestStand API from HTBasic to populate a two-dimensional array stored in a TestStand local variable.
- Access2darray—Demonstrates how to use the TestStand API from HTBasic to read a two-dimensional array stored in a TestStand local variable.
- Fillstrarray—Demonstrates how to use the TestStand API from HTBasic to populate a string array stored in a TestStand local variable.
- Accessstrarray—Demonstrates how to use the TestStand API from HTBasic to read a string array stored in a TestStand local variable.
Complete the following steps to review how TestStand calls the subroutines in the HTBasic PRG file and review the created local variables.
- Open the AccessingArrays.seq example sequence file. On the Variables pane, the NumericArray, TwoDimArray, and StrArray local variables have been created, but do not contain any data.
- On the Steps pane, select an Action step.
- On the Step Settings pane, review the settings for the Action step. The step does not pass local variables to or return local variables from the subroutine.
- Select Execute»Single Pass to run the sequence. Use the TestStand debugging tools such as breakpoints, the Variables pane, and the Watch View pane to monitor the local variables and verify that the HTBasic subroutines populate the panes with data.