Beckhoff Automation GmbH & Co. KG TX1200 — 7.2.9.3 STRING_TO conversions

Reference programming Example: Calling up the instance Inst from a function block where input variables Par1 and Par2 are 0 and TRUE respectively. CAL INST(PAR1 := 0, PAR2 := TRUE) 7.2.8.7 BITADR BITADR returns the bit address of allocated variable. Example in ST: bOFF AT%QX10.1 : BOOL; iBitAdr : BYTE; iBitAdr := BITADR( bOFF ); (* returns 81*) 7.2.9 Type Converting Operators 7.2.9.1 BOOL_TO conversions Converting from the BOOL type variable to a different type: For number type variables the result is 1 when the operand is TRUE and 0 when the operand is FALSE. The result is "TRUE" or "FALSE" respectively for STRING type variables. Examples in ST:

i:=BOOL_TO_INT(TRUE); (* Result is 1 *) str:=BOOL_TO_STRING(TRUE); (* Result is 'TRUE' *) t:=BOOL_TO_TIME(TRUE); (* Result is T#1ms *) tof:=BOOL_TO_TOD(TRUE); (* Result is TOD#00:00:00.001 *) dat:=BOOL_TO_DATE(FALSE); (* Result is D#1970-01-01 *) dandt:=BOOL_TO_DT(TRUE); (* Result is DT#1970-01-01-00:00:01 *) 7.2.9.2 TO_BOOL conversions Conversion from another variable type to BOOL:The result is TRUE when the operand is not equal to 0. The result is FALSE when the operand is equal to 0. The result is true for STRING type variables when the operand is "TRUE", otherwise the result is FALSE. Examples in ST:

b := BYTE_TO_BOOL(2#11010101); (* Result is TRUE *) b := INT_TO_BOOL(0); (* Result is FALSE *) b := TIME_TO_BOOL(T#5ms); (* Result is TRUE *) b := STRING_TO_BOOL('TRUE'); (* Result is TRUE *) 7.2.9.3 STRING_TO conversions Converting from the variable type STRING to a different 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. Examples in ST: b :=STRING_TO_BOOL('TRUE'); (* Result is TRUE *) w :=STRING_TO_WORD('abc34'); (* Result is 0 *) t :=STRING_TO_TIME('T#127ms'); (* Result is T#127ms *) TX1200 210 Version: 1.3