I have to set the content of several numeric variables (basically INT) into a text file as I want to do a kind of backup of the data get from the PLC inputs.
I need to build a long string by transforming the data of all the Integers (in oder to make this text file easily analysable) and enter this string as an input of the function "SysFileWrite" of the library SysLibFile.lib.
Is there any command or function (INT_TO_STRING() ) which allow me to do this conversion, equivalent to these C examples: (char)int_variable or printf("%d", int_variable)?
Thanks to all!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
rgumara hat geschrieben:
I need to build a long string by transforming the data of all the Integers (in oder to make this text file easily analysable) and enter this string as an input of the function "SysFileWrite" of the library SysLibFile.lib.
See example:
PROGRAMPLC_PRGVAR
  iVar: ARRAY [0..10] OFINT :=0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
  strString: STRING;
  i: INT;END_VARIFi<>11THEN
  strString :=CONCAT(strString, INT_TO_STRING(iVar[i]));    (*insert a variable into the line*)
  strString :=CONCAT(strString, '');                (*insert space between variables*)
  i :=i+1;END_IF;
You may not use an array of variables. In this way your program will be a little bit bigger:
PROGRAMPLC_PRGVAR
  iVar1, iVar2, iVar3: INT;
  strString: STRING;
  i: INT;END_VARIFi<>4THEN
  strString :=CONCAT(strString, INT_TO_STRING(iVar1));
  strString :=CONCAT(strString, '');
  strString :=CONCAT(strString, INT_TO_STRING(iVar2));
  strString :=CONCAT(strString, '');
  strString :=CONCAT(strString, INT_TO_STRING(iVar3));
  i :=i+1;END_IF;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
I have to set the content of several numeric variables (basically INT) into a text file as I want to do a kind of backup of the data get from the PLC inputs.
I need to build a long string by transforming the data of all the Integers (in oder to make this text file easily analysable) and enter this string as an input of the function "SysFileWrite" of the library SysLibFile.lib.
Is there any command or function (INT_TO_STRING() ) which allow me to do this conversion, equivalent to these C examples: (char)int_variable or printf("%d", int_variable)?
Thanks to all!
See example:
You may not use an array of variables. In this way your program will be a little bit bigger:
use INT_TO_STRING and to make it a nice line begin with a "and use "," in between and end with a "and a CRLF (13).
please also add the time so you know when it happens.