How to retain the Structure Data Type?
Is there any way that you can create a structure, and within that structure define some of the elements as PERSISTENT and RETAIN and some as just regular?
Lets say that I am defining a structure like this...
TYPE MyStruct :
STRUCT
//definition of my structure
element1 : DINT; //i want to define this as PERSISTENT
element2 : INT; //i want to define this as PERSISTENT and RETAIN
element3 : INT; //i don't want to define this as PERSISTENT or RETAIN
element4 : REAL; //i don't want to define this as PERSISTENT or RETAIN
END_STRUCT
END_TYPE
So, when I go to declare my variable as the type "MyStruct" that I just made, I have the option to designate the whole variable as just a VAR or VAR PERSISTENT RETAIN, or any combination of those, but I obviously can't specify those attributes for specific elements within the variable at that point.
Is there some syntax within the structure that I can use to designate specific elements for retention and others for no retention?
I have attached one screen shot of the Data Type 'Process' wherein I need to retain the HMI_SP and HMI_TSP.

Lets say that I am defining a structure like this...
TYPE MyStruct :
STRUCT
//definition of my structure
element1 : DINT; //i want to define this as PERSISTENT
element2 : INT; //i want to define this as PERSISTENT and RETAIN
element3 : INT; //i don't want to define this as PERSISTENT or RETAIN
element4 : REAL; //i don't want to define this as PERSISTENT or RETAIN
END_STRUCT
END_TYPE
So, when I go to declare my variable as the type "MyStruct" that I just made, I have the option to designate the whole variable as just a VAR or VAR PERSISTENT RETAIN, or any combination of those, but I obviously can't specify those attributes for specific elements within the variable at that point.
Is there some syntax within the structure that I can use to designate specific elements for retention and others for no retention?
I have attached one screen shot of the Data Type 'Process' wherein I need to retain the HMI_SP and HMI_TSP.

Answers
Hi
AFAIK no, the declaration of the variables and their attributes is made during the assignment in the definition phase, the video at the follow link can be a good track for how to do it.
https://www.youtube.com/watch?v=WRqaw...
Hope this help you
BR
Flavio
AFAIK no, the declaration of the variables and their attributes is made during the assignment in the definition phase, the video at the follow link can be a good track for how to do it.
https://www.youtube.com/watch?v=WRqaw...
Hope this help you
BR
Flavio
by pratikyadav25 Rank: 382 on 7/15/2019 10:12:59 PM | Like (0) | Report
The following post is unanswered yet and doesn't help me much.
https://forum-controlsystems.abb.com/7183791/Retain-vs-Persistent
Add new comment