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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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.
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.
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?
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)
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.