{ } Include file reference
Causes ABL to retrieve the statements in a file and compile them as part of the main procedure if it encounters the file’s name inside braces ({}) when compiling the procedure. You can name arguments you want substituted in the file before compilation.
Syntax
Enter the braces ({}) as shown; they do not represent syntax notation in this description.
include-file
The name of an external operating system file that contains statements you want included during the compilation of a main procedure. This filename follows normal operating system naming conventions and is case sensitive on UNIX. If the file you name has an unqualified path name, ABL searches directories based on thePROPATH
environment variable.When ABL compiles the main procedure (the procedure containing the{
}
include file reference), it copies the contents ofinclude-file
into that procedure, substituting any arguments. So, you can use included procedures with arguments even when you precompile a procedure.argument
&argument-name = "argument-value"
A name/value pair used byinclude-file
as a named argument. Theargument-name
is the name of the argument you want to pass to the include file. You can use variable names, field names, and reserved words as argument names. Theargument-value
is the value of the argument you pass to the include file. Enclose theargument-value
in quotation marks, as shown.With named arguments,argument-value
replaces{&argument-name}
in the included file.ExamplesThe
r-inc1.p
procedure uses externally defined and maintained files (r-fcust.i
andr-dcust.i
) for the layout and display of a customer report. You can use these same include files in many procedures.
The
r-incl2.p
example references an include file (r-show.i
) that can take up to five arguments, and the main routine passes four arguments.
When the main procedure is compiled, the line referencing the
r-show.i
include file is replaced by the following line:
This example shows how you can use include files to extend ABL. The main procedure uses a new statement,
r-show.i
, to display the values of fields or variables at various points in a procedure. The include file in this example can handle up to five passed arguments. The main procedure only passes four (point-A, var1, var2, and var3).The
r-custin.p
procedure displays a frame for each customer that you can update with customer information. The procedure includesr-cstord.i
and passes the named argument&frame-options
, and the value of the argument (CENTERED ROW 3 NO-LABEL) to the include file. When the include file references the&frame-options
argument, it uses the value of the argument, and therefore displays the OVERLAY framecust-ord
as a centered frame at row 3 without a label.
Include files are particularly useful for using form layouts in multiple procedures, especially if you do not include the keyword FORM or the closing period (.) of the FORM statement. Thus, the following
r-incl3.p
procedure includes ther-cust.f
file as the definition of a FORM statement.
The
r-incl4.p
procedure uses the same include file as a layout for a DISPLAY statement:
Notes
- You can pass a series of positional arguments or a series of named arguments to an include file, but you cannot pass a combination of positional and named arguments to an include file.
- When you use braces to include one procedure in another, ABL does not include the second procedure until it compiles the first one. This technique has the same effect as using the Editor to copy statements into the main procedure. At times, separate include files are easier to maintain.
- You can nest include files. (They can contain references to other include files.) The number of nested include files is limited by the number of file descriptors available on the system.
- If you have many nested include files and you are running on a Sequent machine, use Maximum Files (
-Mv
) startup parameter to control the number of files you can open simultaneously.- When you have a base procedure and want to make several copies of it, changing it slightly each time, use include files with parameters. For example, at times you might only want to change the name of some files or fields used by the procedure.
- If you define a preprocessor name and later pass a compile-time argument with the same name, but a different value, to a procedure or include file, the value of the initial preprocessor name remains unchanged. Thus, a compile-time argument is scoped to the file to which it is passed.
- Instead of maintaining duplicate source files, create a single include file with the variable portions (such as the names of files and fields) replaced by {1}, {2}, etc. Then each procedure you write can use that include file, passing file and field names as arguments.
- You can use the name of an include file as an argument to another include file. For example, a reference to {{1}} in an include file causes ABL to include the statements from the file with the name that passed as the first argument.
- ABL disregards an empty pair of braces ({}).
- If you use double quotes (“ ”) around arguments in an argument list, ABL removes them. However, if you use single quotes (’ ’), ABL passes them. To pass one set of double quotes, you must use four sets of double quotes.
- When ABL reads an include file into the source, it appends a space character to the end of an include file. For example, the following include file
r-string.i
contains data that is used byr-incstr.p
.
Althoughr-string.i
contains five letters, when you runr-incstr.p
, it returns the value 6 because ABL appends a space character to the end ofr-string.i
.- The maximum length of the arguments you can pass to an include file is determined by the Input Characters (
-inp
) startup parameter.See also{ } Argument reference, { } Preprocessor name reference, COMPILE statement, DEFINE PARAMETER statement, RUN statement
OpenEdge Release 10.2B
|