Bonjour,
La librairy est SYSMEM en Codesys v3.5.
Pour accéder à la fonction : SysMem.SysMemSet.
Il y a plein d'autres fonctions intéressantes : SysMemSwap, SysMemMove, SysmemCpy, ...
Cela évite de créer des Boucles et permet de bien utiliser ADR() et SIZEOF()
Il existe aussi une librairie CAA Memory qui mérite intérêt;
Par exemple MEM.MemFill pour remplir un tableau d'octets.
Bons développments!
Il suffit d'ajouter ces bibliothèques dans le gestionnaire de bibliothèque pour les utiliser.
JM
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I would like to know if it's possible to "Reset" all the index of an array to a value, with one line?
For example:
I have a array of 5 real. array[1]= 1.12, array[2]= 2.23, array[3]= 3.45, array[4]= 4.56, etc...
In a phase of my sequence, I need to "Reset" completely my array[] to a specific value, for example 0.
Is there any commands that allow that or should I use a Loop to "Reset" each index one by one...?
eg: array[1..5] := 0; or something like that?
Thank you for your help,
Regards,
Fred
Related
Talk.ru: 1
Talk.ru: 2
Talk.ru: 3
There is no standard way to do this.
However, if you don't aim platform independence, and your target platform support SysLibMem library, you might want to try:
SysMemSet(ADR(MyArray),0,SIZEOF(MyArray));
However, this only works, if you'd like to reset everything to 0, or it's an array of bytes.
I'm not sure about the performance difference between this solution and a standard ST for loop...
Hello,
Ok, I'm gonna to see if I have SysLibMem library.
I want reset all to '0', so it would be perfect.
Anyway, I can measure the time for performing the 2 methods and compare it... Finally a "For" Loop is not so big to write.
Thank you for your idea,
Regards,
Fred
Bonjour,
La librairy est SYSMEM en Codesys v3.5.
Pour accéder à la fonction : SysMem.SysMemSet.
Il y a plein d'autres fonctions intéressantes : SysMemSwap, SysMemMove, SysmemCpy, ...
Cela évite de créer des Boucles et permet de bien utiliser ADR() et SIZEOF()
Il existe aussi une librairie CAA Memory qui mérite intérêt;
Par exemple MEM.MemFill pour remplir un tableau d'octets.
Bons développments!
Il suffit d'ajouter ces bibliothèques dans le gestionnaire de bibliothèque pour les utiliser.
JM