LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to remove the non-fatal run-time error display of My CVI programm?

pls see the attachment! it is my cvi programm. when i run it , the system tell me "the non-fatal run-time error". How to modify the programm to remove it?if i use "messagepopup", it is OK. But if i use "installpopup" ,it fail.
Download All
0 Kudos
Message 1 of 5
(4,128 Views)
I don't have access to my CVI on this machine, but I believe there is a setting in the project options that you can disable to stop this,

or,

You can progmatically disable the Run Time Error messages...

From NI's support pages:

"You can use the SetBreakOnProtectionErrors function to prevent LabWindows/CVI from displaying the dialog and suspending execution when it encounters a protection error. In general, it is better not to disable the "break on protection errors" feature (Options»Run Options»Break on Library Errors). Nevertheless, you may want to disable it temporarily around a line of code for which LabWindows/CVI is erroneously reporting a protection error."

Hope this helps,


Chris
0 Kudos
Message 2 of 5
(4,128 Views)
The problem is that your program is still running while the popup panel is visible. If your code reaches again (number > limit) it tries to install a second popup panel of your panel which cannot be done and which leads to this warning. Now it's up to you to define what your program should exactly do after it reached the point that number > limit. Should it display the message and stop until user pressed the OK Button? If yes, place a GetUserEvent call with the first parameter set to wait after your InstallPopup function. Your callback function should than look like:

int CVICALLBACK NumbercontrolCallback (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
double limit;
double number;
int phndl, ctrl;

switch
(event)
{
case EVENT_VAL_CHANGED:
GetCtrlVal (panelHandle, PANEL_NUMERCONTROL, &number);
SetCtrlVal (panelHandle, PANEL_NUMERICGAUGE, number);
GetCtrlVal (panelHandle, PANEL_LIMITCONTROL, &limit);
if(number>limit)
{
SetCtrlVal (panelHandle, PANEL_WARNINGLED, 1);
// Beep();
// MessagePopup ("Warning", "The number is up limit");
InstallPopup (panelHandle2);
GetUserEvent (1, &phndl, &ctrl);
}
//f(number else
{
SetCtrlVal (panelHandle, PANEL_WARNINGLED, 0);

}

break;
}
return 0;
}

If you do not want that your code waits you have to think about a programming structure which prevents from calling again InstallPopup while the first one is still active.

Regards,
Heinrich Illig
National Instruments
0 Kudos
Message 3 of 5
(4,128 Views)
The main problem is that InstallPopup doesn't cause your code to wait: it just installs and displays a modal dialog box. Normally, when a modal dialog box is active, you can't operate controls on any other panel. However, in your program, you install the popup while you're still operating a control on panel1. In that case, the popup panel doesn't take charge until you release the Number Control on panel1. If you continue to operate Number Control on panel1, you generate another EVENT_VAL_CHANGED. The popup panel is already installed, but, because InstallPopup doesn't cause your code to wait, you try to install the popup again. You can only have one instance of a popup installed at a time. (You can have more than one popup installed, but you can't install the same popup twice without first removing it).
The simple solution is to use GetUserEvent() to force your code to wait after you call InstallPopup. Look at the help in the function panel for GetUserEvent and try the following.
int nWaited4Control;
int nWaited4Panel;
int nWaited4Event;
SetCtrlVal (panelHandle, PANEL_WARNINGLED, 1);
InstallPopup (panelHandle2);
nWaited4Event = GetUserEvent (1, &nWaited4Panel, &nWaited4Control);
Here's a couple of other thing you may want to think about.
1. You can get into trouble using callbacks on a popup panel. In your simple example with a single popup, a callback is OK, but when you have a popup on a popup, events can be missed. To avoid using a callback on your popup, you can check the event in your code immediately after GetUserEvent, like this.
InstallPopup (panelHandle2);
nWaited4Event = GetUserEvent (1, &nWaited4Panel, &nWaited4Control);
if (nWaited4Event == EVENT_COMMIT && nWaited4Panel == panelHandle2 && nWaited4Control == WARN_OKBUTTON)
RemovePopup(0);
2. You might want to think about using EVENT_COMMIT instead of EVENT_VAL_CHANGED. EVENT_VAL_CHANGED occurs before EVENT_COMMIT. As you grab the knob of Number Control on panel1, and start to turn it, multiple EVENT_VAL_CHANGED's will occur. EVENT_COMMIT only occurs when you let go of the knob. Using EVENT_VAL_CHANGED can make it harder to adjust Number Control back below the limit because the popup panel keps popping up.
3. Do you want to allow the user to set Number Control above the limit? If not, you could use SetCtrlVal to set Number Control to the limit if the user tries to go over the limit. In your popup panel, you could also give the user options to override the limit or to increase the limit to the new setting. But the usability of these options gets back to whether you're using EVENT_VAL_CHANGED or EVENT_COMMIT.
0 Kudos
Message 4 of 5
(4,128 Views)
Ok... I guess I should have read your code before answering this one...

Please ignore the above... far too early in the morning for me...

Chris
0 Kudos
Message 5 of 5
(4,128 Views)