<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Pointers</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/2422417f98/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/2422417f98/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/2422417f98/</id><updated>2020-02-27T21:26:30.282000Z</updated><subtitle>Recent posts to Pointers</subtitle><entry><title>Pointers</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/2422417f98/?limit=25#a37a" rel="alternate"/><published>2020-02-27T21:26:30.282000Z</published><updated>2020-02-27T21:26:30.282000Z</updated><author><name>spfeif</name><uri>https://forge.codesys.com/u/spfeif/</uri></author><id>https://forge.codesys.com293850d11410dda29fe95e90ebad70e00184494b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;What does the RS232 port have to do with pointers? A pointer holds an address to a memory location. Typically this is in the variable type DWORD which holds the address in memory. In the IEC 61131 they gave us the following:&lt;/p&gt;
&lt;p&gt;ADR operator  -  Get the address to a variable&lt;/p&gt;
&lt;p&gt;^ - de-reference a pointer.&lt;/p&gt;
&lt;p&gt;VAR_IN_OUT - This is basically pass by reference instead of pass by value. You can look this up.&lt;/p&gt;
&lt;p&gt;&amp;lt;identifier&amp;gt;: POINTER TO &amp;lt;datatype functionblock=""&amp;gt;; &amp;lt;/datatype&amp;gt;&amp;lt;/identifier&amp;gt;&lt;/p&gt;
&lt;p&gt;I think you can do a google search and find un-godly amounts of information on pointers but in IEC 61131 the main pointers are as described above. Please see the CoDeSys help topic "Pointer". &lt;/p&gt;
&lt;p&gt;If you don't know how they work or how to implement them then how do you know you need to use pointers?&lt;/p&gt;
&lt;p&gt;A very brief example:&lt;/p&gt;
&lt;p&gt;MyVar   :int = 3; (&lt;em&gt; initialize the value of a variable of type int to 3 &lt;/em&gt;)&lt;/p&gt;
&lt;p&gt;If I need the memory address of this variable then I can use the ADR operator&lt;/p&gt;
&lt;p&gt;Pointer_To_MyVar = ADR(MyVar); (&lt;em&gt; So Pointer_To_MyVar holds a memory address not the value 3 &lt;/em&gt;)&lt;/p&gt;
&lt;p&gt;If you want the value 3 returned you can dereference the pointer&lt;/p&gt;
&lt;p&gt;What_Is_The_Value_MyVar :=  Pointer_To_MyVar^;&lt;/p&gt;
&lt;p&gt;What_Is_The_Value_MyVar  will be = 3 after this call.&lt;/p&gt;
&lt;p&gt;If you want to change the the value of MyVar through the pointer Pointer_To_MyVar you can do the following:&lt;/p&gt;
&lt;p&gt;Pointer_To_MyVar^ := 16;&lt;/p&gt;
&lt;p&gt;Now MyVar = 16.&lt;/p&gt;
&lt;p&gt;Let us know what you are trying to accomplish so we can better assist.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Pointers</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/2422417f98/?limit=25#66a6" rel="alternate"/><published>2020-02-27T21:26:26.225000Z</published><updated>2020-02-27T21:26:26.225000Z</updated><author><name>DodgyDave80</name><uri>https://forge.codesys.com/u/dodgydave80/</uri></author><id>https://forge.codesys.com9c38a495e66356f72613c619d76cc8fa4e03bc4d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi, &lt;/p&gt;
&lt;p&gt;Can anyone provide me with a dummies guide for using pointers. I need to look at parts of an RS232 receive buffer in my program, but i don't understand how pointers work or how to implement them.&lt;/p&gt;
&lt;p&gt;Any help would be appreciated.&lt;/p&gt;
&lt;p&gt;Thank You&lt;/p&gt;
&lt;p&gt;Dave&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>