Length of string and Array of bytes

eaglealex
2025-04-01
2025-04-02
  • eaglealex - 2025-04-01

    Hello!

    I have tried read a file to the string variable. But I faced a problem - there is about 2800 bytes of information in file, but string have a limit 2393 bytes.
    I made two variables with same address (for automatic convertion) - string[3000] and array of bytes[1..3000]. And I noticed that array of bytes contains all information from file, but string shows only first 2393 bytes. So I have lost information.
    Is there really such a limitation? Or I have an error in my program and Codesys 2.3 have no limit for such kind of conversation between string and array of bytes?

    Thank you very much!

     

    Last edit: eaglealex 2025-04-01
  • Ton - 2025-04-01

    When you use a string value 0 will be the end terminator.
    Everything after this will not be in the string.
    I guess byte 2394 has a value 0.

     
    • eaglealex - 2025-04-02

      Thank you for your answer!

      I know that 0 will be the end of the string. I checked it. There is no 0 in array of bytes.
      I made screenshots. There is array of bytes, aborted string and the result of my test via online converter.

       
  • eaglealex - 2025-04-02

    Browser's bug... Sorry

     

    Last edit: eaglealex 2025-04-02

Log in to post a comment.