Right way to use global variables?

1 view (last 30 days)
Anne
Anne on 6 Nov 2013
Ok, so I know that global variables are tricky and you better not use them. However, for my problem I think I do need them. I connect to a ni session and use a listener to display the data every 2 seconds. Simultaneously this data is written to a file. After about 10 seconds I want to create a new file to deposit the data to. This means that I need to know how many times the listener has been called. I use a global variable to count this, because I believe that the listener doesn't go back to the main file (if that is the right way to say it). So is this a good way to use global variables? Or is there another way? And what is the main concern of using global variables? (code does work by the way)

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!