Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Modifying textlist entries during runtime?

2020-01-13
2020-01-19
  • jeffersonhui - 2020-01-13

    Is it possible to modify a entries in a textlist while an application is running? For example, I would like to be able to open an on-screen keyboard and have the user be able to type in string and overwrite a textlist entry with that new string. Then, I'd like that new string to show up in dropdown lists.

    Thanks.

     
  • e.kislov - 2020-01-14

    It's possible. Textlists are downloaded to plc as common .txt files (in /PlcLogic/Visu folder).

    You can edit it in your program (with libs SysFile, CAA File, etc.) and you should use function DynamicTextReloadTexts from СmpDynamicText library to "refresh" texts in application.

    IMG: 14

     
  • jeffersonhui - 2020-01-14

    Thank you! Modifying the text list works!

    However, I am having another issue. When I try to use SysFile functions (currently SysFileRead) to read a .txt file generated from a text list, the string that I get back doesn't seem to be standard letters. Is the format of the .txt file "normal"?

    I attached a screenshot as well.

    IMG: readtext.png

     
  • jeffersonhui - 2020-01-14

    Also, when I use the "nano" command to read the txt file, I get "^@" in between every letter, and an ^M^@ at the end of every line. Attached is a screenshot. Is there something odd about the .txt file that is generated by Codesys?

    IMG: nanoReadText.png

     
  • i-campbell

    i-campbell - 2020-01-14

    Interesting. When the first two characters of a text file are ÿþ, that is a notice to the text editor that it is a UTF-16 LE encoded file (is unicode). More details on Wikipedia.

    https://en.m.wikipedia.org/wiki/Byte_order_mark

    The ^@ character represents the byte 00 or null. This is to be expected, as a unicode UTF-16 LE uppercase letter 'I' is '49 00' in hex.

    nano is a simple text editor, hence its name. It cannot handle BOM nor UTF-16. Maybe use a different text editor like vim (I am no

    What is also interesting, is that your sysfileread is giving you only the first three bytes in your string. If you know a bit about the storage format of CODESYS Strings, you will know that the first byte of the memory location is the first character. The end of the string is either the whole string size, or the first NULL character (hex 00). So of course the letter I (49 00) contains a NULL, and so locates the end of your string.

    Try with a WSTRING, which is UTF-16 already. (not sure LE or BE, or worse if it is processor dependant) (you might have to write code to delete the BOM character, if present)

     
  • jeffersonhui - 2020-01-19

    I figured it out! I had "use unicode settings" checked in the visualization manager, so codesys was writing all of the textlist .txt files in unicode format, which would have be useful if I had different languages. I unchecked the unicode settings box and the txt file was fine.

     

Log in to post a comment.