05-24-2001 01:30 PM
05-25-2001 10:48 AM
05-25-2001 11:38 AM
10-10-2017 05:34 PM
I have a similar error:
LoadPanel, with the right parameters, returns zero.
The panel was generated in Labwindows 8 or 12, I am not sure, and debugging in 2017.
Renamed it, deleted it and copied back, neither helps.
Inserted the current pathname and replaced the uir file name. Nothing.
int mainH;
/****************************************************************************/
int main (int argc, char *argv[])
{ int status;
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if (mainH = LoadPanel (0, "hashing.uir", MAINPANEL) < 0) return -1;
//at this point mainH is 0. Why?
//The panel look fine, has all the callback functions, and the header file looks ok too.
DisplayPanel (mainH); //returns -4, because the panel handle is invalid
RunUserInterface ();
DiscardPanel (mainH);
return 0;
}
10-11-2017 03:05 PM - edited 10-11-2017 03:09 PM
if (mainH = LoadPanel (0, "hashing.uir", MAINPANEL) < 0) return -1;
This is an operator precedence problem: C evaluates "<" before "=".
So as written, this line will:
(1) Perform the LoadPanel call, which returns a positive number.
(2) Check whether the result is less than zero. Since it isn't, the comparison returns FALSE (a value of zero).
(3) Assign the result of the comparison (zero) to mainH.
(4) Skip the "return -1" call, since the line now reduces to "if (0) return -1".
To fix it, just add parentheses:
if ((mainH = LoadPanel (0, "hashing.uir", MAINPANEL)) < 0) return -1;