06-03-2016 12:57 PM
I created a simple test application just like you did and I was not able to reproduce the problem. As I mention before, the behavior of strtol() is just unpredictable.
#include <userint.h>
#include "Fost.h"
static int panelHandle;
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "Fost.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
return 0;
}
int CVICALLBACK fostsncb (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int sn;
int ret = 0;
char str[16];
char *pEnd;
switch (event)
{
case EVENT_COMMIT:
SetWaitCursor(1);
GetCtrlVal(panelHandle, PANEL_FOSTSN, str);
sn = (int)strtol(str, &pEnd, 10);
SetCtrlVal(panelHandle, PANEL_RESULT, sn);
SetWaitCursor (0);
break;
}
return ret;
}
06-03-2016 01:49 PM
Does anything else in the program touch (especially modify or clear) the contents of FOST_FOSTSN?
Can you post any other code that might interact with the FOST_FOSTSN control?
06-09-2016 09:05 AM
The function is a callback from a simple dialogbox to get the FOST_FOSTSN using a textbox. There is no other interaction in between.
06-10-2016 09:00 AM
Do you get the error no matter the number that is entered? Does the number 1 create this error as well?