<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Write one dimensional array into two dimensional array</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/73b7f2a344/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/73b7f2a344/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/73b7f2a344/</id><updated>2022-02-25T12:42:05.906000Z</updated><subtitle>Recent posts to Write one dimensional array into two dimensional array</subtitle><entry><title>Write one dimensional array into two dimensional array</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/73b7f2a344/?limit=25#03c9/12cc" rel="alternate"/><published>2022-02-25T12:42:05.906000Z</published><updated>2022-02-25T12:42:05.906000Z</updated><author><name>Vijolica555</name><uri>https://forge.codesys.com/u/vijolica555/</uri></author><id>https://forge.codesys.combc7a71aaaa0dda72d5bf0fe92808e07c656ea308</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you for suggestion. I managed to write 1D array into 2D as needed.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Write one dimensional array into two dimensional array</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/73b7f2a344/?limit=25#e7d6" rel="alternate"/><published>2022-02-25T12:38:38.653000Z</published><updated>2022-02-25T12:38:38.653000Z</updated><author><name>peterned</name><uri>https://forge.codesys.com/u/peterned/</uri></author><id>https://forge.codesys.com08409ad5666d57db9d6eda8890871d7c03f75955</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I think you can simply declare both at the same fixed memory address, e.g.&lt;br/&gt;
aWhole AT %MB100: ARRAY &lt;span&gt;[0..Main.Length]&lt;/span&gt; OF REAL;&lt;br/&gt;
aDivided AT %MB100: ARRAY &lt;span&gt;[0..Main.Width,0..Main.Groups]&lt;/span&gt; OF REAL;&lt;/p&gt;
&lt;p&gt;and use whichever you want, a change in one will automatically be reflected in the other.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Write one dimensional array into two dimensional array</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/73b7f2a344/?limit=25#03c9" rel="alternate"/><published>2022-02-24T08:18:51.729000Z</published><updated>2022-02-24T08:18:51.729000Z</updated><author><name>sgronchi</name><uri>https://forge.codesys.com/u/sgronchi/</uri></author><id>https://forge.codesys.com861ff041b158e92a5d8627bd2f3a3f9f137e4a4a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You have two options.&lt;/p&gt;
&lt;p&gt;First, you can do the "safe way" with two FOR cycles (assuming Main.Length + 1 = (Main.Width + 1) * (Main.Groups + 1) based on how you declared the two arrays)&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;FOR i := 0 TO Main.Width DO&lt;/span&gt;
&lt;span class="err"&gt;    FOR j := 0 TO Main.Groups DO&lt;/span&gt;
&lt;span class="err"&gt;        aDivided[i, j] := aWhole[i * (Main.Groups+1) + j];&lt;/span&gt;
&lt;span class="err"&gt;    END_FOR&lt;/span&gt;
&lt;span class="err"&gt;END_FOR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Second, you can use CAA Memory Library functions like&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;MEM.MemMove(pSource := ADR(aWhole[0]), pDestination := ADR(aDivided[0,0]), uiNumberOfBytes := Main.Length+1);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Write one dimensional array into two dimensional array</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/73b7f2a344/?limit=25#fd82" rel="alternate"/><published>2022-02-22T13:30:41.282000Z</published><updated>2022-02-22T13:30:41.282000Z</updated><author><name>Vijolica555</name><uri>https://forge.codesys.com/u/vijolica555/</uri></author><id>https://forge.codesys.comf892cbb0b5e17e4bb3b17b38e3d4468e42e960bd</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi guys,&lt;/p&gt;
&lt;p&gt;I would appreciate advice on how to write one dimensional array into two dimensional array. &lt;/p&gt;
&lt;p&gt;I have one dimensional array (lets name it aWhole) and the length of this array is known. I need to separate this array in smaller groups so I divide length of one dimensional array with arbitrarily no. of groups and got new array aDivided with the lengths: Width and Groups. Anyone has an idea how to write first array into second one?&lt;br/&gt;
Length is not necessary divided with Groups (in that case we round it to get whole no. of Width but idk what we do with the rest part of aWhole). &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;VAR&lt;/span&gt;
&lt;span class="err"&gt;aWhole : ARRAY [0..Main.Length] OF REAL;&lt;/span&gt;
&lt;span class="err"&gt;aDivided : ARRAY [0..Main.Width,0..Main.Groups] OF REAL;&lt;/span&gt;
&lt;span class="err"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry></feed>