Problems doing SETSYS in an EWON Tag - OPERATION FAILED (28)

Hi,

I’ve created an script using the Cyclic Section of the BASIC IDE for my eWON Flexy, in order to change the email destinatary of several Tags depending on a value:

IF (Email@ = 10) THEN
SETSYS TAG, “LOAD”, “PI8”
SETSYS TAG, “ETO”, “mantenimiento@example.com
SETSYS TAG, “DoSetVal”,1
SETSYS TAG, “SAVE”
ELSE
IF (Email@ = 20) THEN
SETSYS TAG, “LOAD”, “PI8”
SETSYS TAG, “ETO”, “proceso@example.com
SETSYS TAG, “DoSetVal”,1
SETSYS TAG, “SAVE”
ELSE
IF (Email@ = 30) THEN
SETSYS TAG, “LOAD”, “PI8”
SETSYS TAG, “ETO”, “manager@example.com
SETSYS TAG, “DoSetVal”,1
SETSYS TAG, “SAVE”
ELSE
SETSYS TAG, “LOAD”, “PI8”
SETSYS TAG, “ETO”, “none”
SETSYS TAG, “DoSetVal”,1
SETSYS TAG, “SAVE”
ENDIF
ENDIF
ENDIF

It is quite simple, depending on the value of Email@ the “Email To” field of the PI8 Tag configuration changes.

The thing is: I’ve first tryied it with MEM Tags and iworked perfectly, but now I’m using EWON tags (that correspond to the project signals acquired with my ext… card FLX3402), and I get this error: OPERATION FAILED (28) SETSYS TAG, “SAVE”

It seems like the configuration of eWON Tags can’t be change, and what’s more, although I get the error on the line which corresponds to the value that is going to ve saved for the first tag, works on that one and only on that one! :S

Makes no sense to me that the tags can be configured or not wether they correspond to the internal memory or and acquisition card…

Thanks in advance! this is frustrating

@JHG

I just tested this script on my personal unit and had no issues making it work.

However the biggest thing here is remove that script from the cyclic section. We do not want that in the cyclic section. The cyclic section is extremely fast read/write and should only be used when absolutely necessary.

For your code, use an ONCHANGE listener to monitor the state of your Email tag and then call your if clauses when it changes.

Eg:

ONCHANGE "Email", "GOTO UpdateTags"

Then move your if/else clauses into a section called UpdateTags.

This will allow that script to only execute when needed instead of every cycle.

Thanks for the advice!

I finally discovered the problem: the thing was I was using “SETSYS TAG, “DoSetVal”,1” which allows to change the value of a tag, besides being unnecessary in this case, the eWON refused saving a value because the tag was asociated to an input, and inputs can’t be forced. Removing that line fixed the error.

I also found helpful your reply, now the code is working with ONCHANGE in an specific section instead executing the script every cycle.

Thanks again!