Chapter 1: Using Open PL/I

This chapter explains how to install the Open PL/I Compiler and how to enter, compile, link, and run Open PL/I programs.

Compiling a Program

Open PL/I consists of four executable programs:

Note that in the names mfpli and mfplx the fourth character is the lowercase letter "L".

mfpp is executed prior to the compilation, and its output is passed to the Open PL/I Compiler.

You can run mfpp directly, but the recommended way to run it is by use of the -macro option with mfplx when you are compiling your program. This allows the mfpp output to be automatically directed to the Compiler.

mfpli allows only one filename, accepts only Open PL/I Compiler options, and requires a separate ldpli step. The suffix of the filename to be compiled by mfpli is not restricted.

mfplx allows multiple filenames and accepts mfpli options as well as many standard UNIX or Windows system compiler and linker options, such as -c and -o. The -c option specifies compilation without linking. When -c is used, the -o option is passed to the compiler; when -c is not used, -o is passed to ldpli. Note that some file name suffixes are restricted to .pl1 or .pli when using mfplx.

mfvsam allows the creation of an indexed file, the addition or deletion of an index to an indexed file, and the display of information about an indexed file.

See the following sections for descriptions of the syntax to invoke mfpp, mfpli, mfplx, or mfvsam.

mfpp Syntax

The valid format for the mfpp command is:

mfpp [–ipath dir][-{isuffix|x} suffix] [–pp outfile]infile

where dir is a directory name, suffix defines a string to be appended to any unquoted filename in a %INCLUDE statement, infile specifies a source filename, and outfile specifies an output filename. At least one input file must be specified.

The preprocessor input is a file containing an Open PL/I source module, possibly including Open PL/I Macro Preprocessor statements. The preprocessor output is an Open PL/I source module containing no further preprocessor statements, but with the source code modified according to the semantics of the preprocessor statements that were encountered in the input file.

For information about options available for the mfpp command, see the section Preprocessor Options.

mfpp is usually run by use of the -macro option with mfplx. For more information, see the description of the -macro option in Table 1-3.

mfpli Syntax

The valid format for the mfpli command is:

mfpli [option] ... file [option]...

where option represents a Compiler option and file represents any single specified source file. There is no restriction on the suffix of the filename. option arguments can go either before or after file. (An error may result if the -I or -o option appears before file without specifying a list filename or object filename.)

mfplx Syntax

The valid format for the mfplx command is:

 mfplx {option | source_file | object_file} ...

where option represents an Open PL/I Compiler option or a system Compiler or linker option.

source_file represents any specified source file. Files with a .pl1 or .pli suffix are passed to mfpli. On UNIX systems, files with an .s suffix are passed to the system assembler. On Windows systems, files with an .asm suffix are passed to the system assembler.

mfplx supports wildcard characters and indirect files (@files).

object_file represents any specified object file (with an .o suffix for UNIX systems or a .obj suffix for Windows systems) or any specified library (with an .a suffix for UNIX systems or an .lib suffix for Windows systems). Files with an .o (or .obj) or an .a (or .lib) suffix are passed to mfpli, as are specified files with unknown or absent suffixes. The command line that mfpli constructs for each of these invocations is limited to 4096 characters. The .o files can be linked (possibly with other object files and/or libraries) using ldpli or mfplx -o.

mfplx processes options in one of the following ways:

For more information about Compiler options see the section Compiler Options. For more information on compiling and linking programs, see the sections Compiling a Program and Linking a Program, respectively.

Program execution begins at the main entry point. For more information, see the section Main Procedure .

mfvsam Syntax

The mfvsam utility is invoked by the command mfvsam. This utility offers the following options when invoked:

  1. Display information about a VSAM file.
  2. Create a VSAM file.
  3. Add an index to a VSAM file.
  4. Delete an index from a VSAM file.
  5. Exit.

Note:

The mfvsam utility currently produces indexed data files using the C-ISAM format only.

Open PL/I Compiler Implementation Limits

The Compiler generates messages if your source program exceeds certain Open PL/I Compiler implementation limits. The following table lists these implementation limits.

MessageLimit
Depth of nesting of a structure16
Length of a string constant254 1
Maximum length of a string constant with repeat specifier1018
Maximum length of a character string32767
Maximum length of source line320
Maximum size of storage for AREA data32767
Array dimensions8
Nesting level of INCLUDE statements7
Nesting of DO, PROCEDURE, BEGIN, SELECT, and simple ON-unit statements       64 2
Number of arguments in a subroutine or function call239
Number of errors100
Maximum VSAM key size120 bytes
Scale factor of variables0 ≤ scale factor ≤ 128
Scale factor of a constant0 ≤ scale factor ≤ 127
Scale factor of a conversion built-in function0 ≤ scale factor ≤ 127
Value of a format's repeat, w, or d field254
Precision for a fixed binary number31
Precision for a fixed decimal number18
Precision for a float binary number52
Precision for a float decimal number16
Internal Limits 
Number of tokens in a statement20,000
Table 1-1: Compiler Implementation Limits

Footnotes:

1.

The actual spelling of the constant is limited to 256 characters, where the spelling includes the surrounding quotation marks, the extra quotation mark when two single quotation marks represent a single quotation mark inside the string, and the possible trailing X in a hexadecimal string constant or the possibly trailing B and optional digit used to terminate bit-string constants.

2.

64 including the top level procedure.

Preprocessor Options

The options available for use with the mfpp command are explained in the following table. The -ipath and -suffix options obey the rules that apply when they are invoked as compiler options. For more details, see Table 1-3.

OptionExplanation
-define name[=value]     Causes value to be used in place of name wherever the identifier name appears.
-includesTells the preprocessor to process %INCLUDE statements.
-ipath dirThe -ipath and -suffix options obey the rules that apply when they are invoked as Compiler options. For more details, see the Table 1-3.
-isuffix suffix (or -x suffix)The -ipath and -suffix options obey the rules that apply when they are invoked as compiler options. For more details, see Table 1-3.
-margins I,rSets the margins within which characters of the source file are interpreted as source code and outside which all characters are ignored by the Compiler. l is the column number of the leftmost character and r is the column number of the rightmost character to be interpreted as source code. Note that, if tabs are used, each tab is counted as a single character.

The -margins option on a *PROCESS card is ignored if the macro pre-processor is in use (either by executing mfpp or mfplx with the -macro option); in this case, if the source margins are not 1,256, the actual margins must be specified with the -margins option.

-nodebuginfoSpecifies that the preprocessor will not generate the normal debug information that it passes to the Compiler. This is useful if you wish to debug using the post-preprocessing PL/I source file rather than the original source file.
-noincludesTells the preprocessor not to handle %INCLUDE statements.
-pp outfile (or -o outfile)Names the output file the name you specify with outfile. If -pp is not specified, the default name of the file is xxx.pp, where xxxis the input filename up to, but not including, the last "." (if any) in the name. For example, if the input filename is prog.pl1, the default output filename is prog.pp.
-TCauses the preprocessor to examine a %INCLUDE file name for the characters @, #, and $, and to replace @ with A, # with N, and $ with D.
-undefine nameRemoves a definition for name, if name was created by a -define option, and leaves the identifier name in the source as name. It does not preclude a %REPLACE statement or %name=expr from changing the value of name.
-variant stringSupplies a string to be used in place of the VARIANT built-in function.
Table 1-2: Preprocessor Options List

Precompiler and Preprocessor Order of Execution

The Open PL/I Macro Preprocessor and the precompilers used by Open PL/I are run by mfplx in the following order:

  1. Open PL/I Macro Preprocessor
  2. CICS Precompiler
  3. Oracle Pro*PL/I Precompiler or DB2 Precompiler

The ordering of the Compiler switches you use has no impact.

You may change the order, if necessary, by separately invoking the preprocessor and precompilers you choose.

Examples

Example 1: Equivalent to an ordinary compilation with -macro.

The command line

mfplx -macro sample.pl1 -#

produces:

mfpp sample.pl1 -pp sample.pp 
mfpli sample.pp -o sample.o 
rm -f sample.pp 
ldpli sample.o
Example 2: Equivalent to an ordinary compilation with -macro and two precompilers.

The command line

mfplx -oracle -macro sample.pl1 -unikix -#

produces:

mfpp sample-pl1 -pp sample.pp 
kixplt -i sample.pp -o sample.pp1 
propli sample.pp1 sample.pp3 
mfpli sample.pp3 -o sample.o 
rm -f sample.pp sample.pp1 sample.pp3 
ldpli sample.o
Example 3: Run macro preprocessor and CICS precompiler only, preserving the intermediate output files.

The command line

mfplx -E sample.pl1 -macro -unikix

produces:

mfpp sample.pl1 -pp sample.pp 
kixplt sample.pp -o sample.pp1
Example 4: Ordinary compile, preserving CICS precompiler output.

The command line

mfplx -unikix -ppcics cicsout.pl1 sample.pl1 -#

produces:

kixplt -i sample.pl1 -o cicsout.pl1
mfpli cicsout.pl1 -o sample.o 
ldpli sample.o
Example 5: Multiple compilations.

The command line

mfplx sample*.pl1 -db2 -unikix -#

produces:

kixplt -i sampleA.pl1 -o samp1eA.pp1 
lpicdb2 -i sampleA.pp1 -o sampleA.pp2 
mfpli sampleA.pp2 -o sampleA.o 
rm -f samp1eA.pp1 sampleA.pp2
kixplt -i sampleB.pl1 -o sampleB.pp1 
lpicdb2 -i sampleB.pp1 -o sampleB.pp2 
mfpli sampleB.pp2 -o sampleB.o
rm -f sampleB.pp1 sampleB.pp2 
ldpli sampleA.o sampleB.o

Compiler Options

Refer to the tables in this section for descriptions of the options available with your Open PL/I Compiler.

Table 1-3 lists and describes each of the Compiler options and its default setting, when applicable.

OptionExplanation
-#Provides information on how the Compiler and linker would be invoked without actually invoking them. This option also shows which UNIX options are translated to Micro Focus options; for example, when the standard UNIX -O option is given on the driver command line, it is translated on the Compiler invocation line as -opt.
-cSuppresses linking and produces a relocatable object file. This option applies to mfplx only.
-checkThis option, which can be used only with mfplx, causes the Open PL/I Source Checker to be run instead of the Open PL/I Compiler. (For details, see the chapter Open PL/I Source Checker.)
-unikixInvokes the CICS precompiler, kixplt. The default CICS precompiler output file name is xxx.pp1, where xxx is the name of the source file. If the -ppcics option is not specified, the file xxx.pp1 is deleted after the compilation phase is completed. The -unikix option applies to mfplx only.
-cicsdebugAllows use of CodeWatch to debug the PL/I code generated by the CICS precompiler for EXEC CICS statements, rather than debugging with the original source code. Also, causes Compiler diagnostics to use line numbers referencing the CICS precompiler output file. The -cicsdebug command applies to mfplx and kixplt only.
-db2Invokes the DB2 precompiler, lpidb2. The default DB2 precompiler output file name is xxx.pp2, where xxx is the name of the source file. If the -ppdb2 option is not specified, the file xxx.pp2 is deleted after the compilation phase is completed. The -db2 option applies to mfplx only.
-debProduces debugging information for CodeWatch, Micro Focus's source-level debugger. You must specify this option if you intend to use CodeWatch to debug this source. When using -deb, you may specify only optimization levels 1 or 2. For more information, see the section Optimization.
-default_binaryCauses the BINARY attribute to be assumed if the FIXED attribute is specified without BINARY or DECIMAL.
-default_decimal      Causes the DECIMAL attribute to be assumed if the FIXED attribute is specified without BINARY or DECIMAL. This option is the Compiler default.
-defextCauses external variables to be defined in the .data section. You must use this option for programs using external files.

The -defext option causes the initialized values of STATIC EXTERNAL variables and external file constants to be defined. Each STATIC EXTERNAL variable that has an INITIAL value must be declared in one and only one module that has been compiled with -defext. Failure to do so causes the INITIAL value to have no effect. The default is -nodefext.

Also, each file constant must be declared in one and only one module that has been compiled with -defext. When -defext is used, file attributes specified in the file declaration will be merged with attributes specified when the file is opened. This is critical when doing VSAM/INDEXED I/O.

-ECauses any specified precompilers or preprocessor (-macro, -unikix, -db2, -oracle) to be run on the source file, and saves their output, but stops without running the Compiler.
-expProduces an expanded listing of the generated code in the form of assembly language statements in the listing file. For more information, see the section The -exp Option.
-fdasfbCauses Float Decimal data to be internally coded as Float Binary. This option produces much faster code but loses precision in the least significant digits of arithmetic results. See also the -nofdasfb option.
-fmaxpCauses extended floating-point precision to be used for the trigonometric built-ins and for the following arithmetic built-ins: EXP, LOG, LOG10, LOG2, SQRT. -fmaxp is the default.
-highbif This compile-time switch allows changing the value returned by the HIGH() built-in function. For example, -highbif = 128 (the default value is 255; the value 128 maybe used for compatibility with earlier versions of Open PL/I).
-ipath dirlistDirects the Compiler to search specified directories for files to be included in the source program text by use of the %INCLUDE statement. dirlist is an ordered list of directories of the form
dirname[:dirname] ...

-ipath instructs the Compiler to use these directories in the specified order in its search for files to satisfy %INCLUDE statements (except in cases where an absolute directory path is specified in the %INCLUDE statement).

For example, suppose the source program contains:

%INCLUDE partlist;

and the Compiler invocation command is:

mfplx source_file -ipath .:/u/libr1:/u/libr2

In this case, the Compiler will first search for "PARTLIST" in the current working directory, then /u/ libr1, and finally /u/ libr2. If that fails, it will search for "partlist" (lowercase) in the same directories.

In a Windows environment, the equivalent Compiler invocation is:

mfplx source_file -ipath .;drive:\libr1;drive:\libr2
-isuffix stringCauses string to be appended to the filename specified in %INCLUDE statements, except those in which the quoted filename form of the %INCLUDE statement is used.

For example, suppose the source program contains:

%INCLUDE partlist;

and the Compiler invocation command is:

mfplx source_file -isuffix .INC

In this case, the Compiler will search for a file named "PARTLIST.INC".

-l [ file]Produces a Compiler listing where file is the name of the file to which the listing is output. If you do not supply a filename, you must place this option after the source filename on the command line; otherwise, an error message appears. The default name of the file containing the listing is xxx.list, where xxx is the source filename (excluding the pathname) up to, but not including, the last "." (if any) in the name. For example, if the source filename is prog.pl1, the default listing is prog.list (prog.lst for Windows systems). A Compiler listing is produced by default whenever -exp, -map, or -xref is specified. For more information, see the section The -l Option.
-longintChanges the default precision of Fixed Binary variables from (15) to (31).
-lowercaseConverts all uppercase names of internal and external variables and constants to lowercase. For additional information, see the section External Names in the chapter Language Concepts.
-macroInvokes the Open PL/I Macro Preprocessor, mfpp. The default preprocessor output file name is xxx.pp, where xxx is the name of the source file. If the -pp option is not specified, the xxx.pp file is deleted after the compilation phase is completed. The -macro option applies to mfplx only.
-mapProduces a storage allocation map at the end of the listing file. For more information, see the section The -map Option.
-margins 1,rSets the margins within which characters of the source file are interpreted as source code and outside which all characters are ignored by the Compiler. 1 is the column number of the leftmost character, and r is the column number of the rightmost character to be interpreted as source code. Note that if tabs are used, each tab is counted as a single character. The -margins option can be overridden by a *PROCESS statement in the source.

Note: There must be no spaces around the comma separating the left and right margin.

-nestIndicates the nesting level on the listing of DO ... END, PROC ... END, and so on.
-nocicsdebugAllows use of CodeWatch to debug the original source file, rather than the intermediate file generated by the CICS precompiler. Also, causes Compiler diagnostics to use line numbers referencing the original source file. This is the default. The -nocicsdebug command applies to mfplx and kixplt only.
-nofdasfbCauses Float Decimal data to be internally coded as Binary Coded Decimal. The default setting is -fdasfb.
-nofmaxpCauses standard PL/I conversion rules to be used to determine the precision of trigonometric and certain arithmetic built-ins. The default is -fmaxp.
-noincludesDirects the Compiler not to include the contents of %INCLUDE files in the listing file. The default is to include file contents in the listing file.
-nomacroSuppresses the invocation of the Open PL/I Macro Preprocessor. The default is -nomacro.
-noobjCompiles for syntax and semantic checking only. Does not produce an object file.
-nooptCompiles without optimization. This is the default.
-norangeSuppresses generation of code to check the validity of subscript references. This option should be used after your program has been debugged to improve execution time performance. The default is -norange.
-nounixdebugAvoids generating the additional object file data needed to report source file and line number when a fatal run-time error occurs, or for use by the ONLOC built-in function.
-nounrefexternalsPrevents external entry symbols that are not referenced in the program from being generated in the object file. This is the default.
-nowarnSuppresses all WARNING level diagnostics. For a description of the format and contents of the Compiler error messages, see the appendix Open PL/I Compiler Error Messages .
-O Invokes the optimization phase of the Compiler. This option applies to mfplx only and is equivalent to the -opt option.
-o fileNames the object file the name you specify with file. If -o is not specified, the default name of the file is xxx.o, where xxx is the source filename up to, but not including, the last "." (if any) in the name. For example, if the source filename is prog.pl1, the default object filename is prog.o (prog.obj for Windows).

If -c is specified, the -o option is passed to the compiler; if -c is not specified, -o is passed to ldpli.

-oldalignCauses the Compiler to allocate Character Varying items and align structure members as did releases of LPI-PL/I.
-opt [level]Specifies the level of optimization by the Open PL/I Compiler, where level stands for the level (1 – 3) of optimization. The default setting is -noopt. If level is not included, the program is optimized at level 3 unless -deb is specified. For more information, see the section Optimization.
-oracleInvokes the Oracle Pro*PL/I precompiler, propli. The default Pro*PL/I precompiler output file name is xxx.pp3, where xxx is the name of the source file. If the -pporacle option is not specified, the file xxx.pp3 is deleted after the compilation phase is completed. The -oracle option applies to mfplx only.
-picGenerates position-independent code, suitable for linking into a shared library. This option is only available on HP-UX, Solaris 2.x, DG-UX, and UNIX SVR4.
-pl1gCauses Open PL/I to retain the behavior of releases prior to Open PL/I 5.0 for certain operations that have been changed in such a way as to become incompatible with that former behavior. For example, TIME() returns a value including three fractional digits (thousandths), but -pl1g causes it to return only two fractional digits (hundredths).
-pp [file]Specifies the file name for the output file of the Open PL/I Macro Preprocessor. An output file created with the -pp option is preserved after the compilation phase is completed. This option applies to mfplx and mfpp only.
-ppcics [file]Specifies the file name for the output of the CICS precompiler. An output file created with the -ppcics option is preserved after the compilation phase is completed. This option applies to mfplx only.
-ppdb2 [file]Specifies the file name for the output of the DB2 precompiler. An output file created with the -ppdb2 option is preserved after the compilation phase is completed. This option applies to mfplx only.
-pporacle [file]Specifies the file name for the output of the Oracle Pro*PL/I precompiler. An output file created with the -pporacle option is preserved after the compilation phase is completed. This option applies to mfplx only.
-rangeGenerates code to check the validity of all subscript references. (Note that checking code slows down execution time performance.) We recommend that this option be used to debug programming errors relating to subscripting, and that the -norange option be used for debugged code. The default is -norange.
-report [file]
Specifies the file name for the output of the Open PL/I Source Checker. If this option is not used, the output of the checker will be directed to the standard error file. This option applies to mfplx only.
-setnull nDesignates a null pointer value n to be returned by the NULL built-in function, where n is a decimal value. If this option is not specified, the value of the NULL built-in function is an address with all bits set to 1.
-stardescTells the Compiler to produce argument descriptors for calls only when array bounds or string lengths in the parameter declaration are represented by the asterisk (*) symbol. (This was compiler behavior in releases prior to release 7.0.) When this option is not used, the Compiler produces descriptors for array, structure, and string arguments, which can be a problem for very large structures.
-statPrints Compiler statistics to the standard output as each Compiler phase completes. For more information, see the section Compilation Statistics.
-unalignedThis compile-time switch has been added for use on RISC architectures. This switch causes byte instructions to be generated for all based references, which might point anywhere in memory.
-unrefexternalsCauses external entry symbols to be generated in the object file, even if they are not referenced in the program.
-vPrints information to stdout relating to the compilation and link-step phases. This option applies to mfplx only.
-variant stringPasses the variant string string to the Open PL/I Macro Preprocessor. This option applies to mfplx only.
-vaxMakes the following adaptations for programs originally written with Digital Equipment Corporations's PL/I Compiler for the VAX platform:
  • Enables the Fixed Binary(p ≤ 7) data type as a one-byte signed binary integer.
  • Enables Float Binary(24) as equivalent to Float Binary(23).
  • Enables Float Binary(53) as equivalent to Float Binary(52).
  • Causes the BINARY attribute to be assumed if the FIXED attribute is specified without BINARY or DECIMAL.
-warnDoes not suppress level 1 (WARNING) messages. This is the default.
-xrefProduces cross-reference information in the listing file. See "The -xref Option" for more information.
-zp1Causes all structures to be mapped as if the UNALIGNED attribute is specified at the level 1 structure level. This option is for compatibility with versions of DEC VAX PL/I.
Table 1-3: Compiler Options List

Intel-Specific Options

Table 1-4 names and describes each Intel-specific option and its default setting, where applicable. Use the default settings of the Compiler options to generate the most efficient code for your system.

OptionExplanation
-codealign argument    Controls alignment of the generated code where argument is a concatenation of one or more of the following suboptions. Note that each suboption must be followed by a number that is one of 4, 8, or 16; this subargument is referred to as align in the descriptions.
jAlign each label that follows an unconditional jump or a return to be at an address such that mod(address, align)=0. The NOPs that are inserted are never executed.
eAlign each entry point such that mod(address, align)=0.
IAlign loop tops such that mod(address, align)=0.
hUse heuristics to attempt to align labels that do not follow jumps such that mod(address, align)=0, but without inserting any NOP instructions. If align is followed by ".1", alignment will be such that mod(address, align)=0 or 1. The suboptions tell the Compiler where to insert NOP instructions to force the address of critical instructions in generated code to be aligned on boundaries that improve the performance of jumps and calls to those instructions.
-f287Generates Intel287 floating-point coprocessor instructions where possible. This is the default if an Intel387 coprocessor is not present.
-f387Generates Intel387 floating-point coprocessor instructions where possible. This is the default if an Intel 80387 coprocessor is present. If an Intel387 coprocessor is not present, the default generates Intel287 floating-point instructions.
-i386Produces code for the Intel386 processor avoiding optimizations designed for the Intel486 processor. Programs compiled with the -i386 option run correctly on the Intel486, but may perform better when they are compiled with the -i486 option. -i386 is the default when the Compiler is run on an Intel386 processor.
-i486Produces code for the Intel486 processor, using optimizations designed for the Intel486. Programs compiled with the -i486 option may not run on an Intel386 processor. -i486 is the default when the Compiler is run on an Intel486 processor.
-ix86Produces code that will run well on both the Intel486 and the Pentium CPUs.
-PentiumProduces code for the Pentium processor. This is the default when the Compiler is run on a Pentium processor.
Table 1-4: Intel-Specific Options

Compiler Listings

The Compiler listing options are:

All listing information is directed to the listing file. When any of the listing options are specified, the -l option is invoked by default.

The -l Option

The -l option produces a listing file, which is named by default with the source program name (up to but not including the last ".") and the suffix .list. You can choose another name for the listing file by specifying a name after the -l option, in the following format:

-l file

The listing file contains a program listing, which consists of a copy of the source program with line numbers beginning at 1 in a column to the left of the source line.

The -map Option

The -map option produces a storage allocation map, which displays the location and allocation size of each program entity. The map categorizes this information by name, class, size, location, and attributes.

This information is presented in five columns:

ColumnDescription
NAMEIndicates the name of each entity in the program.
CLASSIndicates the storage class of each program entity; for example, AUTOMATIC, CONSTANT, STATIC, PARAMETER, CONTROLLED, or BASED.
SIZEIndicates the size of the entity, usually in bytes. If the size is measured in bits, the size number is followed by a B. If the size of the entity is not constant, a -V- is displayed in the location listing. Entities of class ENTRY or BUILTIN have no size or location listing.
LOCATIONGives the offset location of the entity in hexadecimal notation.
  • For automatic variables, the location column gives the memory offset from the frame pointer
  • For static variables, it gives the memory offset from the beginning of static data
  • For controlled and based variables, it displays the value -V-
ATTRIBUTES     Displays the data type of the entity, for example, FIXED DEC, FLOAT BIN, CHAR, CHAR VAR, BIT ALIGNED, and ENTRY.

Displays BUILTIN for an entity of BUILTIN class. Displays the precision and scale of the entity, where applicable, in parentheses: for example, FIXED BIN(15,0).

Program entities are listed in the order in which they appear in the procedure.

The map first lists external entry points to the program: external constants, subroutines, or programs, including the source program itself. These entry points are listed with name, class, and attributes.

The map then lists program procedures and entities by line number.

The -xref Option

The -xref option provides cross-reference information for each program entity, displaying the line number on which it was declared and the line numbers of all references to it.

The -xref listing for a program is added to the map listing; when you specify the -xref option, you receive a data storage allocation map by default. The cross-reference information appears on the map in the ATTRIBUTES column for each entity, after the line of map attributes information.

References to each entity are listed in the following format:

 DEF line_number REF line_number[...]

A sample map listing with the -xref option follows.

Figure 1-1 Sample Output from the -xref Option

EXTERNAL ENTRY POINTS 
NAME         CLASS           SIZE  LOCATION  ATTRIBUTES 
SYSPRINT     CONSTANT                        FILE EXTERNAL 
                                             DEF 41 REF 41 48 49 
PRIMES       CONSTANT                        ENTRY(MAIN)EXTERNAL
PROCEDURE PRIMES ON LINE 10 
NAME         CLASS           SIZE  LOCATION  ATTRIBUTES 
STORE_CLASS  CONSTANT                        ENTRY 
                                             DEF 90 REF 45 
ARITH_STR    CONSTANT                        ENTRY 
                                             DEF 56 REF 43 
PROCEDURE ARITH_STR ON LINE 56
NAME         CLASS           SIZE  LOCATION  ATTRIBUTES 
DECIMAL      BUILTIN                   BUILTIN 
ESC          AUTOMATIC 6     FFFFFFD8  PICTURED 
FLT_BIN      AUTOMATIC 4     FFFFFFE4  FLOAT BIN(15) 
                                       DEF 63 REF 71 
FIX_DEC      AUTOMATIC 3     FFFFFFEC  FIXED DEC(4,2) 
                                       DEF 62 REF 70
CHR_STR      AUTOMATIC 4     FFFFFFEO  CHAR(4) 
                                       DEF 61 REF 69 
BIT_STR      AUTOMATIC 4B    FFFFFFD4  BIT(4) 
                                       DEF 60 REF 68 
PROCEDURE STORE_CLASS ON LINE 90 
NAME         CLASS     SIZE  LOCATION  ATTRIBUTES 
NUMBER       AUTOMATIC 16B   FFFFFFE8  UNION 
 FIXED_N     MEMBER    2     00000000  FIXED BIN(15,0) 
 FIXED_N_BIT MEMBER    16B   00000000  BIT(16) 
STAT_A_EX    STATIC    3     External  FIXED DEC(5,0)EXTERNAL 
Y            BASED     4     -V-       FLOAT BIN(23)

The -exp Option

The -exp option produces an expanded code listing at the end of the listing file, providing the location and low-level language translation for each instruction and label in the program. The following information is displayed for each statement, in five columns:

ColumnDisplays
FirstThe source statement line number.
Second     The offset location of each instruction in the statement.
ThirdThe hexadecimal representation of each instruction.
FourthThe instruction in a pseudo-assembly code dialect.
FifthInformation about the operands used by each instruction.

Compilation Statistics

The -stat compiler option provides a listing of statistics for each phase of the compilation. The statistics are displayed at the terminal by default or can be redirected to a file. The following figure is a sample terminal display from a UNIX system.

Figure 1-2 Sample Output from the -stat Option (UNIX)

PHASE            USER     SYSTEM    CPU  REAL  13:43:26 
Parser Pass 1    0.05       0.02   0.07     0  13:43:26 
Declare          0.00       0.00   0.00     0  13:43:26 
Parser Pass 2    0.08       0.03   0.11     0  13:43:26 
Allocator        0.01       0.00   0.01     0  13:43:27 
Code Generator   0.71       0.05   0.76     1  13:43:27 
Total            0.85       0.10   0.95     1  13:43:27 

Total source lines:                  38 
Lines per minute (CPU):           2,400 
Lines per minute (real):          2,280 

Text size:                 2,574 bytes 
Data size:                   914 bytes 
Bss Size:                      0 bytes

The following names and describes each of the columns displayed in the printout.

ColumnDescription
PHASEDefines the various phases of the compilation. Each phase and its corresponding statistics displays upon completion.
USER Indicates the CPU time spent on this phase of compilation, excluding CPU time spent by the operating system on behalf of the Compiler.
SYSTEM Indicates the CPU time used by the operating system while executing the corresponding phase.
CPUIndicates the CPU time used by the Compiler while executing the corresponding phase. This is simply the sum of USER and SYSTEM.
REAL Indicates the number of seconds elapsed during the corresponding phase.
The final column    Displays the current time of day in 24-hour notation (on Intel systems only).

Temporary Files

Compiler-generated temporary files are normally placed in the /tmp directory. If you wish to put them in your current working directory, use the command appropriate to your shell program.

Bourne/Korn shell users:    TMPDIR=. ; export TMPDIR
C shell users:setenv TMPDIR .

To store Compiler-generated temporary files elsewhere, specify a pathname by using the command appropriate to your shell program.

Bourne/Korn shell users:    TMPDIR=pathname; export TMPDIR
C shell users: setenv TMPDIR pathname
Windows users:set TMPDIR=pathname

Optimization

By default, programs are not optimized during compilation. You can specify optimization at level 1, 2, or 3, using the following syntax:

-opt level

For example, "-opt 2". If you specify -opt with no level, level 3 optimizations are performed by default. (Remember that if you use the -deb option, only level 1 or 2 is allowed. If you use -deb and specify -opt with no level, level 2 optimizations are performed.) A brief description of the optimizations performed at each level follows.

Level     Description
1 Operator pattern replacement and Boolean conditional expression optimizations.
2 Common subexpression elimination; all level 1 optimizations.
3 All level 1 and level 2 optimizations plus the following:
  • branch chaining
  • dead code elimination
  • strength reduction
  • loop induction
  • loop invariant code motion
  • removal of redundant register saves and loads
  • removal of mathematical identities

Linking a Program

You can use either static or dynamic linking of Open PL/I applications. The Open PL/I run-time library is built both as a static library (.lib) and as a dynamic link library (.dll). The ldpli link-step uses the static version of the Open PL/I run-time library by default. To link dynamically, use

ldpli -dll [options…]

Note:

You should add both %MFPLI_PRODUCT_DIR%\bin and %MFPLI_PRODUCT_DIR%\dll to the %PATH% environment variable.

To link an Open PL/I program, use either mfplx or ldpli.

Link Options

Table 1-5 lists link options that permit the use of Open PL/I with other software products. For more information, see the section Using Open PL/I with Other Software Products.

Option     Explanation
-cisamEnables the C-ISAM package from Informix Software for support of VSAM/indexed files.
-tisamEnables the TISAM package from Transarc for VSAM/indexed files, using Transarc's SFS format.
Table 1-5: Link Options List

Using ldpli

ldpli references the components, such as libraries, that were installed with Open PL/I. ldpli generates executable files from relocatable object files.

Note: The first and fourth characters of the ldpli command are lowercase letter "L".

The ldpli command-line syntax is as follows:

ldpli [option] ... object_file [object_file] ... [optional_library] ...

where

ldpliThe command that invokes the linker.
option Represents all valid linker options. Any of the valid UNIX or Windows system linker command options are accepted. See your operating system reference manual for a listing and description of all valid system linker options.
object_file Specifies object files that are to be linked.
optional_library     Represents library specifications for libraries that are required for your special application. These are needed only if you explicitly CALL library routines from your program. The standard system libraries, such as libc.a on a UNIX system, are always included in the link.

Using ldpli with Windows Systems

In addition to supporting all LINK32 options, ldpli includes the following support for Windows systems:

ldpli enhances the default behavior of the following LINK32 options:

If -deb was used on the command line at compilation time for debugging purposes with CodeWatch, -deb must also be supplied on the command line to ldpli. If using mfplx for both compilation and linking, mfplx will automatically invoke ldpli with -deb.

Running a Program

To run an Open PL/I program, invoke the executable object file produced by the link utility.

The name of the executable object file produced by the linker defaults to a.out. However, if you include the -o filename option on the link command line, the executable object file has the filename that you specified.

For example, "-o sample" on the mfplx command line produces an executable object file named "sample".

Run-time Errors

If an error occurs at run time, a message appears on the terminal. For a description of run-time error conditions and messages, see the appendix Open PL/I Run-time Error Messages .

You can use Open PL/I's ON statement to develop handlers for the conditions that can occur in your program. The ON ERROR statement can be used for arbitrary errors. The ONLOC built-in function can be used in an ON-unit to report the name of an entry in which a condition was raised, and the ONCODE built-in function can be used to report the status value of a run-time error.

Note:

If an error is not caught by an ON-unit, Open PL/I displays the source file and line number where the error occurred. For these features to work, however, you must have compiled the source file with the default option -unixdebug.

This feature is currently available only in the HP-UX, Sun Solaris 2, and IBM AIX versions of Open PL/I.

When a fatal error condition occurs at run time, a message is displayed naming the condition that has been raised; the program address where this occurred; and the source file, entry, and line number at which the condition was raised, as well as the lines in each procedure above it in the call stack. For example:

*** Condition ERROR raised 
***Unhandled condition ZERODIVIDE at PC=00010233 
CALCDIV line 26 in /dirl/dir2/calcs.pl1 
SUBR3 line 444 in /dirl/dir2/subprog.pl1 
MYPROG line 871 in /dirl/dir2/mainprog.pl1

In this example,

CALCDIVIs the entry in which the "ZERODIVIDE" condition was raised.
SUBR3Is the entry that called "CALCDIV" (at line 444).
MYPROG    Is the program that called SUBR3.

If you have compiled your program using the -nounixdebug option, only the program address where the condition was raised will be displayed:

*** Condition ERROR raised 
*** Unhandled condition ZERODIVIDE at PC=00010233

Accessing Command-Line Arguments in Open PL/I Programs

It is sometimes useful to be able to execute a program specifying one or more arguments on the command line in order to cause a variation in the program's behavior. For example, to run a departmental expense report program, you might issue the command deptexp summary to indicate that you wish to see only category totals rather than all the line items.

Command-line arguments can be accessed in a PL/I main program using the following technique:

/* PL/I main program accessing command line args. */ 

PMAIN: PROCEDURE OPTIONS(MAIN); 

   DECLARE ARGC_     FIXED BIN(31) EXTERNAL STATIC; 
   DECLARE ARGV_     POINTER EXTERNAL STATIC; 
   DECLARE ARG(10)   POINTER BASED; 
   DECLARE ARGS      CHAR(50) BASED; 
   DECLARE ARGSV     CHAR(50) VARYING; 
   DECLARE I         FIXED BIN(31); 

   PUT SKIP EDIT(ARGC_)(f(2)); 
   DO I = 1 TO ARGC_; 
      ARGSV = SUBSTR(ARGV_->ARG(I)->ARGS,1,
            INDEX(ARGV_->ARG(I)->ARGS,BYTE(0))-1); 
      PUT SKIP EDIT('"',argsv,'"')(a,a,a); 
      END; 
   PUT SKIP; 

   END PMAIN;

If your PL/I program is controlled by a C main program, you can pass the command-line arguments through to the PL/I program in the following manner:

/* C main program calling PL/I subroutine */ 

main(argc,argv) 
   int argc; 
   char **argv;
{ 
   PSUBR(argc,argv); 
}

/* PL/I subroutine receiving command line args 
   from C main program */ 

PSUBR: PROCEDURE(ARGC,ARGV); 

   DECLARE ARGC      FIXED BIN(31) VALUE;
   DECLARE ARGV      POINTER VALUE; 
   DECLARE ARG(10)   POINTER BASED; 
   DECLARE ARGS      CHAR(50) BASED; 
   DECLARE ARGSV     CHAR(50) VARYING; 
   DECLARE I         FIXED BIN(31); 

   PUT SKIP EDIT(ARGC)(f(2)); 
   DO I = 1 TO ARGC; 
      ARGSV = SUBSTR(ARGV->ARG(I)->ARGS,1, 
            INDEX(ARGV->ARG(I)->ARGS,BYTE(0)));
      PUT SKIP EDIT('"',ARGSV,'"')(a,a,a); 
      END; 
   PUT SKIP; 

END PSUBR;

Associating a Logical Open PL/I File with a Physical Disk Data File

Open PL/I supports a number of ways to associate your physical disk data files with the logical file names used in Open PL/I sources.

Method 1 (Default)

The run-time environment will use the name of the file variable (or constant) used in the source, shifted to all uppercase.

Example
dcl Payroll file input; 
open file(Payroll);

A file named PAYROLL will be used for all I/O operations using file Payroll.

Method 2

Using the TITLE option on the OPEN statement allows one to specify an explicit disk file name with an optional directory prefix. The use of the TITLE option takes precedence over method 1.

Example
dcl Payroll file input; 
open file(Payroll) title ('/global/acct/sep-95.days')

A file named /global/acct/sep-95.days will be used for all I/O operations using file Payroll.

dcl Payroll file input; 
dcl filename character(100) varying; 
<assignment into filename> 
open file(Payroll) title (filename); 
                                   /* Using a variable name */

The value of filename determines the file that will be used for all I/O operations using file Payroll.

Note: Once the file has been opened, changing the value of filename will have no impact. The association is made only once, at the time of the open.

Method 3

The physical disk file name can be specified with the use of UNIX shell environment variables. This method takes precedence over methods 1 and 2. This method allows you to easily alter the physical disk file used for different invocations of the same application.

The environment variable name is the value of the derived name from either of the above methods with MF_ or DD_ prefixed.

Example
dcl file data2 update; 
dcl file specs output; 

open file (data2); 
open file (specs) title('report');

By setting the following environment variables:

I/O operations for file data2 will access /common/data and I/O for file specs will access /common/report.

Note that to override the name for file variable "specs", the name MF_REPORT was used, because of the title option on its OPEN statement.

In the above example, environment variables of the names DD_DATA2 and DD_report would also be allowed.

Using CodeWatch

CodeWatch is a powerful software development tool that can help you locate bugs in your Open PL/I programs. There are two versions of CodeWatch available with Open PL/I:

The command-line version offers a traditional line-oriented interface allowing you to interactively enter commands from the keyboard. The Windows interface offers at least two main windows: one that allows you to enter commands and one that allows you to view your source code. You access CodeWatch commands through pulldown menus and dialogs. The Windows interface runs on a graphical workstation running X-Windows.

CodeWatch enables you to control program execution to set breakpoints, monitor what is happening, examine static type data, and evaluate results. CodeWatch keeps track of variables, subroutines, and data types in terms of the symbols used in the source language. You can reference these items without having to consider the underlying machine language or architecture. You can use CodeWatch to access the source text of the program, to identify and reference program entities, and to detect errors in the program's algorithms and logic.

Note: Your programs must be compiled using the -deb option before they can be run under the control of the debugger. (Every module need not be compiled in -deb mode, but at least one must be; CodeWatch debugs only the modules compiled in -deb mode.) When executed with the -deb option, the Compiler generates a separate symbol table file, filename.stb, in the current directory. filename.stb contains symbolic information that the debugger uses to reference and manipulate source program symbols and entities; set breakpoints, tracepoints, and watchpoints; and control program execution.

For detailed information on CodeWatch, see your CodeWatch Reference Manual.

Creating a Sharable Library

Open PL/I can be used to create sharable libraries on any of the following operating systems:

To produce code that can be included in a sharable library, other than on AIX, you must ask Open PL/I to produce position-independent code by using the -pic option. The -pic option is not required for AIX, because all Open PL/I code on AIX is position-independent. Once you have object files generated as position-independent code, you link them into a sharable library using the following commands.

On HP–UX, to make a new shared library newshare.sl library:

ld -b -o newshare.sl x1.0 x2.o x3.o 

On Solaris 2 or UNIX SVR4:

ld -G -o newshare.sl xl.o x2.o x3.o 

On AIX:

ld -o newshare.o x1.o x2.o x3.o -bE:newshare.exp -bM:SRE

Using Open PL/I with Other Software Products

Because Open PL/I supports a wide range of data types and because it supports standard calling sequences, Open PL/I can be used with many other software products. These include other Micro Focus products as well as products from other companies. This section lists some of the products that Open PL/I is known to work with and gives some hints about using them with Open PL/I.

UniKix

UniKix is UniKix Technologies' CICS system for open systems. Open PL/I supports and is supported by UniKix to enable you to develop On-Line Transaction Processing applications in PL/I.

To create UniKix screens, use UniKix's BMS screen generator utility. Within your screen definition place the command:

LANGUAGE = PLI

Open PL/I provides a CICS precompiler, kixplt, that you can use to process embedded EXEC CICS statements within your PL/I programs. For more information about using Open PL/I's CICS precompiler, see the section Precompiler and Preprocessor Order of Execution .

Note: While the CICS precompiler can be invoked directly with kixplt, we recommend that you invoke it with the -unikix option to the mfplx command.

The following restrictions apply to Open PL/I programs being used as UniKix applications:

If OPTIONS(MAIN) is specified in an application program, that program can be the first program of a transaction, or control can be passed to it by means of an EXEC CICS LINK or XCTL command.

The definition of the External Interface Block (EIB) is generated in each program based upon the pointer variable DFHEIPTR. In programs compiled with OPTIONS(MAIN), the DFHEIPTR variable is set by UniKix to address the EIB on entry; therefore, the CICS precompiler will insert DFHEIPTR and DFHCOMMAREA (pointer to the communications area) as parameters of the MAIN program. For example, the following source line

TEST: PROCEDURE OPTIONS(MAIN);

will be translated to

TEST: PROCEDURE(DFHEIPTR, DFHCOMMAREA) OPTIONS(CICSMAIN);

In programs other than those declared with OPTIONS(MAIN), addressability to the EIB is the user's responsibility. This can be achieved by using the CICS command

EXEC CICS ADDRESS EIB(DFHEIPTR);

or by passing the EIB address or the values of particular EIB fields as parameters.

To perform proper initialization and cleanup, all procedures declared with OPTIONS(MAIN) that contain EXEC CICS statements, or that are calling other procedures containing EXEC CICS statements, must be run through the CICS precompiler.

Open PL/I's UniKix support is license managed. You must obtain a special license from Micro Focus to use it. Of course, you must also have the UniKix product.

Oracle

Open PL/I can be used with the Oracle database system. Oracle's Pro*PL/I SQL precompiler is supplied with Open PL/I.

For more information about using Pro*PL/I with Open PL/I, see the section Precompiler and Preprocessor Order of Execution , and for information about Open PL/I SQL options, see the chapter Open PL/I SQL Options . Also refer to the following other documents: Programmer's Guide to the Oracle Precompilers and Pro*PL/I Supplement to the Oracle Precompiler Guide.

Note: While the Pro*PL/I precompiler can be invoked directly with propli, we recommend that you invoke it with the -oracle option to the mfplx command.

Open PL/I's Oracle support is license managed. You must obtain a special license from Micro Focus to use it. Of course, you must also have the Oracle product.

DB2

Open PL/I can be used with the IBM's DB2 database system. Open PL/I has a precompiler for embedded EXEC SQL statements in your PL/I programs.

For more information about using the DB2 SQL precompiler with Open PL/I, see the section Precompiler and Preprocessor Order of Execution , and for information about Open PL/I SQL options, see the chapter Open PL/I SQL Options .

Note: While the DB2 precompiler can be invoked directly with lpidb2, we recommend that you invoke it with the -db2 option to the mfplx command.

Open PL/I's DB2 support is license managed. You must obtain a special license from Micro Focus to use it. Of course, you must also have IBM's DB2 product.

C++/Views

C++/Views is Intersolv's object-oriented graphical user interface (GUI) program framework. C++/Views includes an interactive graphical designer, as well as an extensive C++ class library. Using C++/Views, you can create the framework for an application with an attractive and efficient graphical user interface. Your C++ framework can then call procedures written with Open PL/I to do your ordinary data processing work.

A C++/Views example, PhoneList, is included in the product set. The example consists of a number of C++ source modules and one PL/I module, a readme file, and a makefile.

C++/Views is not yet available on the following platform supported by Open PL/I:

SyncSort

You may use sort routines supplied by SyncSort with Open PL/I. To do so:

  1. Add the pathname of the SyncSort library to your LD_LIBRARY_PATH environment variable.
  2. Set the SYNCSORT_INSERT environment variable to the pathname of your SyncSort definition file.

    SyncSort will append SyncSort definition options to options that you explicitly specify to Open PL/I.

  3. Specify -syncsort on the ldpli link command.

While developing an application, it is best to turn on debug output fromSyncSort. You can do this by using the /debug option in the sort definition or by setting the environment variable SYNCSORT_DEBUG to 33. For example:

SYNCSORT_DEBUG 33
export SYNCSORT_DEBUG

The use of the environment variable is recommended, because it activates debug output from the start of the SyncSort definition.

By default, SyncSort uses null(s) to pad short keys, whereas Open PL/I rules say that spaces are to be padded to the shorter string during a character string comparison. You must use the SycnSort /padkey X"20" option to have SyncSort match Open PL/I string comparison rules if you expect to have short keys.

The following notes pertain to using SyncSort via the Open PL/I PLISRTx built-ins. (See the section PLISRTx Subroutines in the chapter Open PL/I Built-Ins in your Language Reference Manual for more information.) In all cases, the syntax must be valid.

PL/I PLISRTx built-in arguments:

fields-specThe 'sort fields=(...)' argument is ignored.

The options-list:

SKIPREC=n     For PLISRTA and PLISRTC, Open PL/I automatically adds "/skiprecord n" to the SyncSort definition.

For PLISRTB and PLISRTD, Open PL/I skips n records returned from the input procedure.

EQUALS "/stable" will be added to the SyncSort definition.
records-spec     The record type (V or F) and length are used in the invocation of input or output routines. For PLISRTA, this argument is ignored.
input-procThis must conform to an E15 Sort Input Handling routine. When the record type is F, it should return a char(n), where n is the record length.

When the record type is V, it should return a char(n) varying, where n is the record length.

output-procThis must conform to an E35 Sort Output Handling routine. It should always declare its parameter as char(*), never char(*) varying.

Open PL/I handles the invocation of both input and output procedures. Open PL/I adds the applicable /inprocedure and /outprocedure options to the SyncSort definition, using the record length specified in the records-spec. You may not add these options to your SyncSort definition explicitly.

Warning: When comparing the output from SyncSort and Open PL/I, you should note that records that matched on their keys may be in a different order. This prevents the use of the UNIX diff utility to compare the two files. You can avoid this problem, however, by using the EQUALS option in the fields-spec (in your source program). When EQUALS is present, both SyncSort and Open PL/I use a stable sort. Having records that do not fully contain the keys can also cause different results. You must use /padkey x"20" in your SyncSort definition to overcome this. If you use EQUALS in your PL/I source and the /padkey x"20" option in your SyncSort definition, the output files should be identical.

Open PL/I and Informix

Open PL/I follows the native C compiler's naming conventions. This allows you to mix subroutines and functions compiled with Open PL/I with any other language or third-party library that supports a C language interface. However, you must link the Open PL/I run-time libraries into the final stand-alone program. The -cisam link option enables the C-ISAM package from Informix for VSAM/indexed files.

Informix fully documents their Application Programming Interface for the C language. In general, you should follow the Informix directions for mixing Informix and C, simply treating the modules compiled with Open PL/I as C modules. For information on how to write programs that mix PL/I with C, please see the chapter Language Concepts in this guide.

The following examples illustrate the command used to link an Open PL/I program that uses the Informix libraries. For the purposes of this illustration the Open PL/I Compiler and Informix modules are running on a Sun Solaris system. The Open PL/I modules are called "testobj1.o" and "testobj 2.o", the Open PL/I Compiler has been installed in /opt /pl1, and the environment variable $MFPLI_PRODUCT_DIR has been set to that directory.

ldpli testobj1.o testobj2.o -o testprogram 
/opt/informix/lib/esql/libsql.a
/opt/informix/lib/esql/libgen.a 
/opt/informix/lib/esql/libos.a
/usr/ucblib/libucb.a 
/opt/SUNWspro/SC3.0/lib/cg92/_fstd.o

Note that the names and locations of the Open PL/I and Informix libraries are specific to your installation of Informix and Open PL/I. This illustrates a typical installation.

Open PL/I and Micro Focus

Open PL/I follows the native C compiler's naming conventions. This allows you to mix subroutines and functions compiled with Open PL/I with any other language or third party library that supports a C language interface. You must link the Open PL/I run-time libraries into the final stand-alone program. Micro Focus fully documents inter-language calling between COBOL/2 and C. In general, you should follow the Micro Focus directions for mixing COBOL and C, simply treating the modules compiled with Open PL/I as C modules. The following test program illustrates a COBOL program that calls a PL/I function, passing a string as an argument.

The COBOL source code module:
WORKING-STORAGE SECTION. 01 STR PIC X(20). 
*
PROCEDURE DIVISION.
CALL-PL1 SECTION. 
DISPLAY "Calling the PL/I program". 
CALL "PL1PROC" USING STR.
DISPLAY "Return from PL/I program".
DISPLAY STR. 
STOP RUN.
The PL/I source code module:
PL1PROC: PROCEDURE ( CHARSTR );
DECLARE CHARSTR CHARACTER(20); 

CHARSTR = 'This is a real test!'; 

END PL1PROC;
The commands to compile and link:
mfplx mfpll.pl1 -stat -c 

cob mfcob.cbl mfpl1.o -o mf -v -V -x \ 
    /pl1dir/lib/dflock.o071030 \ 
    /pl1dir/lib/noofm.o071030\ 
    /pl1dir/lib/lpi.a071030

Note that the names and locations of the Open PL/I libraries are specific to your version of Open PL/I. This illustrates a typical installation.

Open PL/I and Encina

Encina is Transarc Corporation's online transaction processing system. Encina can be accessed from Open PL/I using Encina's open application program interface (API). All Encina functions can be accessed. The -tisam link option enables the TISAM package from Transarc for VSAM/indexed files. This allows for sharing datafiles in the SFS format. You can use Open PL/I to develop transaction processing client server applications with one caveat concerning multi-threaded programming.

The I/O subroutines in Open PL/I's run-time library are not thread-safe. Code that contains PL/I I/O can be made thread-safe by using the global lock to serialize PL/I I/O, as in the following example:

DECLARE 

  PTHREAD_LOCK_GLOBAL_NP 
      EXTRY() EXTERNAL('pthread_lock_global_np'), 
  PTHREAD_UNLOCK_GLOBAL_NP 
      ENTRY() EXTERNAL('pthread_unlock_global_np'); 

  CALL PTHREAD_LOCK_GLOBAL_NP(); 

  /* PL/I I/O ... */ 

  CALL PTHREAD_UNLOCK_GLOBAL_NP();

For information on programming with threads, see the OSF DCE Application Development Guide.

A complete example of using Encina with Open PL/I can be found in the directory $MFPLI_PRODUCT_DIR/examples/OpenPLI/encina.


Copyright © 2009 Micro Focus (IP) Ltd. All rights reserved.