LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Panel control by several files

Solved!
Go to solution

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 !

0 Kudos
Message 1 of 11
(3,808 Views)

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

0 Kudos
Message 2 of 11
(3,802 Views)

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..

0 Kudos
Message 3 of 11
(3,795 Views)

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 😉

0 Kudos
Message 4 of 11
(3,787 Views)

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..

0 Kudos
Message 5 of 11
(3,781 Views)

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 ?

0 Kudos
Message 6 of 11
(3,777 Views)

Ok, I tried, but then I got the error "Panel, pop-up, or menu bar handle is invalid" 😕

0 Kudos
Message 7 of 11
(3,770 Views)
Solution
Accepted by topic author emilie_grd

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.

Message 8 of 11
(3,766 Views)

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 !!

0 Kudos
Message 9 of 11
(3,762 Views)

Smiley Happy

I am glad I could help!

0 Kudos
Message 10 of 11
(3,759 Views)