<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to reading string from file issue (more than 255 bytes)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/</id><updated>2023-08-02T06:24:25.159000Z</updated><subtitle>Recent posts to reading string from file issue (more than 255 bytes)</subtitle><entry><title>reading string from file issue (more than 255 bytes)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/?limit=25#2bce" rel="alternate"/><published>2023-08-02T06:24:25.159000Z</published><updated>2023-08-02T06:24:25.159000Z</updated><author><name>kishan</name><uri>https://forge.codesys.com/u/kishan/</uri></author><id>https://forge.codesys.com87e97feb71cde61c06fc062800cd54dad28fb620</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;i have same issue with string(8000000) when i using string utility it not extract all file.&lt;br/&gt;
in side txt file there is 67000 lines but after extracting using string utility i just get 3700 lines &lt;br/&gt;
is there any limits in string util lib.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>reading string from file issue (more than 255 bytes)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/?limit=25#4816/6f48" rel="alternate"/><published>2022-06-29T10:24:31.438000Z</published><updated>2022-06-29T10:24:31.438000Z</updated><author><name>master-student</name><uri>https://forge.codesys.com/u/master-student/</uri></author><id>https://forge.codesys.com2b259bf4d4fd702f74c9e7f3eea49d263887849e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi, I am having a similar issue. I need to get readings from a temp sensor and make a string by opening and reading a file. it seems you already got the solution for a similar issue. Could you may be share the code you made please?. That would be very helpful. &lt;br/&gt;
Thanks&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>reading string from file issue (more than 255 bytes)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/?limit=25#4816" rel="alternate"/><published>2020-02-27T17:03:24.773000Z</published><updated>2020-02-27T17:03:24.773000Z</updated><author><name>mikeardy</name><uri>https://forge.codesys.com/u/mikeardy/</uri></author><id>https://forge.codesys.com2db9b8b8fe362f728cb4fd1d1d8e67938f0f8245</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;IT PERFECTLY WORKS!&lt;br/&gt;
Thank you!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>reading string from file issue (more than 255 bytes)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/?limit=25#66b0" rel="alternate"/><published>2020-02-27T17:03:22.124000Z</published><updated>2020-02-27T17:03:22.124000Z</updated><author><name>Comingback4u</name><uri>https://forge.codesys.com/u/comingback4u/</uri></author><id>https://forge.codesys.comad4805dcab9045f5074654cf91ea437fd977a577</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I find mine in "Library Manager-&amp;gt;Add Library-&amp;gt;Advanced-&amp;gt;Intern-&amp;gt;Utils" and choose StringUtils. Or once you are on the advanced screen just search for StringUtils.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>reading string from file issue (more than 255 bytes)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/?limit=25#238d" rel="alternate"/><published>2020-02-27T17:03:21.016000Z</published><updated>2020-02-27T17:03:21.016000Z</updated><author><name>mikeardy</name><uri>https://forge.codesys.com/u/mikeardy/</uri></author><id>https://forge.codesys.com0b0086bfc7ad4fa139e990bf5719d4417b2f5519</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I like your solution! It's quite similar to mine previous. Where can I found the library you used for this application?  I don't found into the library repository.&lt;br/&gt;
Thanks&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>reading string from file issue (more than 255 bytes)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/?limit=25#8147" rel="alternate"/><published>2020-02-27T17:03:18.270000Z</published><updated>2020-02-27T17:03:18.270000Z</updated><author><name>Comingback4u</name><uri>https://forge.codesys.com/u/comingback4u/</uri></author><id>https://forge.codesys.com4e4114b81df98409dc922663d91d0b041dcd6539</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Mine looks very similar to yours. I would still be interested in seeing the output of sReadLine to see if it is reading the whole file at state 5 before you hit state 6. The difference of mine is I am looking for Unicode characters (16bit) instead of ANSI characters(8bit) since the files i'm reading can be in many different languages. &lt;/p&gt;
&lt;p&gt;To extract data from the buffer you would use something like (Not Tested but hopefully gives you the idea):&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;VAR&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nl"&gt;sValueDelimiter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;STRING&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'='&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nl"&gt;sNewLineDelimiter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;STRING&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="err"&gt;'$&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nl"&gt;nBufferLength&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;DINT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nl"&gt;nValueLocation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nl"&gt;nNewLineStart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nl"&gt;ExtractedValue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;STRING&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;span class="c1"&gt;//Find the length of buffer (Replaces LEN)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nl"&gt;nBufferLength&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;StrLenA&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;pstData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ADR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sReadLine&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;//Locate the equals sign to separate the data from the label (Replaces FIND)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nl"&gt;nValueLocation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;StrFindA&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;pst1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ADR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sReadLine&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nl"&gt;pst2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sValueDelimiter&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nl"&gt;uiSearchStart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; 
&lt;span class="c1"&gt;//Locate end of line to know how long the data field is (Replaces FIND) (If you have [CONFIG FILE] written in the file you will need to cycle past this first before going to StrMidA)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nl"&gt;nNewLineStart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;StrFindA&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;pst1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ADR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sReadLine&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nl"&gt;pst2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sNewLineDelimiter&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nl"&gt;uiSearchStart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; 
&lt;span class="c1"&gt;//Extract the data from the buffer and place it in variable ExtractedValue (Replaces MID/LEFT/RIGHT)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="n"&gt;StrMidA&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;pwst&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ADR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sReadLine&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nl"&gt;uiInputBufferSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SIZEOF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sReadLine&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nl"&gt;iLength&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nNewLineStart&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;nValueLocation&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nl"&gt;iPosition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nValueLocation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;pwstResult&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; 
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="n"&gt;ADR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ExtractedValue&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nl"&gt;uiResultBufferSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SIZEOF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ExtractedValue&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; 
&lt;span class="c1"&gt;//Delete extracted data from the buffer (Replaces Delete) (Not needed but I do this to create a loop out of the first parts)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="n"&gt;StrDeleteA&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;pwd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ADR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sReadLine&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nl"&gt;iLength&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nNewLineStart&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;iPosition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>reading string from file issue (more than 255 bytes)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/?limit=25#2014" rel="alternate"/><published>2020-02-27T17:03:17.320000Z</published><updated>2020-02-27T17:03:17.320000Z</updated><author><name>mikeardy</name><uri>https://forge.codesys.com/u/mikeardy/</uri></author><id>https://forge.codesys.comec498ebcb6dce8486fddd6336477b0071a3735f8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;At this point, I think you are right. &lt;br/&gt;
Could you post some piece of code to better understand what you are saying me?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>reading string from file issue (more than 255 bytes)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/?limit=25#b660" rel="alternate"/><published>2020-02-27T17:03:16.355000Z</published><updated>2020-02-27T17:03:16.355000Z</updated><author><name>Comingback4u</name><uri>https://forge.codesys.com/u/comingback4u/</uri></author><id>https://forge.codesys.com9e7c0d7126606b7fce40e44355ed4abd0e6db50a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I think you are going the wrong direction.&lt;/p&gt;
&lt;p&gt;The File.Read doesn't have a limit besides the size of the buffer. I have multiple applications that read well over 255 (closer to 1600) and you said even yours returns over 255 (266 to be exact) so not sure why you have come up with that assumption.&lt;/p&gt;
&lt;p&gt;Any of the string functions built into the STANDARD library (LEN, MID, FIND, REPLACE, LEFT, RIGHT, ....) have a limit of 255 and that is one reason you should use the STRING UTIL library. Also from what has been said on the forums the STRING UTIL library is much quicker.&lt;/p&gt;
&lt;p&gt;Hope you find an answer either way but reading byte for byte sounds slow.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>reading string from file issue (more than 255 bytes)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/?limit=25#e7e2" rel="alternate"/><published>2020-02-27T17:03:13.685000Z</published><updated>2020-02-27T17:03:13.685000Z</updated><author><name>mikeardy</name><uri>https://forge.codesys.com/u/mikeardy/</uri></author><id>https://forge.codesys.comb2e8f6405f620b4651840ab5623c5bf799c82511</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;The issue is around FileRead function: the function does not return a string longer than 255 bytes. &lt;/p&gt;
&lt;p&gt;Actually, I'm trying to solve the problem using file position pointer reading byte per byte and generating substring less than 255 bytes long. I will post code as soon as I tested it... could be useful for others &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>reading string from file issue (more than 255 bytes)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/c4d7a9efdf/?limit=25#a75a" rel="alternate"/><published>2020-02-27T17:03:12.735000Z</published><updated>2020-02-27T17:03:12.735000Z</updated><author><name>Comingback4u</name><uri>https://forge.codesys.com/u/comingback4u/</uri></author><id>https://forge.codesys.comdab13047bcfeaf09afa163f4bfeea1f628d356b2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Nothing sticks out based off the information you have here. I see you have MID commented out which is only a string of 255 and you should look at using StrMidA in the StringUtils library.&lt;/p&gt;
&lt;p&gt;What does the buffer equal after read is complete? Have you tried increasing sReadLine to STRING(2000) and see if you get more back?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>