<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to ARRAY of unknow struct</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ffb32f829d/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ffb32f829d/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/ffb32f829d/</id><updated>2020-02-27T14:33:31.345000Z</updated><subtitle>Recent posts to ARRAY of unknow struct</subtitle><entry><title>ARRAY of unknow struct</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ffb32f829d/?limit=25#7c89" rel="alternate"/><published>2020-02-27T14:33:31.345000Z</published><updated>2020-02-27T14:33:31.345000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comd3f4734d9805d69a56b50098ccd741315e1b56c5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; rickj&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Zitat:&lt;/strong&gt;&lt;br/&gt;
By the way, you use prefixes in your coding, this is called "Hungarian Notation" and it is a terrible style of coding. It makes your code unreadabale&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Amen!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>ARRAY of unknow struct</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ffb32f829d/?limit=25#bb09" rel="alternate"/><published>2020-02-27T14:33:30.836000Z</published><updated>2020-02-27T14:33:30.836000Z</updated><author><name>schaepper</name><uri>https://forge.codesys.com/u/schaepper/</uri></author><id>https://forge.codesys.coma70944fe01ab07bf7e83d0f02c9a182608471740</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello&lt;/p&gt;
&lt;p&gt;Can you explain what exactly you want to do? Why do you need an unknown type and then "by convention" say its a byte? Is it really the type which is unknown?&lt;br/&gt;
This would be a perfect usecase for an interface or a baseclass, you could also extend the type struct and make your "own" structure.&lt;/p&gt;
&lt;p&gt;So you have an interface like, "LogEntry" or "ILoggingSource" with a method "GetLogMessage". All the FB's and Functions which need to log implement this interface, and this interface would be the item in your list.&lt;br/&gt;
Here is some "sample" code:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;s_arrDestination&lt;/span&gt; : &lt;span class="nv"&gt;ARRAY&lt;/span&gt; [&lt;span class="mi"&gt;0&lt;/span&gt;..&lt;span class="mi"&gt;10&lt;/span&gt;] &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nv"&gt;ILoggingSource&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;each&lt;/span&gt; &lt;span class="nv"&gt;loggingItem&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;s_arrDestination&lt;/span&gt;
{
   &lt;span class="nv"&gt;File&lt;/span&gt;.&lt;span class="nv"&gt;Write&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;loggingItem&lt;/span&gt;.&lt;span class="nv"&gt;getLogMessage&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
}
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;By the way, you use prefixes in your coding, this is called "Hungarian Notation" and it is a terrible style of coding. It makes your code unreadabale. Also, its scientifically proved that hungarian notation causes braindamage or even braindeath.&lt;br/&gt;
I know even in the PLC Open guidelines they use it, but its still eyecancer. Please avoid it never ever think of doing it again in your future.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Linus Torvalds (against Systems Hungarian):&lt;/strong&gt;&lt;br/&gt;
Encoding the type of a function into the name (so-called Hungarian notation) is brain damaged—the compiler knows the types anyway and can check those, and it only confuses the programmer.&lt;span&gt;[10]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="https://en.wikipedia.org/wiki/Hungarian_notation" rel="nofollow"&gt;https://en.wikipedia.org/wiki/Hungarian_notation&lt;/a&gt; m &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>ARRAY of unknow struct</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ffb32f829d/?limit=25#0a23" rel="alternate"/><published>2020-02-27T14:33:30.365000Z</published><updated>2020-02-27T14:33:30.365000Z</updated><author><name>josepmariarams</name><uri>https://forge.codesys.com/u/josepmariarams/</uri></author><id>https://forge.codesys.com7cbfc4b2c7196d099815a66e5c5c378820ad4053</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;See&lt;/p&gt;
&lt;p&gt;SptDestination:=adr(sptdestination).&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>ARRAY of unknow struct</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ffb32f829d/?limit=25#ce7b" rel="alternate"/><published>2020-02-27T14:33:29.010000Z</published><updated>2020-02-27T14:33:29.010000Z</updated><author><name>Joan M</name><uri>https://forge.codesys.com/u/joan-m/</uri></author><id>https://forge.codesys.combbcd6f4188de98c7c3a4498bb20247fc138513ed</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;s_ptDestination := ADR(s_ptDestination);                                 // Get pointer to data buffer&lt;/p&gt;
&lt;p&gt;This has no effect...&lt;/p&gt;
&lt;p&gt;You have to point the pointer to something else before being able to use it.&lt;/p&gt;
&lt;p&gt;So when you try to dereference the pointer the pointer is still not initialized therefore it fails.&lt;/p&gt;
&lt;p&gt;s_ptDestination := ADR(s_buffer);  // ADR returns the address of the object (not pointer) you pass as parameter...&lt;/p&gt;
&lt;p&gt;Hope this helps...&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>ARRAY of unknow struct</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ffb32f829d/?limit=25#c05e" rel="alternate"/><published>2020-02-27T14:33:28.518000Z</published><updated>2020-02-27T14:33:28.518000Z</updated><author><name>LJL-Houben</name><uri>https://forge.codesys.com/u/ljl-houben/</uri></author><id>https://forge.codesys.com8783575598f6fff19fb1fdb7d48be99a2111740d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi All&lt;/p&gt;
&lt;p&gt;I'm trying to make a logging function and when I call this function I want to connect a structure that holds the data. Within this structure I have 1 keyword of type BYTE. To the function I give a pointer to this struct and the length of this struct. THIS WORKS &lt;/p&gt;
&lt;p&gt;Within the logging function, for timing reasons, I need to make a buffer that holds e.g. 10 loggings before the data is saved to disk. So I need something that can create:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;s_arrDestination&lt;/span&gt; &lt;span class="p"&gt;:&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="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;UNKNOWN_STRUCTURE&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;So I started to 'play' with pointers, but my laptop keeps on crashing, so I'm doing something realy wrong. Code until now:&lt;br/&gt;
&lt;span style="color: 85%;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;
The line s_ptDestination^ := s_ptSource^ is marked as comment because this causes the laptop crash. So hopefully someone can help me with this issue. &lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Ludo&lt;/p&gt;
&lt;p&gt;Please no OSCAT comments, couldn't find anything helpfull on that site until now.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>