11-22-2009 04:06 PM
11-23-2009 03:39 AM
11-23-2009 04:11 AM
Thanks Roberto,Learning so much from you guys this is year of me being more libraries like never before and more functions
through last three years of coding.
11-25-2009 07:08 AM
Im checking to see if I handle the errorchecking right for the Ini_GetStringCopy ?A little assistance?
int Boresight_Command(double *dAZposX,double *dELposY)
{
int error=0;
char *sErrorMsg1=0;
char sAZposX[100]={0};
char sELposY[100]={0};
char sCrtCommand[256]={0};
char sDirPath[BUF_LEN_FOR_DIRECTORY];
IniText iIniTextHandle=0; // Handle for the text file.
char sPathName[BUF_LEN_FOR_DIRECTORY];
GetProjectDir(sDirPath);
MakePathname(sDirPath,KEY_TEXT_FILE,sPathName);
//Verify if there is enough memory
nullChk(iIniTextHandle=Ini_New (0));
//Verify if file exist on disk
error=FileExists(sPathName,0);
if(error<=VI_SUCCESS)
{
Terminate_Executable();
return FAILURE;
}
errChk(Ini_ReadFromFile (iIniTextHandle,sPathName));
errChk(Ini_GetStringCopy(iIniTextHandle,g_sOperatorID, "OperatorID", //////////////////////////////I wanted to do a error check , did I do it right?
g_sOperatorID));
errChk(Ini_GetDouble(iIniTextHandle,g_sSkrSerialNumberk,X_OFFSET_POS,
dAZposX));
errChk(Ini_GetDouble(iIniTextHandle,g_sSkrSerialNumberk,Y_OFFSET_POS,
dELposY));
Fmt(sAZposX,"%f",*dAZposX);
sprintf(sCrtCommand,"SERVO, WRITE, 098000034, %s",sAZposX);
Send_SERVO_Command(sCrtCommand);
Fmt(sELposY,"%f",*dELposY);
sprintf(sCrtCommand,"SERVO, WRITE, 098000038, %s",sELposY);
Send_SERVO_Command(sCrtCommand);
Error:
if(iIniTextHandle)
{
//Cleaning memory
Ini_Dispose (iIniTextHandle);
//Cleaning memory
free (g_sOperatorID);/////////////////////////////////// did i free in the right spot? im using the Ini_GetStringCopy
}
if(error < VI_SUCCESS)
{
sErrorMsg1 = GetGeneralErrorString (error);
MessagePopup ("ERROR", sErrorMsg1);
Terminate_Executable();
}
return error;
}
11-25-2009 07:17 AM
Sorry I left out my Casting of a pointer to pointer on my char variable in Ini_GetStringCopy
Im checking to see if I handle the errorchecking right for the Ini_GetStringCopy ?A little assistance?
int Boresight_Command(double *dAZposX,double *dELposY)
{
int error=0;
char *sErrorMsg1=0;
char sAZposX[100]={0};
char sELposY[100]={0};
char sCrtCommand[256]={0};
char sDirPath[BUF_LEN_FOR_DIRECTORY];
IniText iIniTextHandle=0; // Handle for the text file.
char sPathName[BUF_LEN_FOR_DIRECTORY];
GetProjectDir(sDirPath);
MakePathname(sDirPath,KEY_TEXT_FILE,sPathName);
//Verify if there is enough memory
nullChk(iIniTextHandle=Ini_New (0));
//Verify if file exist on disk
error=FileExists(sPathName,0);
if(error<=VI_SUCCESS)
{
Terminate_Executable();
return FAILURE;
}
errChk(Ini_ReadFromFile (iIniTextHandle,sPathName));
errChk(Ini_GetStringCopy(iIniTextHandle,g_sOperatorID, "OperatorID",
//////////////////////////////I wanted to do a error check , did I do
it right?
g_sOperatorID));
errChk(Ini_GetDouble(iIniTextHandle,g_sSkrSerialNumberk,X_OFFSET_POS,
dAZposX));
errChk(Ini_GetDouble(iIniTextHandle,g_sSkrSerialNumberk,Y_OFFSET_POS,
dELposY));
Fmt(sAZposX,"%f",*dAZposX);
sprintf(sCrtCommand,"SERVO, WRITE, 098000034, %s",sAZposX);
Send_SERVO_Command(sCrtCommand);
Fmt(sELposY,"%f",*dELposY);
sprintf(sCrtCommand,"SERVO, WRITE, 098000038, %s",sELposY);
Send_SERVO_Command(sCrtCommand);
Error:
if(iIniTextHandle)
{
//Cleaning memory
Ini_Dispose (iIniTextHandle);
//Cleaning memory
free (g_sOperatorID);/////////////////////////////////// did i free in the right spot? im using the Ini_GetStringCopy
}
if(error < VI_SUCCESS)
{
sErrorMsg1 = GetGeneralErrorString (error);
MessagePopup ("ERROR", sErrorMsg1);
Terminate_Executable();
}
return error;
}
11-25-2009 07:32 AM
Also guys while stepping through my code, i got non runtime fatal error from this
g_sOperatorID = calloc( BUF_LEN, sizeof(char) );////////
int Boresight_Command(double *dAZposX,double *dELposY)
{
int error=0;
char *sErrorMsg1=0;
char sAZposX[100]={0};
char sELposY[100]={0};
char sCrtCommand[256]={0};
char sDirPath[BUF_LEN_FOR_DIRECTORY];
IniText iIniTextHandle=0; // Handle for the text file.
char sPathName[BUF_LEN_FOR_DIRECTORY];
GetProjectDir(sDirPath);
MakePathname(sDirPath,KEY_TEXT_FILE,sPathName);
//Verify if there is enough memory
nullChk(iIniTextHandle=Ini_New (0));
//Verify if file exist on disk
error=FileExists(sPathName,0);
if(error<=VI_SUCCESS)
{
Terminate_Executable();
return FAILURE;
}
errChk(Ini_ReadFromFile (iIniTextHandle,sPathName));
errChk(Ini_GetStringCopy(iIniTextHandle,g_sOperatorID, "OperatorID",
(char**)g_sOperatorID));
g_sOperatorID = calloc( BUF_LEN, sizeof(char) );//////////////////////this is where i get the error
errChk(Ini_GetDouble(iIniTextHandle,g_sSkrSerialNumberk,X_OFFSET_POS,
dAZposX));
errChk(Ini_GetDouble(iIniTextHandle,g_sSkrSerialNumberk,Y_OFFSET_POS,
dELposY));
Fmt(sAZposX,"%f",*dAZposX);
sprintf(sCrtCommand,"SERVO, WRITE, 098000034, %s",sAZposX);
Send_SERVO_Command(sCrtCommand);
Fmt(sELposY,"%f",*dELposY);
sprintf(sCrtCommand,"SERVO, WRITE, 098000038, %s",sELposY);
Send_SERVO_Command(sCrtCommand);
Error:
if(iIniTextHandle)
{
//Cleaning memory
Ini_Dispose (iIniTextHandle);
//Cleaning memory
free (g_sOperatorID);
}
if(error < VI_SUCCESS)
{
sErrorMsg1 = GetGeneralErrorString (error);
MessagePopup ("ERROR", sErrorMsg1);
Terminate_Executable();
}
return error;
}
11-25-2009 07:33 AM
the error is 621, 53 Array assignments are illegal.
621, 53 Lvalue required.
11-25-2009 08:02 AM - edited 11-25-2009 08:03 AM
Well, a couple of things are not fully clear to me:
11-25-2009 08:14 AM
well the reason Im naming it as a global is because I want to remember where I am, Im using that global in many places through the source file
its define as g_sOperatorID[BUF_LEN];
11-25-2009 08:16 AM