02-25-2014 04:47 PM
What I want to do is subtract the incrementing constants in while loops 1&2. I've removed the meat of the code, as it would get in the way of the question. Basically, everytime a value is read (outside the case structure), iI want it to increment the 'number of times read'.The same happens in the second while loop (they're essentially independent of each other). I can't subtract them outside of the while loops because the code never leaves the loop. Could I use a global variable? Thanks for any replies.
Solved! Go to Solution.
02-25-2014 05:09 PM
First, a minor pet peeve of mine on terminology. Constants don't increment. 🙂
You may have taken away too much meat to get a clear understanding. Basically it looks like you have two independent counters and you want to calculate the difference between them.
A global variable would work. A functional global or action engine would be even better. How often are you going to be comparing counts? You'll need a third loop do the calculation and display the result.
02-25-2014 05:30 PM
Oh yeah of course haha.
Basically outside of the case structure is a VISA read, which reads a tag. This goes straight to the case structure. I want it to increment by 1, everytime the tag is read. Then to subtract one count from the other.
Would I need a third loop surrounding the two separate while loops?
I've added a bit more, hopefully it makes more sense.
02-26-2014 10:14 AM
You'll need to put in the globals or functional globals to make your counter values available outside of your acquisition loops.
You'll need a third loop in PARALLEL to do the subtraction of the values that you have in your globals.
You may also want to look into using Queues and Notifiers.
Another way to do this would be to pop a notifier each time you receive a tag and then have a processing loop that handles the received notifiers.
02-26-2014 12:01 PM
Thank you so much.
Used a parallel loop with global variables and it worked perfectly first time.