03-23-2018 04:38 AM
Hi everybody !
I am a beginner in labWindows and I have met several problems
I would like to structure my project in order to have:
- a main file
- a file that gathers all the callback functions - Callbacks.c
- a file that handles the importation of configuration files - import.c
- a file that handles the exportation of results and configurations - export.c
- a file with functions that handles the display of parameters/values in the panels, those functions will be called by the Callback functions - Display.c
In parallel, I have a file Panels.h that gathers all the parameters of my panels
For now, I encountered a first problem:
I managed to display parameters in my panels when the code line "SetCtrlVal(panel, PANEL_NAME, project)" is written in the file Callbacks.c. However, if I move this instruction in a function of the Display.c file (function called by an other function of the Callback.c file), the display does not work.. Can I control my panels with several functions from several files or only with CVI CallBacks functions ?
Thank you in advance for your answers !
Solved! Go to Solution.
03-23-2018 04:48 AM
Yes you can 🙂
You need to include the function definitions in all your files that need it, i.e., add
#include <Display.h>
to callback.c
03-23-2018 04:58 AM
Thank you for your answer !
This is what I did but it seems not to work.. In which file should I load my panels ? I used the function "LoadPanel" in the main file but also in the Callback.c, I am not sure that it is really good..
03-23-2018 05:14 AM
you also need to make sure that your variables are unique and known, i.e., define your variables only once (not one definition of panel in both files...).
A more general suggestion: if you learn something new, e.g., C and/or CVI, start with something simple and gradually make it more complex...so why not start with all of your code in one file (possibly separated into sections), and once things work as expected you can split it into two, then three, ... files. Cut and paste is fast 😉
03-23-2018 07:00 AM
Ok I'll do that ! Should I load my panels in the main.c and include main.h in the other files to make them aware of the definition of the panels or is there a better way ?
Yes this is exactly what I am doing ! 😉 My project worked in one file, the splitting is creating problems..
03-23-2018 07:23 AM
this sounds reasonable 😉
@emilie_grd wrote:
Ok I'll do that ! Should I load my panels in the main.c and include main.h in the other files to make them aware of the definition of the panels or is there a better way ?
03-23-2018 07:41 AM
Ok, I tried, but then I got the error "Panel, pop-up, or menu bar handle is invalid" 😕
03-23-2018 07:47 AM
did you consider my earlier post: you also need to make sure that your variables are unique and known
so in main.c panel (etc.) has to be defined global, and in your other files you have to define it as extern.
03-23-2018 07:57 AM
Thank you so much !!!
I did defined them before as global variables but for a reason I can't explain I also defined them as static. I deleted the static and now everything is working, thank you !!
03-23-2018 08:16 AM
I am glad I could help!