GUI-O Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Read text file in to TA widget

    Scheduled Pinned Locked Moved
    Comments & Feedback
    2
    3
    202
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Sato
      last edited by Sato

      Hello,
      With this I create a widget of type TA

      mqttClient.publish(&In[0], "|TA UID:ta1 X:84 Y:26 W:30 H:43 VIS:1 BGC:#b4c5de FGC:#121212 SHE:1 FSZ:4.5 RAD:1.5 BSZ:10 CL:1\r\n");

      I have a file on SPIFFS, such as "/test.txt", to which I sometimes append a few lines of text.
      The question is, how can I read only the last 10 lines of the file to place it in the ta1 widget?

      With BSZ:10 I can show the last 10 lines in "ta1", but the file is read from the beginning, line by line to "ta1" and after all then only shows the last 10 lines.

      The reason for my question is that, as I use a GPRS modem, I would like to send as little data as possible via MQTT, in this case want send only the last 10 lines of the file.

      To solve this problem, I've written some workaround code, but it's not very elegant

      What could be the best solution to this?

      Regards

      K 1 Reply Last reply Reply Quote 0
      • K
        kl3m3n @Sato
        last edited by

        @Sato You currently cannot read the file from the back. This functionality can be added though. I will see what I can do with the next release.

        You can read individual lines with FAC:2 and FP: parameter (the last 10), but you need to know the number of lines in the file upfront...

        Best regards,
        kl3m3n

        S 1 Reply Last reply Reply Quote 0
        • S
          Sato @kl3m3n
          last edited by

          Hello @kl3m3n,

          The read how many lines exists in the files is no problem.
          Next week i will see how to handle it with FAC and FP

          Thank you
          Regards

          1 Reply Last reply Reply Quote 0
          • First post
            Last post