Defining Variable's in the Source Code?
Angelo_One
Posts: 9
I was informed by another programmer that best practices for defining a variable when creating Include files for devices is to define the variable's in the Source code. Is this method correct? Because when I define variable's in the Source Code and then use them in the Include file the variable text stays black and does not change color. But code still compiles and functions. Any help would be greatly appreciated. Thank you in advance!
0
Comments
Include files and module files handle highlighting exactly the same.
That being said, always define your variables with the least amount of scope needed. If you have a variable which is only being used within a function or event, define it in there then pass variables around using your function arguments. This will help you avoid action at a distance, make debugging easier and greatly improve your code reusability.
--
Also, as a side note the term "source code" is generally used to refer to all of your uncompiled code. This includes both your *.axs and *.axi files in NetLinx. If you are referring to the file that shows under "Source" in the NetLinx Studio workspace tree a better way to communicate it may be your *.axs file or master file. End semantics nazi rant.