Programmatically Changing a Knob's or Slide's Text Labels and Values to Non-Sequential Values

Updated Mar 15, 2018

Reported In

Software

  • LabVIEW

Issue Details

I would like to change the text labels and values of a knob or scale. I know at development time I can right-click on the knob, choose Properties, and choose the Text Labels tab. There, I can set the text labels and values to sequential or non-sequential values. 
 

How do I achieve this programmatically? There is a property called Text Labels, but that only lets me set the text labels.

Solution

In order to accomplish non-sequential values for text labels, you will not be able to use the Text Labels property node. Instead you will have to follow the steps below:

    • Place a knob or slide on the front panel, right-click it, and select Properties.
    • Select the Text Labels tab and place a check mark next to Use text labels for scale markers.
    • Create a property node for the knob or scale. To do this right-click on the knob and go to Create»Property Node»Digital Displays[]. This returns an array of digital display references.
    • Place a Type Cast function on the block diagram. It can be found in Functions»Mathematics»Numeric»Data Manipulation»Type Cast.
    • Place an array constant on the block diagram. It is located under Functions»Programming»Array»Array Constant.
    • Create a class specifier constant found under Functions»Programming»Application Control»Class Specifier Constant.  Change it to a ring control reference by clicking on it and choosing Generic»GObject»Control»Numeric»NamedNumeric»Ring.
    • Drag the Ring Reference into the array constant. 
    • Wire the output of DigDisps[] to the input of the type cast function. 
    • Wire the array of ring control references to the Type terminal of the type cast function.
    • Place an index array function, found in Functions»Programming»Array»Index Array, and wire in the Output of type cast to the array terminal. Also wire a numeric constant with the value 0 to the Index terminal.
    • Create a property node from the output of the Index Array by right-clicking on the Outputterminal and selecting Create»Property»StringsAndValues[]. Make sure the Output of index array is wired to the reference terminal of the property node.
    • Right-click on the property node and select Change to Write.
    • Wire in an array containing a cluster with a string and a numeric into the StringsAndValues[]property node. The array will determine the marker text and values for the knob or slide.
    • The screenshot below illustrates how to change a knob's values and labels programmatically.

    WAS THIS ARTICLE HELPFUL?

    Not Helpful