String_to conversions, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 1072

Advertising
background image

L-force | PLC Designer

Programming Reference

1070

DMS 4.1 EN 03/2011 TD29

Examples in IL:

(* Result is FALSE *)

(* Result is 29952 *)

(* Result is 129 *)

(* Result is 'DT#1998-02-13-14:20' *)

Examples in ST:

b :=DATE_TO_BOOL(D#1970-01-01);

(* Result is FALSE *)

i :=DATE_TO_INT(D#1970-01-15);

(* Result is 29952 *)

byt :=DT_TO_BYTE(DT#1970-01-15-05:05:05);

(* Result is 129 *)

str:=DT_TO_STRING(DT#1998-02-13-14:20);

(* Result is 'DT#1998-02-13-14:20' *)

Examples in FBD:

STRING_TO Conversions
IEC Operator: Converting from the variable type STRING to a different type.
The conversion works according to the standard C compilation mechanism: STRING to
INT and then INT to BYTE. The higher byte will be cut, thus only values of 0-255 result.
This way it is possible on most processors to generate optimal code because the
conversion can be performed by a single machine instruction.
Syntax for the conversion operator:
STRING_TO_<data type>
The operand from the STRING type variable must contain a value that is valid in the
target variable type, otherwise the result will be 0.

Advertising