Highlighting Mod Params

Here's a little twist to something I had been doing in order to get parameters passed to modules to correctly high light and auotcomplete.
Module header:
Less chance of the #DEFINE getting deleted elsewhere in the code causing these to become valid definitions. Plus I used to actually do the complete definition dev = 5001:0:0 but there's really no point since I only want the auto complete and highlighting. I can use the same #DEFINE without the compiler yelling at me that DEFINE_MODULE_PARAMETERS is already defined.
Now everything will auto complete and highlight in the correct colors set in preferences and the chance I me screwing things up down the road are minimized.
edit:
Actually now that I think about it I never did anything for modules and used the #DEFINE "SOMETHING" in the main and the matching #IF_NOT... for highlighting and auto-complete in my includes which used to get screwed up if I inadvertantly removed the #DEFINE.
Module header:
MODULE_NAME='VAV_LGTV_Mod,Rev1'(DEV vTVcomm,DEV dvTV,INTEGER nInstance,INTEGER nSerial,CHAR cIP[],INTEGER nTVs_DeBug)Now to get the devices to high light and autocomplete I use compiler directives but the twist is doing it all locally where needed whereas I used to do it the #DEFINE "SOMETHING" in the main code where these device were actually defined but that's too much of a pain to track and could cause problems it the #DEFINE "SOMETHING" was ever removed since I would never remember all the locations I might have the #IF_NOT_DEFINED. So now I just do this only inside the module:
DEFINE_DEVICE //#DEFINE DEFINE_MODULE_PARAMETERS //THIS JUST ALLOWS HIGHLIGHTING & AUTOCOMPLETE ITEMS PASSED IN THE HEADER #DEFINE DEFINE_MODULE_PARAMETERS #IF_NOT_DEFINED DEFINE_MODULE_PARAMETERS vTVcomm dvTV #END_IFfor devices and
DEFINE_VARIABLE //MODULE HEADER PARAMETERS //THIS JUST ALLOWS HIGHLIGHTING & AUTOCOMPLETE ITEMS PASSED IN THE HEADER #DEFINE DEFINE_MODULE_PARAMETERS #IF_NOT_DEFINED DEFINE_MODULE_PARAMETERS nInstance nSerial cIP nTVs_DeBug #END_IFfor vars.
Less chance of the #DEFINE getting deleted elsewhere in the code causing these to become valid definitions. Plus I used to actually do the complete definition dev = 5001:0:0 but there's really no point since I only want the auto complete and highlighting. I can use the same #DEFINE without the compiler yelling at me that DEFINE_MODULE_PARAMETERS is already defined.
Now everything will auto complete and highlight in the correct colors set in preferences and the chance I me screwing things up down the road are minimized.
edit:
Actually now that I think about it I never did anything for modules and used the #DEFINE "SOMETHING" in the main and the matching #IF_NOT... for highlighting and auto-complete in my includes which used to get screwed up if I inadvertantly removed the #DEFINE.
0
Comments
I use the same strategy for modules too.
I like having everything in a single block of code so it is easy to copy paste.
it can be done with one fewer compiler directive too
at least as long as no one ever comes along and defines DONOTDEFINETHISVALUE
I'm going to start doing this for my modules as well.
What comes after the define_device? The ellipsis indicates something should follow, but I'm not sure what.
It might not look that clean, but it probably works just as well, right?
Because then you would be re-defining the module parameters. I'm not sure that it would even compile.
The pre-compiler directive "tricks" the IDE into highlighting the devices and variables as if they were defined right there even though the defines never even make it into the compiled code.
true, silly me
I see your optimization and raise you foolproof! I suggest using #IF_NOT_DEFINED with a built-in variable that will always be defined:
__NETLINX__ is the first line of code in NetLinx.axi so it's always defined. If it's not defined, your code ain't running anyway.
well played sir
lol, I always forget Netlinx.axi is there. At some point I should poke around and see what's in there again.
-Ryan