<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Variable Length Array - Cannot mix variable and fixed length dimensions?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9943e7a02f/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9943e7a02f/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/9943e7a02f/</id><updated>2025-05-26T08:28:54.651000Z</updated><subtitle>Recent posts to Variable Length Array - Cannot mix variable and fixed length dimensions?</subtitle><entry><title>Variable Length Array - Cannot mix variable and fixed length dimensions?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9943e7a02f/?limit=25#6527" rel="alternate"/><published>2025-05-26T08:28:54.651000Z</published><updated>2025-05-26T08:28:54.651000Z</updated><author><name>Dave_T</name><uri>https://forge.codesys.com/u/nz-dave/</uri></author><id>https://forge.codesys.coma60c3c612f16b0dac08735ce524d227492443080</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;VAR CONSTANT&lt;br/&gt;
    size : INT := 10;&lt;br/&gt;
END_VAR&lt;/p&gt;
&lt;p&gt;My_Array : ARRAY&lt;span&gt;[1..SIZE , 1..5]&lt;/span&gt; OF REAL;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Variable Length Array - Cannot mix variable and fixed length dimensions?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9943e7a02f/?limit=25#b7e0" rel="alternate"/><published>2025-05-24T12:51:45.090000Z</published><updated>2025-05-24T12:51:45.090000Z</updated><author><name>andrax</name><uri>https://forge.codesys.com/u/andrax/</uri></author><id>https://forge.codesys.comc4b97a96f4bad704ab83874c397b79bbb731a868</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Arrays with variable lengths are a bad idea.&lt;br/&gt;
This makes your system unstable and can lead to crashes.&lt;br/&gt;
Declare your array large enough to reserve enough memory&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Variable Length Array - Cannot mix variable and fixed length dimensions?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9943e7a02f/?limit=25#dd87" rel="alternate"/><published>2025-05-23T19:45:00.510000Z</published><updated>2025-05-23T19:45:00.510000Z</updated><author><name>bmatlove</name><uri>https://forge.codesys.com/u/bmatlove/</uri></author><id>https://forge.codesys.com24de994c7d24a337e3b678e654fb654b833a0fa0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I am trying to work with an array of variable length in one dimension, but known in the other dimension.&lt;br/&gt;
For example, using an array that represents a list of items, each with an attribute profile.&lt;br/&gt;
I do not know how many item will be in the list, but I know that every item has 5 attributes, like size, weight, etc.&lt;/p&gt;
&lt;p&gt;Codesys does not seem to be able to accept this.&lt;br/&gt;
I have referenced &lt;a class="" href="https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_datatype_array.html" rel="nofollow"&gt;Data Type: ARRAY OF documentation page&lt;/a&gt;, which is not explicit if variable &amp;amp; fixed length array dimensions can be mixed.&lt;br/&gt;
In the VAR_IN_OUT scope, I initially tried &lt;code&gt;MY_ARRAY : ARRAY [*, *] OF REAL;&lt;/code&gt; which was no problem, of course. I then modified it to &lt;code&gt;MY_ARRAY : ARRAY [*, 1..5] OF REAL;&lt;/code&gt; which throws &lt;code&gt;C0006:  ', or ]' expected instead of '..'&lt;/code&gt; among consequent downstream errors.&lt;br/&gt;
I then used the Auto Declare -&amp;gt; Array Wizard, which accepted &lt;em&gt;-&lt;/em&gt; and 1-5 for 2-dimensional lower and upper bounds.&lt;br/&gt;
It output: &lt;code&gt;testarray: ARRAY[*..*, 1..6] OF INT;&lt;/code&gt; which throws the same error stream.&lt;/p&gt;
&lt;p&gt;What's the deal here? Is this possible?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>