I am trying to script a check box to find the correct text file using system.util.execute. I have two errors. Here is the code I have for the ‘property change’ event handler.
val = event.source.parent.getComponent(‘StationType_Lbl’).text
system.util.execute(‘C:\Printing Templates’’ + val + ‘.txt’)
If I don’t have the second ’ after Templates\ is throws the error ‘no viable alternate at input’ like it doesn’t close the end of the string.
The second is when I run the above code it gives this error:
Traceback (most recent call last):
File “event:propertyChange”, line 13, in
TypeError: execute(): 1st arg can’t be coerced to String[]
Thank you for the reply, the value of ‘val’ is the type of station the user is currently on. There is a corresponding text file with it in a folder, the text file has zebra printing language code in it (Model, newDate, Printer1IP are all variables inside the zpl code).
Here is the full script with your code input into it.
Count = 0
if event.source.selected is True:
Count = Count + 1
if event.source.parent.getComponent(‘PrinterAActive’).selected is True and event.source.selected is True:
if Count == 1:
Count = Count + 1
Model = event.source.parent.getComponent(‘Dropdown’).selectedStringValue
date = system.date.now()
newDate = system.date.format(date, “MM/dd/yyyy HH:mm:ss”)
Printer1IP = event.source.parent.getComponent(‘Printer1IP’).text
val = event.source.parent.getComponent(‘StationType_Lbl’).text
execute_string = “C:\Printing Templates%s.txt”%(val)
system.util.execute(execute_string)
if Count != 1:
Count = 0
event.source.selected = False