INCLUDE
copycode-name
[operand1]
99 |
This document covers the following topics:
For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.
The INCLUDE
statement is used to include source lines from
an external object of type copycode into another object at compilation.
The INCLUDE
statement is evaluated at compilation
time. The source lines of the copycode will not be physically included in the
source of the program that contains the INCLUDE
statement, but
they will be included during the program compilation and thus in the resulting
object module.
Caution:
A source code line which contains an INCLUDE
statement must not contain any other statement.
Operand Definition Table:
Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1
|
C | A | U | no | no |
Syntax Element Description:
Syntax Element | Description |
---|---|
copycode-name
|
Copycode Name:
As
The object you specify must be of the type
copycode. The copycode must be
contained either in the same library as the program which contains the
When the source of a copycode is modified, all programs using that copycode must be compiled again to reflect the changed source in their object codes. The source code of the copycode must consist of syntactically complete statements. |
operand1
|
Insert Values for Dynamic Insertion:
You can dynamically insert values in the copycode which is
included. These values are specified with
In the copycode, the values are referenced with the following notation: &n& That is, you mark the position where a value is to be inserted with
For every You may write one copy code parameter
( A string may follow one or several copy code parameters without a
blank (that is, Note: Values that are specified in the |
Example 2 - INCLUDE Statement Including Copycode with Parameters
Example 4 - INCLUDE Statement with Concatenated Parameters in Copycode
** Example 'INCEX1': INCLUDE (include copycode) ************************************************************************ * WRITE 'Before copycode' * INCLUDE INCEX1C * WRITE 'After copycode' * END
** Example 'INCEX1C': INCLUDE (copycode used by INCEX1) ************************************************************************ * WRITE 'Inside copycode'
Page 1 05-01-25 16:26:36 Before copycode Inside copycode After copycode
** Example 'INCEX2': INCLUDE (include copycode with parameters) ************************************************************************ DEFINE DATA LOCAL 1 EMPL-VIEW VIEW OF EMPLOYEES 2 NAME END-DEFINE * * INCLUDE INCEX2C 'EMPL-VIEW' 'NAME' '''ARCHER''' '20' '''BAILLET''' * END
** Example 'INCEX2C': INCLUDE (copycode used by INCEX2) ************************************************************************ * Transferred parameters from INCEX2: * * &1& : EMPL-VIEW * &2& : NAME * &3& : 'ARCHER' * &4& : 20 * &5& : 'BAILLET' * * READ (&4&) &1& BY &2& = &3& DISPLAY &2& IF &2& = &5& WRITE 5X 'LAST RECORD FOUND' &2& STOP END-IF END-READ * * Statements above will be completed to: * * READ (20) EMPL-VIEW BY NAME = 'ARCHER' * DISPLAY NAME * IF NAME = 'BAILLET' * WRITE 5X 'LAST RECORD FOUND' NAME * STOP * END-IF * END-READ
Page 1 05-01-25 16:30:43 NAME -------------------- ARCHER ARCONADA ARCONADA ARNOLD ASTIER ATHERTON ATHERTON ATHERTON AUBERT BACHMANN BAECKER BAECKER BAGAZJA BAILLET LAST RECORD FOUND BAILLET
** Example 'INCEX3': INCLUDE (using nested copycodes) ************************************************************************ DEFINE DATA LOCAL 1 #A (I4) END-DEFINE * MOVE 123 TO #A WRITE 'Program INCEX3 ' '=' #A * INCLUDE INCEX31C '#A' '5' /* source line is #A := 5 * * MOVE 300 TO #A WRITE 'Program INCEX3 ' '=' #A * INCLUDE INCEX32C '''#A''' '''20''' /* source line is #A := 20 * WRITE 'Program INCEX3 ' '=' #A END
** Example 'INCEX31C': INCLUDE (copycode used by INCEX3) ************************************************************************ * Transferred parameters from INCEX3: * * &1& : #A * &2& : 5 * * &1& := &2& * WRITE 'Copycode INCEX31C' '=' &1&
** Example 'INCEX32C': INCLUDE (copycode used by INCEX3) ************************************************************************ * Transferred parameters from INCEX3: * * &1& : '#A' * &2& : '20' * * WRITE 'Copycode INCEX32C' &1& &2& * INCLUDE INCEX31C &1& &2&
Page 1 05-01-25 16:35:36 Program INCEX3 #A: 123 Copycode INCEX31C #A: 5 Program INCEX3 #A: 300 Copycode INCEX32C #A 20 Copycode INCEX31C #A: 20 Program INCEX3 #A: 20
** Example 'INCEX4': INCLUDE (with concatenated parameters in copycode) ************************************************************************ DEFINE DATA LOCAL 1 #GROUP 2 ABC(A10) INIT <'1234567890'> END-DEFINE * INCLUDE INCEX4C '#GROUP.' 'ABC' 'AB' * END
** Example 'INCEX4C': INCLUDE (copycode used by INCEX4) ************************************************************************ * Transferred parameters from INCEX4: * * &1& : #GROUP. * &2& : ABC * &3& : AB * * WRITE '=' &2& /* 'ABC' results into ABC WRITE '=' &1&ABC /* '#GROUP.' ABC results into #GROUP.ABC WRITE '=' &1&&2& /* '#GROUP.' 'ABC' results into #GROUP.ABC WRITE '=' &1&&3&C /* '#GROUP.' 'AB' C results into #GROUP.ABC
Page 1 05-01-25 16:37:59 ABC: 1234567890 ABC: 1234567890 ABC: 1234567890 ABC: 1234567890