Highlighting Mod Params
vining
X Member
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.
Comments
-
Great twist, thank you for sharing
-
You can do the same thing in a single compiler directive by adding define_device, define_variable, etc into your if/else block. I use this in different includes (including system wide structures) and simply paste it at the top of every include file.
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.#DEFINE DEFINE_MODULE_PARAMETERS #IF_NOT_DEFINED DEFINE_MODULE_PARAMETERS define_device vTVcomm dvTV define_variable nInstance nSerial cIP nTVs_DeBug #END_IF
-
I started doing this in my modules recently after someone (maybe you vining?) mentioned it on the forums.
it can be done with one fewer compiler directive too
#if_defined DONOTDEFINETHISVALUE define_device... #end_if
at least as long as no one ever comes along and defines DONOTDEFINETHISVALUE
-
That's clever.
I'm going to start doing this for my modules as well. -
I started doing this in my modules recently after someone (maybe you vining?) mentioned it on the forums.
it can be done with one fewer compiler directive too
#if_defined DONOTDEFINETHISVALUE define_device... #end_if
at least as long as no one ever comes along and defines DONOTDEFINETHISVALUE
What comes after the define_device? The ellipsis indicates something should follow, but I'm not sure what. -
MODULE_NAME='Elk_M1_Ethernet_Comm'(DEV vdvELK, DEV dvELK, CHAR cELK_IP[]) #if_defined RELIGIOPOLITICS DEFINE_DEVICE vdvELK dvELK DEFINE_VARIABLE CHAR cELK_IP[1] #end_ifI added lines 2-8. They don't have any effect on the program but NS will do the syntax highlighting and autocomplete for the parameter variables that it otherwise would not have. -
Why would you use the #IF_DEFINED directive. and not just put the lines under DEFINE_DEVICE?
It might not look that clean, but it probably works just as well, right? -
Why would you use the #IF_DEFINED directive. and not just put the lines under DEFINE_DEVICE?
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. -
Bigsquatch wrote: »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 started doing this in my modules recently after someone (maybe you vining?) mentioned it on the forums.
it can be done with one fewer compiler directive too
#if_defined DONOTDEFINETHISVALUE define_device... #end_if
at least as long as no one ever comes along and defines DONOTDEFINETHISVALUE
I see your optimization and raise you foolproof! I suggest using #IF_NOT_DEFINED with a built-in variable that will always be defined:#IF_NOT_DEFINED __NETLINX__ ... code ... #END_IF
__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. -
nicholasjames wrote: »I see your optimization and raise you foolproof! I suggest using #IF_NOT_DEFINED with a built-in variable that will always be defined:
#IF_NOT_DEFINED __NETLINX__ ... code ... #END_IF
__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
Leave a Comment
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums