New, help with basic scripting

I am new with Ignition, and had a couple of questions:

  1. I have a text field. It gets inputed with a string after scanning a barcode. Is there a way that when the text field gets entered, it will be written to an event script, but then gets resetted so I would not have to mouseover the text before inserting a new barcode.

Basically I will take each barcode. When it comes in, I will tabulate information on the barcodes that were scanned until information is resetted.

  1. Will I need to use event handlers, or an event script (client) or both?

Thanks in advance

If I understand your scenario correctly, I think a tag change timer script would be the way to go. For more information about timer scripts and tag change scripts: … ripts2.htm … cripts.htm

I wouldnt think time delays would do it though.

I want a change which depends on clicking on the text field. I think that is a mouseclick event change. So, I scan my barcode, and its ASCII equivalent is inputted into the text field. Everytime a value goes into my text field, I will determine through its first symbol whether it will belong in 1 of 6 groups (I have easy if statements that can do that). There is also an accumulator that will show on the same HMI screen. For example, an employee badge reader: one barcode is $1234, and another is $4567, I will show on the HMI that (2) barcodes are from employees from the same group.

On screen, one has to mouseclick over it and get the string highlighted before I could put a new barcode scan into the text field.

My first question is how to clear the text field screen after a barcode is scanned?
Then when it is scanned, what type of script I have to make to tabulate everything. I have a code to tabulate the amount of employees, but just need to know where to write it.

Thanks in advance

Sorry about that, that was a mistake about mentioning timer scripts, timer scripts and tag change scripts are mutually exclusive. I guess I’m unclear about why the highlighting, or even the text box is needed though. A client tag change script could increment the value of a component each time an OPC tag was changed, or if you really needed that text box, it could increment the accumulator and then clear out that text box, or am I misunderstanding? :confused:

I thought a text box was needed because I want the user to see the ASCII string once it is scanned on the screen. Once scanned, an accumulator would increment.
Then, the text box would clear so another scan could come in.

Oh ok, how long do you want that ASCII string to stay in the text box? I’m thinking that by the time the text box is updated with a new value, the tag change script will clear the text box almost instantaneously. But if you want it to stay on the screen for a couple seconds, you could enable a timer component that after x seconds would clear the box.

To ensure all of this works correctly, you’ll want to bind a text box to the OPC tag (and turn bidirectional off), that way you could remove the data from the text box by highlighting and deleting the text, or clear out the text box via scripting. Turning bidirectional off will ensure that you don’t try to write back an empty string to the device, unless you want that functionality.

I would like a timer for 2 seconds. Yes, without a timer, it clears instantaneously.

All of your help is greatly appreciated and is helping.

You can do this by adding a timer component to the window, and setting its bound to 3. The functionality is that you want the timer to count to 2, clear the text box, and then reset itself. You can put this script on the propertyChange event handler of the timer:

if event.propertyName == "value": if event.newValue == 2: event.source.parent.getComponent("Text Field").text = "" event.source.running = False event.source.value = 0

Your tag change script would enable this timer (by setting running = True), and the timer would clear the box, and then reset. Remember that you have to use a client tag change script, since the scope of the gateway tag change script won’t allow it to access components on windows.