03-16-2010 03:39 PM
03-16-2010 03:46 PM
kristofparedis wrote:
And why/where exactly do I want to destroy the semaphore. Because I need it as long as my program is running... so I don't see a reason to destroy it... cause I have to initialize a new one then...
Thats kind of like leaving the front door open when you come home because you "intend to go to work again tomarrow anyway." Open-close it, Create it-destroy it, are good code practices and help your code be more self-contained. You don't allways want to rely on an OS garbage collection to clean up for you.
03-16-2010 03:52 PM
ok, makes sense.
Thanks Jeff.
Now concerning my initial question. Say that I do need to work with a local for my reference. Is there any way to work around the issue, e.g. is there a way to switch off the reinitialization for the locals, or to put the correct value back in (by recreating a new semaphore), so that my program can continue? Because I guess that the value of the local gets deleted and the acquire function gives an error because it can't read the local any more... right?
Kristof
03-16-2010 04:05 PM
kristofparedis wrote:ok, makes sense.
Thanks Jeff.
Because I guess that the value of the local gets deleted and the acquire function gives an error because it can't read the local any more... right?
Correct
Kristof
Now concerning my initial question. Say that I do need to work with a local for my reference.
You NEVER have to work with a local variable (OK I have used them but, very rarely)
there is a community nugget on FG's and AEs that Ben wrote. It will give you an idea how you can store that semaphore in a sub-vi and access it from anywhere. Wires would be the "prefered" method of passing the referance to the data though.
03-16-2010 04:20 PM
Thank you,
One more thing on your last comment: you never have to use locals and then I consider my case solved 🙂
I was trying to see whether I could get rid of all my locals in my program, but say I have 3 for loops in a sequence, each generating a certain amount of data, one after the other. In my current program, I write everything I collect into a local and with a seperate while loop I pick-up the data and plot them continuously. How do you managae this without a local (since the for loop only passes it data to the next when it is finished). So i can basically only plot in 3 steps all the data from one loop at a time, instead of point by point.
Kristof
03-16-2010 05:06 PM