06-15-2018 02:33 PM
Hello community,
I have four panels on one .uir file and was adding more content, until CVI got out of memory. I searched for solutions and found that I may need to split my content on different .uir files. I did it, but the buttons, gauges, etc that I took away aren't recognized on my main code. I get the next error: use of undeclared identifier
How do I call the new .uir file?
Thanks in advance
Solved! Go to Solution.
06-15-2018 03:14 PM
Hi Lamb25,
A few questions:
1.) Was there a specific message you received when you the CVI "got out of memory"? Like a code of some sort?
2.) Was there an error code for the undeclared identifier?
You should be able to call the panel through the following functions:
static int panelHandle;
int main()
{
// Change the panelHandle to whatever handle you would like.
// Match the name of .uir file to the one that contains your uir file.
// PANEL swapped to the constant name used to identify your panel.
if ((panelHandle = LoadPanel (0 , "sample.uir", PANEL)) < 0)
return -1;
DisplayPanel(panelHandle);
RunUserInterface();
DiscardPanel(panelHandle);
return 0;
}
If I am not mistaken, it is likely that the controls when you moved them to a different panel or different .uir's that their constant name changed. You can find out what the new name is in the main project's header file.
Regards,
Vincent
06-15-2018 03:45 PM - edited 06-15-2018 03:46 PM
Of course you need to add the include files for the new UIR files to your code; and pass the correct file name in LoadPanel call.
And you may want to add the UIR files itself to the project: it's not mandatory but it helps getting things clear.
06-15-2018 04:21 PM
Hello community,
Thanks Vincent and Roberto, both answers helped me.
The solucion was: #include "GAUGES.h"
I call this panel with the button "GAUGES" and in the button call back the next code worked:
//==============================================================================
// SEND MESSAGES TO THE GAUGES (BTN_GAUGES: GAUGES)
int CVICALLBACK sendGAUGES (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_LEFT_CLICK:
int error = 0;
/* initialize and load resources */
errChk (panelGAUGES = LoadPanel (0, "GAUGES.uir", PANEL_GAUG));
/* display the panel and run the user interface */
errChk (DisplayPanel (panelGAUGES));
errChk (RunUserInterface ());
SEND_STRING(CS);
SEND_STRING(SN);
turnOffAllTelltales();
Error:
/* clean up */
if (panelGAUGES > 0)
QuitUserInterface (0);
break;
}
return 0;
}
06-15-2018 04:33 PM - edited 06-15-2018 04:34 PM
Glad to hear that.
Just as a side note, if you aready running the program with RunUserInterface (as you are for sure, otherwise the button callback wouldn't fire), you shouldn't call it again: it is unnecessary and can mess thing up.