NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use GetValStringByOffset?

HI,
 
I'm tyring to use the function GetValStringByOffset from CVI....
 
It seems like the function I need but, were is the lookup string?
 
What I'm trying to do is to get an element of array from TestSTand.
 
Example.   the 3rd element of FileGlobal.myAarray  (Array of 10 strings)
Can you show me how to do it?
 
Thanks
 
0 Kudos
Message 1 of 2
(3,044 Views)

Hi Rafi,

 

Here is some code to get your element of the string array.

#include "stdtst.h"
#include "tsutil.h"

void __declspec(dllexport) GetStringFromArray(CAObjHandle propertyObject, char returnString[1024], short *errorOccurred, long *errorCode, char errorMsg[1024])
{
    int error = 0;
    ErrMsg errMsg = {"Error with GtValStringByOffset"};
    ERRORINFO errorInfo;
    //char *lastUserName = NULL;
 char *str=NULL;
 
    // INSERT YOUR SPECIFIC TEST CODE HERE

    // The following code shows how to access a property or variable via the TestStand ActiveX API
    tsErrChk (TS_PropertyGetValStringByOffset (propertyObject, &errorInfo, 3, 0,
                                 &str));

 
 strcpy(returnString, str);

Error: 
    // FREE RESOURCES
    // if (lastUserName != NULL)
//    CA_FreeMemory(str);

    // If an error occurred, set the error flag to cause a run-time error in TestStand.
    if (error < 0)
        {
         *errorOccurred = TRUE;
   
        // OPTIONALLY SET THE ERROR CODE AND STRING
        *errorCode = error;
        strcpy(errorMsg, errMsg);
        }
}

Added some attachments as well

Hope it helps

Regards

Ray Farmer

Regards
Ray Farmer
Download All
0 Kudos
Message 2 of 2
(3,038 Views)