05-18-2015 10:08 AM
Hello,
I am creating a CVI interface that runs a Teststand sequence. I want to set/get variables from the StationGlobals of Teststand. I use this code to get a string:
if (TSTD_GetStationGlobalsString(ERR_RETURN_PTR, "TS.LastUserName", &result) < 0)
printf("fail\n");
else
printf("%s\n",result);
and the function TSTD_GetStationGlobalsString is as below:
int TSTD_GetStationGlobalsString( ERR_RETURN_DECLARATION, char* lookupString, char** pString )
{
int error = NO_TB_ERROR;
ERRORINFO errorInfo;
char* pTempString;
ERR_RETURN_INIT_NO_ERROR;
errChk (TS_PropertyGetValString (gStationGlobalsHandle, &errorInfo, lookupString, 0, &pTempString));
*pString = malloc(strlen(pTempString)+1);
strcpy(*pString, pTempString);
Error:
if (pTempString != NULL)
{
CA_FreeMemory(pTempString);
}
if (error != 0)
{
strcpy(*pString, "");
return -1;
}
else
{
return NO_TB_ERROR ;
}
}
this is working, howerver when I want to access another variable diffrent from TS it doesn't. Can someone help me please.
Thank you.
Solved! Go to Solution.
05-18-2015 10:39 AM
What are you using as your lookup string? If I have a StationGlobal called Foo then I need to pass just "Foo" as my lookup string.
Also, make sure the the StationGlobal exists or it won't work. You can either use the PropertyExist method or use the InsertIfMissing flag (0x1).
Regards,
05-19-2015 02:05 AM - edited 05-19-2015 02:35 AM
Hello,
Thank you for your help, I use "toto" as a lookup string, it's a string variable that I have added to the sequence. I have also checked the StationGlobal handle while debugging and it is not NULL. but it looks like it only has the defalut variables.
Edit: I actually cheked the station global using PropertyExist method and it returns True.
Thank you
05-19-2015 02:41 AM
Sorry
PropertyExist method returns False.
Thank you
05-19-2015 07:02 AM - edited 05-19-2015 07:03 AM
Hello,
Problem solved, I only had to restart Teststand to save the new Sation Global ^^'
Thanks
05-19-2015 08:48 AM
Glad you figured it out!