02-05-2011 04:16 AM - edited 02-05-2011 04:23 AM
Hi ,
I'm working with CVI 9.1 for more then a year during this time i'v noticed a few things, i would like you to help me understand them.
2. Accessing buttons
Solved! Go to Solution.
02-05-2011 12:43 PM - edited 02-05-2011 12:45 PM
Wow! A very huge set of questions!
Some fast answer.
There is a basic error in your statement: the first parameter of SetCtrlVal ( ) must be the panel handle, that is the reference to the in-memory object that is created when you call LoadPanel ( ). Using the panel constant name is not correct: it may work if you're lucky and have the panel handle with the same value as its constant name, but it's definitely not the correct way to address controls on a panel.
Even though, I do not understand the error you are reporting: I would expect "the control is not the type expected by the function" or some error for inconsistent data type (like passing an int to a double control) or so...
Please remember that every function that addresses objects on a panel must be aware of the panel handle, so either you pass it to the function as a parameter or store it in a global variable.
I normally let CVI take care of #including the necessary system files: when I use some function like Fmt in a source file and compile it CVI warns me to add the relevant include file, and it does it properly. Operating this way I never had problems with the Formatting and I/O Library functions. You could rebuild the include list by deleting all #includes in yous source files and compiling the project, this should fix the errors
You must include the files with function definitions in all source files that are using them. Or you can create a general include file with all includes in your project and include only this one in all of your source files
This is a general rule that drives CVI environment: when executing a loop inside a function (either a control callback or another function) the system is not handling UI events, so your buttons appear locked. This can be solved by adding a repetitive call to ProcessSystemEvents ( ) inside your loop: this way all UI events are monitored and handled by the system.
You must use this method with care: before entering the loop you should disable all controls that are not to be used during the function (normally only the Quit button must be left active) otherwise you could enter a situation in which other callbacks are executed during the loop that may interfere with it.
In such a case, to avoid setting a callback in stop button and the use of a global variable I normally create a toggle Stop button and handle it this way:
while (1) {
....
ProcessStemsEvents ( );
GetCtrlVal (panelHandle, PANEL_STOP, &stop);
if (stop) {
... exit gracefully from the function
break;
}
}
This argument has been discussed several times in the forums: making a search for ProcessSystemEvents returns a large set of discussions that you may want to read
CVI does not have a native boolean value. I normally use an int and test wether it is zero or not
I don't understand what you are describing: could you add some piece of code that enters this situation and report the exact message the compiler is warning?
02-07-2011 12:23 AM
Thank you Roberto for you answers I know it was a big post 🙂 ,
About my last question , I think i know the answer one of your previous answers helped me understand...
Thank you again for the quick answer.