From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-16-2011 07:11 AM
HI,
first of all: I'm relatively new to LabWindows, working on it during some practical work as a Student
(yeah, and sorry for the bad english, I'm from Germany)
To the Problem:
The first important Information:
After having searched for a solution, I just don't know, what to do,
My Project consists of ONE Main.uir-File with a Tab, a "Main.c" that basically handles the main .uir-Stuff and some Initiating-Stuff and in addition to that Several Sub-Sourc-Files, one for each Tab-Panel of the Main.uir-Tab.
To use the UI-Items on the Main-Tab with the Sub-Sources, I am initiating Tab-Handles at startup, that can be used by the SubSource-Files, like:
GetPanelHandleFromTabPage (PANEL, PANEL_TAB, 2, &BALU);
With this Handle, I can identify every UI-Items, when working with the SubSources
The second important information:
In some of the TabPages of the .uir there are several ControlArrays. To use them I create a ControlArrayHandle, like:
MWSAverageHandle = GetCtrlArrayFromResourceID (BALU, MWSAverageArray);
No, I am able to identify specific elements of the Arrays, like:
SetCtrlVal (BALU, GetCtrlArrayItem (MWSProgressHandle, ActiveBalun), ProgressString);
Now there is a Problem, I am not able to solve:
During runtime, everything works out fine, I can use every element of a ControlArray with this ControlArrayHandle ("MWSProgressHandle"), everything works perfect, no errors at all. BUT, when closing the programm, I get the following error-message:
NON-FATAL RUN-TIME ERROR: "Baluns.c", line 313, col 16, thread id 0x00000AB8:
Library function error (return value == -4 [0xfffffffc]). Panel, menu bar, or control array handle is invalid
But this seems somehow ridiulous to me, because at runtime every single line works perfect, every Array-Item can be used without Problems...
Is there anything I am just not able to see???
Thanks a lot for your help.
Greeting from Lübeck, Germany!
Mathias
Solved! Go to Solution.
03-16-2011 07:27 AM
Hi Mathias,
it might help to also tell us line 313 of your code, the one giving the error,
Wolfgang
03-16-2011 08:00 AM
ahh yeah, forgot that:
The lines that cause the errors, are like the following type:
SetCtrlVal (BALU, GetCtrlArrayItem (MWSProgressHandle, ActiveBalun), ProgressString);
and here, the error is caused specifically by:
GetCtrlArrayItem (MWSProgressHandle, ActiveBalun);
So when I am not "breaking" in debugging-mode but "continueing", the error will occurr in every line, that contains the GetCtrlArrayItem-function
03-16-2011 08:26 AM
Hi,
in your first message you wrote that you receive the error message when closing the program... do you discard any panel / control when shutting down your program? From your invalid panel error I would suspect that you first discard your panel and then attempt to use MWSProgressHandle...
03-16-2011 08:31 AM
You said that this happens when you want to close your application; it is uncommon that you want to populate a control while closing the app: may it happen that the handle and/or the control array have already been discarded when you reach this line of code?
Is this code in a callback function? In this case, which event are you handling in the moment of error?
Have you tried breaking the code and looking at the handle in the variable window or the watch window to see if it has the correct value?
03-16-2011 08:59 AM - edited 03-16-2011 09:01 AM
Maybe I just figured something out:
First of all, most of the Functions, that cause the Error, are in Timer-Callbacks (at this state of development, ALL of them)
So I just added a Test-Function in a normal Button-Callback, which contains a "GetCtrlArrayItem"-Function, and this specific Line does NOT cause an Error... (Or at least it does not occur in the Error-List, when clicking "continue" in debugging-mode). Somehow the Timer-Callbacks seem to be called, when closing the Application...
BUT: this happens when I don't do anything in the Application, and the all Timers are Disabled, until some Buttons are pushed (so when I close the application right after opening it, they still should be disabled)
@ Wolfgang:
After discarding I do not want to use one of the handles, or at least I'm not doing that purposely
@ Roberto:
Actually I am only discaring the MainPanel-Handle in the Main.uir (and one other Panel, but the error occurred before implementing that other panel). Do all Handles (PanelHandles as well as ControlArrayHandles, TabPageHandles and so on) need to be discarded?
And no, I did not check the Variable Window, I was not aware of this possibility, I will try to figure that out.
03-16-2011 09:18 AM
In your timer callback, do you check for ( event == EVENT_TIMER_TICK ) ? Callbacks might get called for various events, not just the one you have in mind...
03-16-2011 09:44 AM
yeah, well.... Thanks a lot!
I totally got used to, that CVI creates the switch-cases automatically, unfortunately it does not so with Timer-Callbacks, that solved it!!!
Thanks again!!! 🙂
03-16-2011 09:53 AM
You're welcome!
03-16-2011 10:33 AM
Mathias,
When CVI generates the callback function skeleton, it only generates the switch statement if, in your default event preferences, you have at least one event that is applicable to that type of control.
The way you select the default events is by clicking Code>>Preferences>>Default Events in the UI Editor window.
For timer controls, you should make sure that you have EVENT_TIMER_TICK selected: