<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Increment pointer address</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/26655728a8/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/26655728a8/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/26655728a8/</id><updated>2020-02-27T23:00:12.716000Z</updated><subtitle>Recent posts to Increment pointer address</subtitle><entry><title>Increment pointer address</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/26655728a8/?limit=25#1238" rel="alternate"/><published>2020-02-27T23:00:12.716000Z</published><updated>2020-02-27T23:00:12.716000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comeec558e8bb85dcf1822df9e7da60dc7eab5464cf</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;If you get tired of dereferencing your pointer, you can use REFERENCE TO instead of POINTER TO. Check the help for more info.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Increment pointer address</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/26655728a8/?limit=25#3e3d" rel="alternate"/><published>2020-02-27T23:00:08.234000Z</published><updated>2020-02-27T23:00:08.234000Z</updated><author><name>JorTec</name><uri>https://forge.codesys.com/u/jortec/</uri></author><id>https://forge.codesys.comfa8c661bb665adbc319d08391136251d9543dbce</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;scott_cunningham hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
I am not by my computer, but I believe you need to dereference before index: dataPtr^&lt;span&gt;[1]&lt;/span&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Works! Unbelievable I didn't try that... Thanks very much!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Increment pointer address</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/26655728a8/?limit=25#1e4c" rel="alternate"/><published>2020-02-27T23:00:06.580000Z</published><updated>2020-02-27T23:00:06.580000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com13115edf4a8c04485a1daf68a2fc57fa8890d052</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;I am not by my computer, but I believe you need to dereference before index: dataPtr^&lt;span&gt;[1]&lt;/span&gt;.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Increment pointer address</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/26655728a8/?limit=25#4b7c" rel="alternate"/><published>2020-02-27T23:00:04.954000Z</published><updated>2020-02-27T23:00:04.954000Z</updated><author><name>JorTec</name><uri>https://forge.codesys.com/u/jortec/</uri></author><id>https://forge.codesys.comde0482af4fdb40e02503bf5c3e27e644721e8dce</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks for your reply. Unfortunately, this is not possible (error 4110, '&lt;span&gt;[&amp;lt;index&amp;gt;]&amp;lt;/index&amp;gt;&lt;/span&gt;' needs array variable). &lt;/p&gt;
&lt;p&gt;Other solutions, or is my implementation wrong: dummyFunction(dataPtr&lt;span&gt;[0]&lt;/span&gt;^, dataPtr&lt;span&gt;[1]&lt;/span&gt;^ + dataPtr&lt;span&gt;[2]&lt;/span&gt;^ *256 , dataPtr&lt;span&gt;[3]&lt;/span&gt;^);&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Increment pointer address</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/26655728a8/?limit=25#ed41" rel="alternate"/><published>2020-02-27T23:00:00.394000Z</published><updated>2020-02-27T23:00:00.394000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.come0284853bbd3c41bb63924236fab15ca99c87eb6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;Instead of defining a pointer to byte, define your pointer as:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;dataPtr&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;POINTER&lt;/span&gt; &lt;span class="k"&gt;TO&lt;/span&gt; &lt;span class="nb"&gt;ARRAY&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="n"&gt;MAX_RECEIVE_TCP_SERVER&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;OF&lt;/span&gt; &lt;span class="n"&gt;BYTE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Then you can access your data with array indexing like you wish.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Increment pointer address</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/26655728a8/?limit=25#0bbc" rel="alternate"/><published>2020-02-27T22:59:58.782000Z</published><updated>2020-02-27T22:59:58.782000Z</updated><author><name>JorTec</name><uri>https://forge.codesys.com/u/jortec/</uri></author><id>https://forge.codesys.comd3ead879a1783d029d8184e4c3937ea196b18b56</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello all,&lt;/p&gt;
&lt;p&gt;I have an array of x bytes. I want to process this data somewhere else in my program so I want to use pointers. I want to be able to increment the pointer address in an easy way. I know have the following code:&lt;/p&gt;
&lt;hr/&gt;
&lt;p&gt;receivedData : ARRAY &lt;span&gt;[0..MAX_RECEIVE_TCP_SERVER]&lt;/span&gt; OF BYTE;&lt;/p&gt;
&lt;hr/&gt;
&lt;p&gt;processCommand( ADR(receivedData&lt;span&gt;[6]&lt;/span&gt;) );&lt;/p&gt;
&lt;hr/&gt;
&lt;p&gt;FUNCTION processCommand : BOOL&lt;br/&gt;
VAR_INPUT&lt;br/&gt;
    dataPtr : POINTER TO BYTE;&lt;br/&gt;
END_VAR&lt;br/&gt;
VAR&lt;br/&gt;
    channel: BYTE;&lt;br/&gt;
    value: UINT;&lt;br/&gt;
    state: BYTE;&lt;br/&gt;
END_VAR&lt;/p&gt;
&lt;hr/&gt;
&lt;p&gt;channel := dataPtr^;&lt;br/&gt;
dataPtr := dataPtr + 1;&lt;br/&gt;
value := dataPtr^;&lt;br/&gt;
dataPtr := dataPtr + 1;&lt;br/&gt;
value := value + (dataPtr^ * 256);&lt;br/&gt;
dataPtr := dataPtr + 1;&lt;br/&gt;
state := dataPtr^;&lt;/p&gt;
&lt;p&gt;dummyFunction(channel, value, state);&lt;/p&gt;
&lt;hr/&gt;
&lt;p&gt;Is there an easier way to increment the pointer address? I would prefer to have something like this, but I don't know if this is possible: &lt;br/&gt;
dummyFunction(dataPtr&lt;span&gt;[0]&lt;/span&gt;^, dataPtr&lt;span&gt;[1]&lt;/span&gt;^ + dataPtr&lt;span&gt;[2]&lt;/span&gt;^ *256 , dataPtr&lt;span&gt;[3]&lt;/span&gt;^);&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>