0

I am receiving data into an array from the energy meters which is of REAL datatype. My array: ARRAY[0..49] OF Real; I want to convert this data into string data type like i want all the values enclosed in commas "" separately.

Waiting for your kind responce.

1 Answers1

1
(*Declaration part*)

aMyStringArray  : ARRAY[0..49] OF STRING;
aMyRealArray    : ARRAY[0..49] OF REAL;
i               : INT;
sMyLongString   : STRING(50*255);

(*Implementation part*)

sMyLongString := '';
FOR i:=0 TO 49 DO
    aMyStringArray[i] := REAL_TO_STRING(aMyRealArray[i]);
    sMyLongString := CONCAT(sMyLongString,'"');
    sMyLongString := CONCAT(sMyLongString,aMyStringArray[i]);
    sMyLongString := CONCAT(sMyLongString,'"');
    sMyLongString := CONCAT(sMyLongString,',');
END_FOR
Filippo Boido
  • 1,136
  • 7
  • 11
  • Thank You for your help. But it is returning result in array of string i just need a string like " "," "," ". Your kind help is needed – Maria Abdullah Jul 20 '19 at 04:32
  • You are welcome Maria, please mark my answer as the correct one so that others with a similar question can find it more easily. – Filippo Boido Jul 22 '19 at 05:40
  • I did but my profile repo is less than 15 so it is recorded but didnt mark. – Maria Abdullah Jul 22 '19 at 06:03
  • "To mark an answer as accepted, click on the check mark beside the answer to toggle it from greyed out to filled in." https://stackoverflow.com/help/someone-answers . You have to accept the answer instead of voting it up. – Filippo Boido Jul 22 '19 at 17:15