<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Generic Change Log</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/a09f75ccef/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/a09f75ccef/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/a09f75ccef/</id><updated>2020-02-27T13:47:44.430000Z</updated><subtitle>Recent posts to Generic Change Log</subtitle><entry><title>Generic Change Log</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/a09f75ccef/?limit=25#fddf" rel="alternate"/><published>2020-02-27T13:47:44.430000Z</published><updated>2020-02-27T13:47:44.430000Z</updated><author><name>Tim.Manning</name><uri>https://forge.codesys.com/u/tim-manning/</uri></author><id>https://forge.codesys.com4f23f1b83e8305cf5e4d91a7077df26c7f72a495</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I need to develop a generic change log.&lt;/p&gt;
&lt;p&gt;I want to be able to compare two instances of a structure (dutName and dutNameLast), and determine which elements have changed.&lt;/p&gt;
&lt;p&gt;I can use the MEM.Compare function to determine that there is a difference between the two instances of structures. &lt;/p&gt;
&lt;p&gt;But once I detect that there is a difference, I need to populate a Change Log, which will be an array of a structure that looks like this:&lt;/p&gt;
&lt;p&gt;ChangeTS           | SeqNum |  VarName                          | OldValue      | NewValue&lt;br/&gt;
DATE_AND_TIME |  123       | dutName.configINT_A        | 'xxx'            | 'xxy'&lt;br/&gt;
DATE_AND_TIME |  122       | dutName.configREAL_B      | 'x.xxxx'       | 'y.yyyy'&lt;br/&gt;
DATE_AND_TIME |  121       | dutName.configBOOL_C     | '1'               | '0'&lt;br/&gt;
DATE_AND_TIME |  120       | dutName.configDINT_D      | 'xxxxxx'       | 'yyyxyy'&lt;/p&gt;
&lt;p&gt;Only the elements that have changed get logged.&lt;/p&gt;
&lt;p&gt;I want this to be generic, because I need to be able to compare two instances of a variety of structures.  &lt;/p&gt;
&lt;p&gt;I am having trouble figuring out how to do the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Is there a programmatic way to determine what the element names are for a structure?  I'd like to be able to reference the structure somehow, and get a list of element names returned.  &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Is there an easy way to traverse the elements of a structure, so that I can do a comparison of the individual elements in some kind of loop:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Loop through the elements of the structure&lt;br/&gt;
     compare value of dutName.(nth_elementname) to value of dutNameLast.(nth_elementname)&lt;br/&gt;
     change &lt;em&gt;.(nth_elementname) to &lt;/em&gt;.(nth+1elementname)&lt;br/&gt;
   End loop&lt;/p&gt;
&lt;p&gt;Any assistance or advice would be greatly appreciated.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>