NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

TS_PropertyGetValString

I am trying to access some variables in Test Stand through a Dll written using CVI.  When I include the tsErrChk function I get an error stating "108 Undefined label 'Error'.  I don't understand why?  When I remove the tsErrChk function the code compiles.  However when I get to this point in the project I get a System Level Exception.  I need to find out why I get this error so I included the tsErrChk func. to help.  Any suggestions?? 
 
  int      error = 0;
  ERRORINFO    errorInfo;
  ErrMsg   errMsg = {'\0'};
    
    int flag = 0;
    char *stringVal = NULL;
               
    tsErrChk (TS_PropertyGetValString(context, &errorInfo, "Locals.WxcTestParms.BootDevice", 0, &stringVal));
   strcpy(sysInfoStruct.BootDevice, stringVal);
0 Kudos
Message 1 of 4
(4,162 Views)
tsErrChk is a macro that looks like:

#define tsErrChk(fCall)\
\
if ((error = (fCall)) < 0) {\
    TS_GetOLEErrorMsg(error, &errorInfo, errMsg, 0, 0, ERRMSG_SIZE);\
    error = (error == DISP_E_EXCEPTION ? errorInfo.sCode : error);\
    if(error < 0) goto Error;\
} else


The compile problem you are having is because the macro has a goto statement in it.  You are missing the Error label that's required to use this macro.  Your function should be similar to this example:

void TX_TEST DLLEXPORT PowerOnTest(tTestData *testData, tTestError *testError)
{
    int measurement;
    int error = 0;
    ErrMsg errMsg = {'\0'};
    ERRORINFO errorInfo;
    VBOOL PowValue;
    tsErrChk(TS_PropertyGetValBoolean(testData->seqContextCVI, &errorInfo,
                                      "Locals.PowerFail", 0, &PowValue));
    measurement = 12 + (rand()%4);  /* value from 12 to 15 */

    if (PowValue)
        measurement += 4;  /* make sure the value is 16 or more */

    testData->measurement = measurement;
   
Error: 

    // If an error occurred, set the error flag to cause a run-time error in TestStand.
    if (error < 0)
        {
        testError->errorFlag = TRUE;
        testError->errorCode = error;
        testData->replaceStringFuncPtr(&testError->errorMessage, errMsg);
        }   
       
}

----
I am the founder of CnCSoftwareSolutions. When not cleaning up baby drool, I write about test data or work on Vision, a tool for understanding your test data. Visit me at www.cncsoftwaresolutions.com
0 Kudos
Message 2 of 4
(4,156 Views)

Here's the entire piece.  I don't understand what I am missiing???

int DLLEXPORT DLLSTDCALL ALVR_TS_GetBootParameters (int instrumentHandle, CAObjHandle context)
{
 
 int      error = 0;
 ERRORINFO    errorInfo;
    ErrMsg   errMsg = {'\0'};
    
    int flag = 0;
    char *stringVal = NULL;
               
    TS_PropertyGetValString(context, &errorInfo, "Locals.WxcTestParms.BootDevice", 0, &stringVal);
 strcpy(sysInfoStruct.BootDevice, stringVal);

0 Kudos
Message 3 of 4
(4,150 Views)

I got it...

 

Thanks

Needed the

Error: 
  
 CA_FreeMemory(stringVal);
 
 if (error < 0)
    {
  MessagePopup ("Error", errMsg);
  return TEST_FAIL;
 }
 else
     return TEST_PASS;

0 Kudos
Message 4 of 4
(4,145 Views)