Hungarian Notation Prefixes

I’m presently working through the SNAP-SCM-CAN2b CAN Bus integration guide. However, I am having a hard time comprehending what all the variable names mean. Is there a standard list of the different Hungarian Notation prefixes? Some are obvious (like ‘n’ to represent an integer or ‘nt’ to represent an integer table), but at other times it all degenerates into alphabet soup.

Is there a standard list Opto 22 uses?

Kind Regards
Bart

Hi Bart,

In theory, we’d stick to our own suggestions, as documented in the PAC Control User’s Guide, although I can see I don’t always do that (usually I use ch vs. cmh for comm handles, and sometimes preface global tag names with a chart-specific prefix):


You can see from [B]this discussion[/B] how naming conventions can be a matter of personal style.

You may also want to check out this document, form 2073, for more Best Practices and thoughts on naming conventions.

-OptoMary

Thanks for that info. I was looking for that info in the wrong guide.

Personally, I do not use ‘Hungarian’ prefixes as a rule unless there is some aspect about the variable’s function and semantics that cannot be inferred from its original type alone, or the prefix adds useful extra information. Of those that you showed, the most likely ones I would use would be the timer prefixes and perhaps the prefixes related to points and handles.

I guess that I am also used to strongly typed languages. On a slightly related note: will OptoScript eventually allow for local variables? It can be a pain not having them though on the other hand it does cut out a lot of bugs related to memory management.

Thanks, Bart

Hi Bart,

You can use subroutines if you’d like to have local variables. Just pass in the global parameters you need. Check out this post for more than you ever wanted to know about subroutines.

On naming those global variables–often I’ll use a prefix to my variables for a particular chart to avoid the problem of accidentally using a global in more than one chart at the same time.

For example, I’ve been writing a little strategy for some nifty cheap Belkin WeMo devices to control an outlet via WiFi with my smartphone using groov Server for Windows & SoftPAC (on my PC). Ditto some nifty wireless color-changing light bulbs (Philips hue). So all the variables in the WeMo chart look like: WEMO_nOnOff vs. the variables in the hue chart that have names like: HUE_nLightIndex.

Fun stuff!

-OptoMary