ONCHANGE function with String - Printable Version +- Ewon Technical Forum (https://techforum.ewon.biz) +-- Forum: Development (https://techforum.ewon.biz/forum-50.html) +--- Forum: BASIC Script (https://techforum.ewon.biz/forum-52.html) +--- Thread: ONCHANGE function with String (/thread-2567.html) |
ONCHANGE function with String - Jules - 09-09-2024 Hello everyone, I’m currently facing an issue when handling string data types in my program. I’ve created a function that prints the value of a tag when it changes. This function works correctly for other data types (integers, floats, etc.), but it encounters a problem when it comes to strings. Here’s the behavior observed with strings: When the tag value changes, the function prints the result twice, with about a one-second delay between the two prints. In the first case, it shows the old value, and then in the second print, the new value. Example: Tag PLC = TEST Change PLC tag to TEST10 The output is as follows: TEST TEST10 Tag PLC = TEST10 Change PLC tag to TEST102 The output is: TEST10 TEST102 The only case where the function runs just once is when the length of the new string is the same as the previous one. Problem: I don’t understand why the function prints the old value first before displaying the new one, and why this behavior doesn’t occur with other data types. Has anyone encountered this problem before, or does anyone have an idea of what could be causing this behavior with strings? Here is the code for the function. st.comment is a String PLC tag (Siemens). Code: Rem --- eWON start section: Init Section Thank you in advance for your help! |