<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to  Struct - Variable String Length</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4c15a95e0e/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4c15a95e0e/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/4c15a95e0e/</id><updated>2020-06-29T21:10:29.017000Z</updated><subtitle>Recent posts to  Struct - Variable String Length</subtitle><entry><title> Struct - Variable String Length</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4c15a95e0e/?limit=25#8172" rel="alternate"/><published>2020-06-29T21:10:29.017000Z</published><updated>2020-06-29T21:10:29.017000Z</updated><author><name>nothinrandom</name><uri>https://forge.codesys.com/u/nothinrandom/</uri></author><id>https://forge.codesys.com43dae68f29c35e1d890f7106f1eed5da2186ba00</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;@JAPIB,&lt;/p&gt;
&lt;p&gt;Thanks for confirming!  I am a bit bummed out since this would make packing/unpacking structs not straight forward at all.  But I guess the alternative would create possibility of buffer overflow, so it is not safe.  Now, I need to really think about how to unpack structs with this limitation.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title> Struct - Variable String Length</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4c15a95e0e/?limit=25#1fcd" rel="alternate"/><published>2020-06-29T20:13:37.383000Z</published><updated>2020-06-29T20:13:37.383000Z</updated><author><name>JAPIB</name><uri>https://forge.codesys.com/u/japib/</uri></author><id>https://forge.codesys.com2203acd330d21efadf74017feeeae0d3b5d8b8f2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
It seems that the length of a chain must be defined only by a constant.&lt;/p&gt;
&lt;p&gt;So you can only write : testName : STRING&lt;span&gt;[10]&lt;/span&gt;;&lt;br/&gt;
And not :&lt;br/&gt;
    testLength : BYTE:=10; //Even if we initialize the value&lt;br/&gt;
    testName : STRING&lt;span&gt;[testLength]&lt;/span&gt;; //Not OK&lt;/p&gt;
&lt;p&gt;Even in the case of a variable declaration (not a structure),&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title> Struct - Variable String Length</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4c15a95e0e/?limit=25#a386" rel="alternate"/><published>2020-06-29T19:48:17.793000Z</published><updated>2020-06-29T19:48:17.793000Z</updated><author><name>nothinrandom</name><uri>https://forge.codesys.com/u/nothinrandom/</uri></author><id>https://forge.codesys.com19118a998878188434683db90217f5af42359aed</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I would like to create a struct that has variable string length.  However, CoDeSys compiler is not happy since testLength is not a constant.&lt;/p&gt;
&lt;p&gt;STRUCT&lt;br/&gt;
    testLength  : BYTE;&lt;br/&gt;
    testName    : STRING&lt;span&gt;[testLength]&lt;/span&gt;;&lt;br/&gt;
END_STRUCT&lt;/p&gt;
&lt;p&gt;I have been reading through documentation but could not find an answer to this, so I hope it is not impossible.  Maybe there is another way to approach this?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>