> So in view that Labview is now coded in C++ it seems that using 'constants'
> is a better method.
> I guess the rules change as we climb the ladder.

Yes, C++ programmers today will typically frown on #defines for the 
reasons you mentioned, but that has little to do with why they aren't in 
LV.  LV doesn't have #defines because it didn't start out as a 60s era 
textual language. LV doesn't have a while and a do while, a goto, a 
break, a continue, or even an if statement.  It doesn't have these 
because the designers wanted to keep the language simpler.  Making a VI 
call to get your constant won't be that bad, especially if you don't put 
it in your loops.  You can also concentrate multiple ones into a single 
VI using either multiple outputs or an input selector.  At the moment, 
this will not be inlined by the LV compiler, but it will be fast, 
correct, highly readable, and easy to modify the constants throughout 
the program.

When your C programmer friends start to snicker and talk about 
efficiency, select some code and make a subVI from selection.  Or start 
explaining how LV has dynamic arrays and loop autoindexing.  It will 
usually send them away.

Greg McKaskle


  • #define William Rance
    • Greg McKaskle

Reply via email to