3 - 20 3 - 20
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
3.5 Specifying Data
There are three ways of assigning a value to a BASIC variable.
1) Use an assignment statement. (e.g., A=1, B=120)
2) Input from the keyboard or other device.
3) Use the READ - DATA instructions.
Method 2) is described in Section 3.11, and Chapter 4, 6, and 7. In this section,
methods 1) and 3) are described.
3.5.1 Assignment statements
The character "=" is used frequently in programs, but the meaning is somewhat
different from the mathematical "=."
To begin with, try executing the following program.
10 A=1
20 PRINT A
30 A=A+2
40 PRINT A
50 END
RUN
1
3
OK
Line 30 states that A=A+2. If this were an equation, the expression 0=2 would be
obtained by subtracting A from the both sides, which would be invalid. However, the
program runs properly.
The "=" character in BASIC means to assign the result of the expression, etc. on the
right side to the variable prepared in the left side. Line 30 thus means to add 2 to the
current value of A and to assign the result to the new A.
In other words, A=C+E is valid, but D+E=A will be invalid. Executing the following two
blocks will clarify the meaning of "=."
7 7
10 A=5:B=7
20 PRINT A, B
30 A=B
40 PRINT A, B
50 END
RUN
5 7
OK
10 A=5:B=7
20 PRINT A, B
30 B=A
40 PRINT A, B
50 END
RUN
5 7
5 5
OK
……
……
The value of B is assigned to A.
The value of A is assigned to B.
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...