6.9.3 Exercise

This section gives an illustrative example of using a string value object. Settings may differ depending on your project’s configuration.

This section gives an illustrative example of using a string value object. Settings may differ depending on your project’s configuration.

Exercise: Showing a string value based on an analog value

In this example, a water tank will display its status using a string value object, which in turn changes based on an analog tag value. Strings may be defined and configured using the ‘String Editor’ tool.

※ Please refer to the String Editor section for more information.

a) Create a new analog tag and name it ‘VALUE’.

b) Go to [Tools] – [String Editor] to configure the contents of the string table. If you have not already done so, create a new group (0). Add the strings shown below to group 0.

  • When the ‘VALUE’ tag is equal to 0, “The water tank is empty.” will be displayed.

  • When the ‘VALUE’ tag is equal to 1, “The water has been stored in the tank.” will be displayed.

  • When the ‘VALUE’ tag is equal to 2, “The water tank is full.” will be displayed.

c) Select [Draw] – [String Value] and enter the tag name ‘VALUE’ in the ‘Tag’ field. Specify the string group as 0.

d) Select [Draw] – [Switch/Lamp] to create a word switch. Define the action as ‘Tag operation’ to increase the value of the ‘VALUE’ tag by 1 every time the switch is pressed.

e) Launch the project in Xpanel or the simulator. When you press the button, the tag value changes, causing a different string to be displayed.

No string will be displayed if there is no corresponding string with the analog tag’s value. In the example above, a string will only be displayed when ‘VALUE’ is equal to 0, 1, or 2.