How to clear an ASCII string using a macro

Introduction:

Within this tutorial, we demonstrate how to “clear” the content of an ASCII object using a macro.

Software Version:

EasyBuilder Pro 6.03.02.463+

Instructions:

The Macro

By using a macro similar to the one below, the user will be able to “clear” a string within HMI or PLC memory.
Note: The FILL() command is used to fill an array with a preset value, in this case:

  • Fill(blank[0], 0, 20): blank[0] is the array variable and the starting element in that array.

  • Fill(blank[0], 0, 20): 0 indicates that the array variable will be filled with null.
    Note: The ASCII code associated with 0 (dec) is null.

  • Fill(blank[0], 0, 20): 20 is the length of the char array and is equal to the number of characters that we wish to clear.

Then, the length of the array may be used within the “SetData” command:

  • SetData(blank[0], “Local HMI”, LW, 0, 20)

image

LW-0, within the macro above, is a memory address within the HMI that is assigned to the ASCII object in the image below:
image

Executing the Macro

In the example below, the macro will execute periodically:

In the example below, the macro will execute once when the HMI starts:

In the example below, the macro has been configured to execute when a Function Key is pressed:

In the example below, the macro will be executed when a Combo Button is pressed:

In the example below, the macro will be executed by an Action Trigger when the window opens: