I want this to be generic, because I need to be able to compare two instances of a variety of structures.
I am having trouble figuring out how to do the following:
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.
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:
Loop through the elements of the structure
compare value of dutName.(nth_elementname) to value of dutNameLast.(nth_elementname)
change .(nth_elementname) to .(nth+1elementname)
End loop
Any assistance or advice would be greatly appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I need to develop a generic change log.
I want to be able to compare two instances of a structure (dutName and dutNameLast), and determine which elements have changed.
I can use the MEM.Compare function to determine that there is a difference between the two instances of structures.
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:
ChangeTS | SeqNum | VarName | OldValue | NewValue
DATE_AND_TIME | 123 | dutName.configINT_A | 'xxx' | 'xxy'
DATE_AND_TIME | 122 | dutName.configREAL_B | 'x.xxxx' | 'y.yyyy'
DATE_AND_TIME | 121 | dutName.configBOOL_C | '1' | '0'
DATE_AND_TIME | 120 | dutName.configDINT_D | 'xxxxxx' | 'yyyxyy'
Only the elements that have changed get logged.
I want this to be generic, because I need to be able to compare two instances of a variety of structures.
I am having trouble figuring out how to do the following:
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.
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:
Loop through the elements of the structure
compare value of dutName.(nth_elementname) to value of dutNameLast.(nth_elementname)
change .(nth_elementname) to .(nth+1elementname)
End loop
Any assistance or advice would be greatly appreciated.