Specifying Data; Assignment Statements - Mitsubishi QD51 Programming Manual

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

3 LET'S CREATE AND EXECUTE A PROGRAM

3.5 Specifying Data

3.5.1 Assignment statements

3 - 20
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.
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 "=."
10 A=5:B=7
20 PRINT A, B
30 A=B
40 PRINT A, B
50 END
RUN
5 7
......
7 7
The value of B is assigned to A.
OK
10 A=5:B=7
20 PRINT A, B
30 B=A
40 PRINT A, B
50 END
RUN
5 7
......
5 5
The value of A is assigned to B.
OK
MELSEC-Q
3 - 20

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents