Temporary Global Variables


#1

I’ve read how the SNAP controller (R2 in my case) parallels charts using 1 ms time slicing. It gives each chart 1 ms of processing time in turn (e.g. Chart1 gets 1 ms, then Chart2, then Chart3, etc. then back to Chart1). It was described as a round-robin approach. Does this mean I shouldn’t write to the same variable in more than one chart because they may be writing over each other? For example, a generic loop variable “i” or some other temporary variable.

Thanks
Joey


#2

Hi Joey,

Welcome to the OptoForums!

You are correct, with the exception of those in subroutines, all your variables are global (and should be re-used with caution because of the reason you mentioned).

Here’s [B]a thread on naming conventions[/B] you might want to read. Some people like to start the names of their variables with an indication of the chart they’re used in.

Whatever conventions you choose, I’d recommend against using a variable name like “i” – especially if you ever use OptoScript, because if you want to search for “i” in an OptoScript, that could get icky.

You get 50 characters to name your variables – go crazy! Or, at least, be descriptive. :slight_smile:

-OptoMary