Loginskip to content

Advanced NXT-G Block Techniques - Part II

news/
software/
NXT Repository/Programming/
NXT Repository/Tutorials/

In this post I’ll describe another useful trick for NXT-G Block programmers. Often it is convenient to have several actions in one block. For example, my Array Block has “read”, “write” and “create/resize” actions selectable from a dropdown list. However, not allways the same terminals are needed. In the above example, read and write mode need a “Position” input terminal, while create/resize mode requires a “Size” input terminal. Here I’ll describe how one can use a single terminal, and dynamically rename it when the action is changed.

There are two text strings that must be changed - the easier part is changing the Config VI front panel caption string from “Position:” to “Size:”. As once can see in the diagram above this is done by the middle propery node. However, one must take care that the caption text does not move when replacing the text. To do this, I read the caption left position before the change, and set it to the same value after the change.

The second change is a little more difficult - one would want the NXT-G user to see the correct “tooltip” (the yellow text appearing when you place the mouse above a terminal). This requires changing the caption of the Implementation VI control. I’ve written a special VI that changes the caption of a specific control/indicator (identified by a unique label). This VI, which is the yellow block in the above diagram, is available for download here. Use the Context Help (Ctrl-H) to see how to wire it in your code.