Loginskip to content

January 7th, 2007

Compiler optimizations in NXT-G

Having published my “Template VI Library Block” I received an email from NI, explaining how a similar code optimization can be done in a more “regular” fashion:

Consider a program/block diagram which has a “switch” (i.e. a case structure) and each case performs a different task. The compiler decides whether to include in the final program all case diagrams if, and only if, the case structure selection input is connected to a control and this control is wired to a terminal in the Implementation VI connector pane (and thus will have a drawer terminal in the NXT-G IDE).

One the other hand, if you wire a constant to the case structure selection input, or wire a control which is not connected to a connector (and thus not accessible in NXT-G drawer) - the compiler will add only the relevant piece of code into the final program file.

Having published this, I still find my block useful as it makes adding functions easier, and automatically shows the the right description in the control panel.