3 - 49 3 - 49
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
(3) When a portion of the program is shared
The MERGE and DELETE options of the CHAIN instruction are used when a
certain portion of the current program is to be switched with another program.
70 PRINT "Program B executed!!"
80 A=4:GOSUB 1000
90 END
SAVE " PRO-B"
OK
NEW
OK
10 PRINT "Program A executed!!"
20 A=7:B=3:GOSUB 1000
30 CHAIN MERGE " 0:PRO-B" , 70, ALL, DELETE 10-30
1000 PRINT " A=" ;A
1010 PRINT " B=" ;B
1020 RETURN
SAVE " PRO-A"
OK
RU N
Program A executed!!
A= 7
B= 3
Program B executed!!
A= 4
B= 3
OK
LIST
70 PRINT "Program B executed!!"
80 A=4:GOSUB 1000
90 END
1000 PRINT " A=" ;A
1010 PRINT " B=" ;B
1020 RETURN
OK
Lines 90 through 30 of the
current program will be
deleted and the "PRO-B.BAS"
program will be added.
…………
Contents of "PRO-B.BAS"
The original program
contents
A
10
20
30
60
10
20
30
60
A
40
50
DELETE
option
MERGE
option
I'll erase this part since
I don't need it.
I'll add this.
The transfer of variable contents using the ALL option and COMMON
instruction can be used even when the DELETE and MERGE options
are used in the CHAIN instruction.