No viable alternative at input


I get an error ‘No viable alternative at input’. What does it mean and how can I fix it?

Thanks for help.

Jython is case-sensitive. “IF” should be “if”


Hi @grzegorz.kaczmarczyk, case matters. Use if not IF.

Edit: Beat me by a hair @Matrix_Engineering :stuck_out_tongue_winking_eye:


Thanks, it works!

You’re both getting hearts, but there can be only one solution :smiley:

1 Like

Now I am encountering a different problem.

I want to write ‘1000’ to a variable, when other variable is equal 1. The code I wrote doesn’t work. Nothing happens.

@grzegorz.kaczmarczyk, I believe system.tag.write() has been depreciated. You should either be using writeAsync or writeBlocking. Note the parameters for these are passed as lists.

.read has also been deprecated, but bear in mind it returns 3 values, you have to get the .value an example shown here:

but as you are on ignition 80/81 you should use the new functions system.tag.readBlocking - Ignition User Manual 8.0 - Ignition Documentation


Just to clarify a bit on what @Matrix_Engineering is saying. still works and returns a qualified value object, to get the value of the tag you have read you must use the .value property of the qualified value.

However, both @matthew.ayre and @Matrix_Engineering are correct, and system.tag.write() were depricated with Ignition 8.0.0. You should use the new functions as they have detailed.

Also, you should start now making a habit of only calling a tag read/write function as few times as possible. With that in mind your code should look something like this:

tagValues = system.tag.readBlocking(['[default]SQL/MP_ZMIENNA4','[default]PLC/Zmienna1'])

if tagValues[0].value == 1:

I’m assuming that this isn’t your entire script, otherwise it isn’t necessary to read Zmienna1 unless you plan to use that read value.

As an aside, you should use the preformatted text option </> or place three back ticks ``` before and after your code, there are some situations where screenshots are useful but when trying to assist with code it is much better to have something that is readable, we can copy and paste from, and that will keep your formatting.