Download MELSEC iQ-F FX5 Programming Manual (Program Design)
Transcript
Syntax The following table shows the types of statements that can be used in a ST program. Item Description Reference Assignment statement Assignment statement Page 40 Assignment statement Sub-program control statement Function block call statement, function call statement Page 41 Sub-program control statement RETURN statement Conditional statement IF statement (IF, IF...ELSE, IF...ELSIF) Page 42 Conditional statement CASE statement Iteration statement FOR statement Page 43 Iteration statement WHILE statement REPEAT statement EXIT statement Write statements using half width characters. Assignment statement Format Description Example <Left side> := <Right side> ; The assignment statement assigns the result of the right side expression to the label or device of the left side. The result of the right side expression and the data type of the left side need to be the same data type. intV1 := 0; intV2 := 2; When an array type label or a structure label is used, check the data types of the left side and right side of the assignment statement. When an array type label is used, the data type and the number of elements need to be the same for the left side and right side. Do not specify elements. Ex. intAry1 := intAry2; When a structure label is used, the data type needs to be the same for the left side and right side. Ex. dutVar1 := dutVar2; ■Automatic conversion of data types In the ST language, if a different data type is assigned or a different arithmetic operation is described, the data type may be automatically converted. Ex. Example of automatic conversion dintLabel1 := intLabel1; // Assignment statement : Automatically convert the INT type variable (intLabel1) to a DINT type variable, and assign it the DINT type variable (dintLabel1). dintLabel1 := dintLabel2 + intLabel1; // Arithmetic operation expression : Automatically convert the INT type variable (intLabel1) to a DINT type variable, and perform DINT type addition. Type conversion is performed in an assignment statement, input argument pass to a function block and function (VAR_INPUT part), and an arithmetic operation. 40 6 ST LANGUAGE 6.1 Configuration