Instead you can use a more modern approach via a UNION for this kind of operations as it is meant for this.
I'd suggest something like the following example;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2018-09-20
Originally created by: ph0010421
Inside a FOR loop...
StringArray[i] := DINT_TO_STRING(DintArray[i]);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2018-09-21
Originally created by: rickj
If you want to convert the numeric value of each DINT array element then use ph0010421's method. If the DINT array contains ascii data then use Aliazzz's method.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hello ,
I am New In PLC programming And I Need Help.
I have Array Of DINT Which I want to Convert Into STRING Or ARRAY Of STRING , How Can I Do it ?
Thanks a Lot
Anu
more posts ...
see its so simple
no need to use any conversion
codesys is best for this
you just define dint variable at some physical address
define string array on the same address thats it
e.x Dintarray: array[0..30] of DINT AT %MDW100;
Dintarray_STRING: array[0..30] of STRING AT %MDW100;
Instead you can use a more modern approach via a UNION for this kind of operations as it is meant for this.
I'd suggest something like the following example;
See CODESYS help on UNION datatypes;
https://help.codesys.com/webapp/_cds_datatype_union;product=codesys;version=3.5.12.0
Hello!
The size of
ardiMyArr
is not 5x4 = 20 bytes?Thanks in advance!
Originally created by: ph0010421
Inside a FOR loop...
StringArray[i] := DINT_TO_STRING(DintArray[i]);
Originally created by: rickj
If you want to convert the numeric value of each DINT array element then use ph0010421's method. If the DINT array contains ascii data then use Aliazzz's method.
Last edit: Sangchin 2023-12-03