LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

strtol NON-FATAL RUN-TIME ERROR (errno == 34 [0x22]). (ERANGE) Range error

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;
}

0 Kudos
Message 11 of 14
(1,668 Views)

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?

0 Kudos
Message 12 of 14
(1,665 Views)

The function is a callback from a simple dialogbox to get the FOST_FOSTSN using a textbox. There is no other interaction in between.

0 Kudos
Message 13 of 14
(1,614 Views)

Do you get the error no matter the number that is entered? Does the number 1 create this error as well?

0 Kudos
Message 14 of 14
(1,602 Views)