User's Manual for Digital UNIX
This manual gives an overview of the PL/I language and an explanation
of PL/I program development. It describes the operation of the
Kednos PL/I for UNIX compiler and the features of the Digital UNIX
operating system environment that are important to the PL/I
programmer.
Operating System and Version: Digital UNIX Version 3.2 and
higher
Kednos Systems, Inc., makes no representations that the use of its products in the manner described in this publication will not infringe on existing or future patent rights, nor do the descriptions contained in this publication imply the granting of licenses to make, use, or sell equipment or software in accordance with the description.
Possession, use, or copying of the software described in this publication is authorized only pursuant to a valid written license from Kednos or an authorized sublicensor.
No responsibility is assumed for the use or reliability of software on equipment that is not listed as supported in the Product Description.
Restricted Rights: Use, duplication or disclosure by the U.S. Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013.
© Kednos Corporation, 1995, 1996, All Rights Reserved.
Kednos Corporation, Kednos PL/I, and Kednos VPO are trademarks of Kednos Corporation.
Alpha AXP, AXP, CDD, DEC,DEC 4000, DECwindows, Digital, OpenVMS AXP, ULTRIX, VAX, OpenVMS, VT102, VT220, VT240, VT320, VT330, VT340, and the DIGITAL logo are trademarks of Digital Equipment Corporation.
SAA and IBM are trademarks of International Business Machine Inc.
Stratus is a trademark of Stratus Computer Inc.
Kednos PL/I for UNIX includes the GNU readline and assembler software. See See for the entire text of the Free Software Foundation's GNU Copyleft.
Portions Copyright 1984-1990 FairCom Corporation. All Rights Reserved.
Kednos requests your critical evaluation to assist in preparing future documentation. Please send any comments to comments@Kednos.com or by physical mail to:
Compiling and Linking a PL/I Program 2-1
Compiling Multi-Language Programs 2-4
Linking Objects using the pl1 Command 2-8
Preprocessor Compilation Control 2-11
Passing Command Line Parameters to a PL/I Program 2-20
Accessing Automatic and Parameter Data 3-7
Qualifying Structure References 3-7
Referring to Arrays and Structures 3-8
Preparing to Use the Debugger 3-8
Compiling for the dbg Debugger 3-8
Debugging Optimized Programs 3-9
Starting and Ending a Debugging Session 3-10
Ending the Debugging Session 3-11
Using the dbg Command Line Editing Features 3-11
Getting Started with Command Line Editing 3-12
Using the UNIX File System for I/O 4-2
PL/I Files and UNIX File Specifications 4-2
Using Environment Variables 4-4
Environment Variables in TITLE Values 4-4
Process Standard System File Names 4-5
Expanding File Specifications 4-6
Values Returned by PL/I Built-In Functions for Error Handling 4-8
Access Modes for Record I/O 5-3
Direct and Sequential Access 5-4
Access by Record Identification 5-4
IBM Dialect Fixed Length Environment Options 5-5
IBM Dialect Variable Length Environment Options 5-6
Appending Records to an Existing File 5-8
Superseding an Existing File 5-8
Relative File Organization 5-8
Populating a Relative File 5-11
Specifying and Using Environment Options 6-1
Arguments for Environment Options 6-1
Interpretation of ENVIRONMENT Options for Existing Files 6-3
Conflicting and Invalid ENVIRONMENT Options 6-3
Summary of ENVIRONMENT Options 6-4
FIXED_LENGTH_RECORDS Option 6-16
MAXIMUM_RECORD_SIZE Option 6-17
ENVIRONMENT Options for File Protection and File Sharing 6-26
FLUSH Built-In Subroutine (DEC Dialect Only) 8-1
REWIND Built-In Subroutine (DEC Dialect Only) 8-2
How the Sort Program Interface Works 9-2
Determining Which Entry Point to Use 9-3
Calling the Sort Subroutines 9-4
General Format of the Sort Interface Call 9-4
Specifying the Sort Fields 9-5
Specifying Record Information 9-7
Specifying Input and Output Routines 9-10
Input and Output Routines 9-11
Using the PLIRETC Built-In Subroutine 9-11
RESIGNAL Built-In Subroutine 10-1
Resignaling the Condition 10-5
Executing a Nonlocal GOTO 10-6
Relationship of UNIX Signals to PL/I ON-Units 10-8
Accessing the Signal Values 10-10
Modifying the ONCODE Values 10-11
Search Path for ON-Units 10-13
Default Handling for Main Procedures 10-14
Default Handling for Non-Main Procedures 10-15
Condition-Handling Built-In Functions 10-22
ONCODE Built-In Function 10-22
The UNIX Procedure Calling and Condition Handling Standard 11-2
Parameter-Passing Mechanisms 11-2
Passing Parameters by Reference 11-3
Dummy Arguments for Arguments Passed by Reference 11-4
Using Pointer Values for Arguments Passed by Reference 11-5
Passing Arrays to a FORTRAN Routine by Reference 11-5
Passing Parameters by Value 11-5
Dummy Arguments for Arguments Passed by Value 11-7
Special Parameter Attributes 11-7
Determining the Type of Call 11-10
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION A-2
How to Apply These Terms to Your New Programs A-8
Figure 3-1. Specifying Environments 3-5
Figure 10-1. Resignaling a Condition 10-6
Figure 10-2. Unwinding the Call Stack 10-7
Figure 10-3. Execution of an ON-Unit 10-14
Table P-1. Documentation Conventions Table xi
Table 2-1. Alphabetic List of PL/I Driver Options 2-4
Table 3-1. dbg Command Line Options 3-10
Table 3-2. Debugger Command Summary 3-17
Table 4-1. Default Process Stream Names 4-5
Table 4-2. System File Names for Get and Put Statements 4-5
Table 6-1. Description of Columns in Table 6-2 6-4
Table 6-2. Summary of DEC and ANSI Dialect ENVIRONMENT Options 6-5
Table 6-3. Summary of IBM Dialect ENVIRONMENT Options 6-6
Table 6-4. ENVIRONMENT Options That Are Ignored 6-7
Table 6-5. Default Record Sizes 6-18
Table 6-6. Default Record Sizes 6-20
Table 7-1. Summary of Input/Output Statement Options 7-2
Table 9-1. Entry Points for the Sort Program 9-3
Table 10-1. Corresponding Values 10-10
Table 10-2. ONCODE Values for PL/I ON Conditions 10-23
Table 11-1. Converted Data Types of Arguments Passed by Reference 11-4
Figure 3-1. Specifying Environments 3-5
Figure 10-1. Resignaling a Condition 10-6
Figure 10-2. Unwinding the Call Stack 10-7
Figure 10-3. Execution of an ON-Unit 10-14
Table P-1. Documentation Conventions Table xv
Table 2-1. Alphabetic List of PL/I Driver Options 2-4
Table 3-1. dbg Command Line Options 3-10
Table 3-2. Debugger Command Summary 3-17
Table 4-1. Default Process Stream Names 4-5
Table 4-2. System File Names for Get and Put Statements 4-5
Table 6-1. Description of Columns in Table 6-2 6-4
Table 6-2. Summary of DEC and ANSI Dialect ENVIRONMENT Options 6-5
Table 6-3. Summary of IBM Dialect ENVIRONMENT Options 6-6
Table 6-4. ENVIRONMENT Options That Are Ignored 6-7
Table 6-5. Default Record Sizes 6-18
Table 6-6. Default Record Sizes 6-20
Table 7-1. Summary of Input/Output Statement Options 7-2
Table 9-1. Entry Points for the Sort Program 9-3
Table 10-1. Corresponding Values 10-10
Table 10-2. ONCODE Values for PL/I ON Conditions 10-23
Table 11-1. Converted Data Types of Arguments Passed by Reference 11-4
This manual describes how to use theKednos PL/I for UNIX compiler on the Digital UNIX operating system, and contains detailed explanations of the extensions made to the standard PL/I language for this implementation. To aid in program development, it includes information on some UNIX commands and utilities. It also includes information to assist in writing PL/I programs that use features of the file system and the operating system.
This manual is designed for programmers who have a working knowledge of PL/I and some familiarity with the Digital UNIX operating system and the C shell (csh).
This manual is divided into the following sections:
See contains the Free Software Foundation's Copyleft.
The Kednos PL/I for UNIX Reference Manual contains a complete definition of PL/I for RISC ULTRIX and the VAX PL/I languages, with detailed reference information on all standard PL/I language elements.
The Kednos PL/I for UNIX Installation Guide gives instructions on how to install the PL/I for RISC ULTRIX compiler.
The manpages contain information on PL/I built-in functions and pseudovariables. For an introduction to manpages, type the following:
The Digital UNIX documentation set gives complete information on the operating system.
For the purposes of this manual, the term PL/I refers to Kednos PL/I for UNIX, which runs on the DEC OSF/1 and Digital UNIX systems.
All descriptions of the effects of executing statements and evaluating expressions assume that the initial procedure activation of the program is through an entry point with OPTIONS(MAIN).
It is further assumed that any non-PL/I procedures called by the program follow all conventions of the PL/I run-time environment.
Overview of Kednos PL/I for UNIX
Kednos PL/I for UNIX is a comprehensive and powerful programming language useful for systems programming, scientific computation, and commercial data handling and data organization. It is a block-structured language that lends itself to the creation of efficient and maintainable structured programs. It has extensive string-handling capabilities.
Kednos PL/I for UNIX is Kednos's implementation, with extensions, of the American National Standard PL/I General-Purpose Subset, ANSI X3.74-1981. The General-Purpose Subset is a subset of full PL/I, ANSI X3.53-1976.
The General-Purpose Subset was designed for scientific, commercial, and systems programming on small and medium-size computer systems. The subset excludes features of PL/I that are prone to error, not often used, or that greatly increase the complexity of run-time support required by the compiler.
Over and above its conformity to the General-Purpose Subset,Kednos PL/I for UNIX offers many enhancements that extend the functionality of the subset. Some of these extensions are features of full PL/I, and some are features for compatibility with other PL/I implementations in the industry, especially VAX PL/I. Other extensions integrate Kednos PL/I for UNIX into the Digital UNIX common language environment and into a complete programming environment. Kednos PL/I for UNIX extensions are intended for programs that will execute exclusively under the control of the UNIX operating system.
The Kednos PL/I for UNIX extensions provide support for the UNIX Procedure Calling and Condition Handling Standard, allowing PL/I procedures to call procedures written in other languages. Another notable extension is the preprocessor, which allows for conditional compilation of programs and for compile-time source transformation; it enables users to write procedures that will be executed at compile time.
Kednos PL/I for UNIX can be used with a number of tools in a complete programming environment. For example, the compiler system provides a source level, interactive debugger called dbg. This enables you to debug programs as they execute. Use of the debugger is described in See of this manual.
TheKednos PL/I for UNIX language is fully described in the Kednos PL/I for UNIX Reference Manual. This reference manual contains further information on the General-Purpose Subset, the UNIX extensions, and the differences between Kednos PL/I for UNIX and other implementations of the PL/I language.
Kednos PL/I for UNIX is compatible with other versions of Kednos PL/I (Open VMS and RISC ULTRIX) with some exceptions. VMS specific options that are not compatible are emulated, flagged at compile-time, or ignored, depending on the VMS specific option. See the appendix on language differences in the Kednos PL/I for UNIX Reference Manual for more information.
This chapter describes how to create, compile, link, and run a Kednos PL/I for UNIX program.
A PL/I source file is a UNIX file that contains PL/I code, as defined in the Kednos PL/I for UNIX Reference Manual.
To create a source file, use the text editor of your preference, such as the vi editor. You can also use any of the UNIX file management tools available on your system to generate source files. For example:
The following sections discuss the pl1 command and the command options.
A program called a driver invokes the major components of the compiler system. The components are:
The pl1 command runs the driver that compiles, optimizes, assembles, and link edits your programs. The command may be followed immediately by one or more options, by one or more filenames, or both.
A driver option. Driver options specify instructions to all the processing phases. You can specify either the long or short version of the options, as shown in See . Alphabetic List of PL/I Driver Options .
An input source file containing the program or module to be compiled. You must specify a file suffix. Valid suffixes are:
You can include more than one file specification on the same command line by separating the file specifications with a space as follows:
The driver command, pl1, invokes the following processing phases to compile and optionally link edit the source file:
By default, the pl1 command both compiles and link edits a source module. If you specify the -c driver option, processing stops after the assembler phase, producing a linkable object file. You can then use the pl1 or ld command to link edit the linkable object(s) into one executable binary. By default, the linkable object file has the same name as the source file, but with the suffix .o.
This produces the linkable object file.o.
The default name of the executable binary is a.out. For example:
This command line produces the executable binary a.out.
You can specify a different name for the executable binary by using the driver option -o and supplying the desired file name. For example:
This command line compiles and link edits the source module file.pli and produces an executable binary, file.
If you have previously compiled the source module and used the -c option to produce the linkable object file.o, the following command line links edit the object module:
This command link edits the object module file.o and produces the executable binary file. You can link edit several object modules together to produce a single executable binary, as follows:
This command link edits the object modules file1.o and file2.o and produces the executable binary file.
When specifying a name for your executable binary or object module, note that the full file name (file name and extension) must differ from the name of the source file(s). In other words, when compiling file.pli, do not supply file.pli as the full file name of your executable binary or object module.
When your application has two or more source programs written in different languages, including C, Pascal, and Fortran, compile each program module separately with the appropriate driver and then link them in a separate step. To create the linkable objects, use the pl1 command option -c. The following example compiles a PL/I program and a C program:
When you compile the routines, the drivers produce the linkable object files plifile.o and cfile.o. Use the pl1 command to perform the link edit, which loads and initializes the appropriate run-time libraries for PL/I.
See . Alphabetic List of PL/I Driver Options lists the options for the pl1 command line. The UNIX manpage pl1(1) also describes the pl1 command options if the manual pages are installed on the system.
|
Specifies natural alignment. On Alpha processors, -a is equivalent to -a8 |
||
|
Aligns to the specified byte boundary. n must be a power of two. The default value is -a1, which causes the compiler to align so there are no pad bytes in structures. |
||
|
Suppresses the loading phase of the compilation. Produces an object file even when you compile only one program. |
||
|
Defines the dialect of the compiler, where dialect is one of the following: ibm, dec, ansi. The default dialect is ansi. |
||
|
Produces debugger symbol table information. This option implies the -N option. |
||
|
Defines an additional directory for the PL/I preprocessor to search when looking for %INCLUDE modules You can specify this option multiple times to define several directories. |
||
|
Enables range and subscript checking. Turns on signalling of the STRINGRANGE and SUBSCRIPTRANGE conditions. Use this option to generate code to dynamically check the values of array, character, and bit string indexes. |
||
|
When linking, search an object library named libname.a, where name is a string. |
||
|
Changes the algorithm of searching for libx.a or libx.b so the default directories are not searched. Use this option when you only want to search the directories specified by the ld(1) option -Ldir. |
||
|
Changes the algorithm of searching for libx.a or libx.b so that ld searches the specified directory before the default library directories. |
||
|
-m lower 1 |
Specifies that all identifiers are case insensitive and externals are converted to lower case. This is the default. |
|
|
Specifies that all identifiers are case sensitive. Allows mixed case identifiers |
||
|
Specifies that all identifiers are case insensitive and externals are converted to upper case. |
||
|
Specifies the case of the include file names in a preprocessor %INCLUDE statement. The specified case is applied when the module name is built by the preprocessor. -M lower is the default, specifying that all file names are converted to lowercase. -M mix specifies case sensitivity, allowing mixed case file names. -M upper converts filenames to upper-case. |
||
|
Links the image without shared libraries. By default, images are linked with shared libraries. You must link without shared libraries to use the dbg debugger. Thus the -N option is implied by the -g option. |
||
|
Generates an executable binary with the specified file name. If you do not use this option, the compiler names the executable binary a.out. |
||
|
Performs all optimizations, including global register allocation. Restrictions: The -c option cannot be specified with the -O option. The -O option must precede all source file arguments. |
||
|
Generate information for profiling. |
||
|
Do not generate information for profiling. This is the default. |
||
|
Turns on the preprocessor phase of compilation. This is the default for the -D dec dialect. |
||
|
Turns off the preprocessor phase of compilation. This is the default for the -D ibm and -D ansi dialects. |
||
|
Generates a compiler listing file with corresponding filename and a suffix of .l. The listing file includes source program lines with all the included files expanded, and a datamap of the program. |
||
|
Defines the compilation variant used by the VARIANT preprocessor built-in function. Ignored if you compile without using the preprocessor. |
||
|
Defines the file suffix for include files. Supplied for compatibility with Digital and valid for the -D dec dialect only. |
||
|
Displays the compiler passes, with their arguments, input, and output files, as they execute. Also displays resource usage in the C shell time format. |
||
|
Includes cross reference information in the listing file. Implies -s; you need not use -s if you use -x. |
Use the pl1 command to link edit separate objects into one executable binary when the main program is written in PL/I. The driver recognizes the .o suffix as the name of a file containing object code suitable for link editing and immediately invokes the link editor. For example:
pl1 -o file mainfile1.o file2.o
Write the main program in PL/I and use the pl1 command to link edit the program to insure correct initialization of the PL/I run-time library. This statement produces the executable binary file.
The pl1 command implicitly calls the ld link editor (unless you specify the -c compile-only option). The link editor combines object modules to produce an executable binary. These object modules include:
A pl1 command where all the parameters are object files does only a link edit. For example, such a command might appear in a file for make(1) that specifies a build procedure. This file separates the compile operations from the link edit so that make can omit operations on source files that have not been modified.
If possible, use the pl1 command instead of ld to link edit PL/I object files. This automatically selects the correct run-time libraries and the correct version of ld. However, if you need to specify options to ld, you must invoke ld directly. Refer to the manpage on ld(1) for more information on specifying ld options, including specifying the run-time libraries.
The object code for the PL/I built-in routines is in an archive library. The distinctive suffix .a identifies a file as an archive library. The link editor gets your program code from your object file or files, and then gets the built-in routine code from object libraries called run-time libraries. It merges them and resolves references.
Kednos PL/I for UNIX includes the following run-time libraries:
The default run-time library for the pl1 command. It contains support for all PL/I language features except indexed file support (files declared or opened using the ENVIRONMENT(INDEXED) option). Programs using indexed files that are linked to this library generate fatal run-time errors.
Contains the same features as libpli.a with the addition of indexed file support (see libpli.a). Because the library increases the size of executable binaries, slows the link editing process, and requires additional memory during execution, use it only when indexed file support is required.
Contains additional support functions required by libplit.a.
To specify other libraries when invoking the link editor, use the -l option. Library names start with lib and have extensions .so (shared object), .a (archive) or .b (ucode). For example, if you have written a PL/I program that calls routines from the run-time library libx11.a, then specify:
The link editor (ld) searches for any libraries you specify using the default search path listed in the manpage for ld. However, the system administrator or installer determines the actual location of the PL/I run-time libraries, so you might need to add directories to the default search path.
The -L option to the link editor, when followed by a directory name, adds the specified directory to the search path for run-time libraries. Do not type any separators between -L and the name of the directory. You can use this option several times; the link editor searches the directories in the order that you specify on the command line. Your definition of the search path must precede your specification of libraries (using the -l option described in See Run-Time Libraries ) on the command line.
The link editor searches the directories you specify with -L, in the order you specify them on the command line, before it searches the standard directories (which were specified during installation). This lets you specify files that supersede the usual run-time library.
If you use the -L option and do not follow it with a directory name, the link editor does not search its standard directories.
When you use the -L option, the link editor uses the following search path:
The PL/I preprocessor lets you change a source program at compile time. You can mix preprocessor statements with nonpreprocessor statements in the source program, but the preprocessor statements only execute at compile time. The resulting source program is then used for further compilation.
The preprocessor does two types of preprocessing:
Preprocessor statements let you include text from other sources (%INCLUDE statements), control the course of compilation (%DO, %GOTO, %VARIANT, %PROCEDURE, and %IF), issue user-generated diagnostic messages, and selectively control listings and formats. The preprocessor statements are described in full in the Kednos PL/I for UNIX Reference Manual.
At compile time, preprocessor variables, procedures, and variable expressions are evaluated in the order in which they appear in the source text, and the new values are substituted in the source program in the same order. Thus, the course of compilation becomes conditional, and the resulting executable binary may exhibit a variety of unique features. Note that preprocessor variables and procedures must be declared and activated before replacement occurs.
%THEN %FATAL 'Please compile this outside of prime time';
%T = '''Compiled on '||DATE()||'''';
DECLARE INIT_MESSAGE CHARACTER(60) VARYING INITIAL(T);
%IF VARIANT() = ''| VARIANT() = 'NORMAL'
%T = '''unknown variant '||variant()||'''';
INIT_MESSAGE=INIT_MESSAGE||' with '||T;
This example illustrates several aspects of the preprocessor. First, you must compile this program outside of prime time. Second, depending upon the value of VARIANT, the program is compiled with a different variant.
Notice the number of single quote marks around the string constant assigned to T. Single quotes are sufficient if you only use the value of T in a preprocessor user-generated diagnostic message. That is, the value of T is concatenated with nonpreprocessor text and assigned to INIT_MESSAGE because during preprocessing, single quotes are stripped off of string constants. To ensure that the run-time program also has quotes around the string, you must supply additional quotes, as shown.
The %PROCEDURE statement defines the beginning of a preprocessor procedure block and specifies the parameters, if any, of the procedure. A preprocessor procedure executes only at compile time. Invocation is similar to a function reference and occurs in two ways:
A preprocessor procedure is invoked by the appearance of its entry name and list of arguments. If the reference occurs in a nonpreprocessor statement, the entry name must be active before the preprocessor procedure is invoked. If the entry name is activated with the RESCAN option, the value of the preprocessor procedure is rescanned for further possible preprocessor variable replacement and procedure invocation. Preprocessor procedures can be invoked recursively.
Since the preprocessor procedure is always invoked as a function, the %PROCEDURE statement must also specify (using the RETURNS option) the data type attributes of the value that is returned to the point of invocation.
The return value replaces the preprocessor procedure reference in the invoking source code. Preprocessor procedures cannot return values using their parameter list. The return value must be capable of being converted to one of the data types CHARACTER, FIXED, or BIT. The maximum precision of the value returned by the %RETURNS statement is BIT(31), CHARACTER(32500), and FIXED(10).
You can use either of the following two types of argument lists in preprocessor procedures:
Since a keyword argument list ends with a semicolon rather than a right parenthesis, the STATEMENT option lets you use a preprocessor procedure that has a keyword argument list as if it were a statement. Consequently, preprocessor procedures using the STATEMENT option let you extend the PL/I language by simulating otherwise unavailable features.
All preprocessor statements are preceded by a percent sign (%) and are terminated by a semicolon (;). All text that appears within these delimiters is considered part of the preprocessor statement and is executed at compile time. For example:
%DECLARE HOUR FIXED; /* declaration of a preprocessor
%DECLARE (A,B) CHARACTER; /* a factored preprocessor
%HOUR = SUBSTR(TIME(),1,2); /* preprocessor assignment
Notice that a percent sign (%) is required only at the beginning of the statement, and must be the first item, other than white space (spaces or tabs) on the line. Preprocessor built-in functions are contained within preprocessor statements and consequently do not require a percent sign.
You can label preprocessor statements. Like other PL/I labels, you can use labels on preprocessor statements as the targets of program control statements. A preprocessor label must be an unsubscripted label constant preceded by a percent sign. The format for a preprocessor label is:
%label: preprocessor-statement;
As with other preprocessor statements, the percent sign alerts the compiler that all text until the semicolon line terminator is preprocessor text. Therefore, you do not need to enter another percent sign on that line.
The compiler treats all statements within a preprocessor procedure as preprocessor statements. You must label preprocessor procedures to invoke them, and you must use a percent sign before the procedure label. However, statements within the procedure do not require leading percent signs.
For a table summarizing the preprocessor statements and for individual descriptions of the statements, see the Kednos PL/I for UNIX Reference Manual.
A number of PL/I preprocessor built-in functions are available for use at compile time. With few exceptions, they have the same effect as run-time PL/I built-in functions with the same name. For a table summarizing the preprocessor built-in functions and for individual descriptions of the functions, see the Kednos PL/I for UNIX Reference Manual.
If you specify either the -s or -x compiler option, the PL/I compiler produces a listing file. The listing file contains the following information:
The following example shows portions of a listing file:
source file: /lang/tmp/real_progAAAaagzEa.pl
compiled on: 950923 at: 17:24:54 by: ANSI/IBM PL/I, rev 1.04in: /local/home/louise/test
Listing File is in: /local/home/louise/test/
0-1 0 0 Test: procedure options (main); À
0-3 1 0 declare x character (8) initial ('foo'),
0-4 1 0 input_x character (8) initial ('');
0-5 1 0 declare y fixed bin (15) initial (42),
0-6 1 0 input_y fixed bin (15) initial (0);
0-7 1 0 declare valid bit(1) initial ('0'B);
0-9 1 0 put skip list ('What is the answer?: ');
0-11 1 0 put skip list ('Type the most common file name: ');
0-14 1 0 if (x = input_x) & (y = input_y)
0-16 1 0 valid=real_programmer();
0-18 2 0 put skip list ('You''re not a real programmer!');
0-22 1 0 real_programmer: procedure() returns(bit(1));
0-24 2 0 /* this exists to show another subroutine level */
0-25 * 2 0 /* in the listing file */
0-27 2 0 declare real_prog bit(1);
0-29 2 0 put skip list ('You''re a Real Programmer!!!');
0-32 2 0 end; /* real_programmer */
***** EXTERNAL ENTRY POINTS ***** Ã
name class size loc attributes
name class size loc attributes
INPUT_X automatic 8c 84 CHAR(8) UNALIGNED INITIAL
INPUT_Y automatic 1 96 FIXED BIN(15,0) ALIGNED PRECISION INITIAL
constant ENTRY RETURNS INTERNAL
SYSPRINT constant FILE EXTERNAL
VALID automatic 1b 112 BIT(1) UNALIGNED INITIAL
X automatic 8c 92 CHAR(8) UNALIGNED INITIAL
Y automatic 1 128 FIXED BIN(15,0) ALIGNED PRECISION INITIAL
procedure REAL_PROGRAMMER on line 22
name class size loc attributes
REAL_PROG automatic 1b 96 BIT(1) UNALIGNED
***** ENTRY POINTS AND ARRAY OF LABELS *****
name class size loc attributes
constant ENTRY RETURNS INTERNAL
*****ERROR 179 SEVERITY 1 on line 1 in file Õ /lang/tmp/real_progAAAaagzEa.pl.*****
The undeclared name "SYSIN" has been contextually declared
in this block. It will acquire default attributes.
*****ERROR 179 SEVERITY 1 on line 1 in file /lang/tmp/real_progAAAaagzEa.pl.*****
The undeclared name "SYSPRINT" has been contextually
declared in this block. It will acquire default attributes.
The following list describes the callouts in the preceding listing file example:
Header information -- contains information about the source file you compiled, such as when you compiled it, the compiler variant used (dec, ansi, ibm), and the directory specification of the listing file.
À The source program listing -- contains line numbers generated by the compiler, an optional asterisk (*) if the line is continued from a previous line, a level number, specifying the level of procedural nesting, a second level number, specifying the block level within a procedure, and the source text.
à Cross reference listing tables -- includes tables listing external entry points, then a block-by-block listing of each procedure or internal block in the program, describing each variable declared in the block.
Õ Compilation error messages -- the text of any error messages generated during compilation.
The PL/I compiler identifies syntax errors and violations of language rules in the source program. If the compiler locates any errors, it writes messages to standard output. If you enter the pl1 command interactively, the messages are displayed on your screen.
If the compiler creates a listing file it also writes these messages to the listing, as shown in the previous section.
When it appears on the screen, a message from the compiler has the following format:
*****ERROR nn SEVERITY s on line line-no in file filename.*****
The nn specifies the error number.
The s specifies the severity of the error. The following letters represent possible severities:
The compiler produces messages with warning severity if it encounters the following:
The filename indicates the file specification.
The line number n specifies the source file line number of the statement that caused the error. This is the line number assigned to a statement by the compiler. The error message also appears in the listing file (if listing is requested) with the listing line number.
The message-text is the message. In many cases, the message text consists of more than one line of output. The messages generally provide enough information for you to determine the cause of an error and correct it.
To run a PL/I program, enter the name of the executable binary produced by the pl1 command. If you did not use the -o option in the pl1 command, the default name of the executable binary is a.out. Enter a.out to run your PL/I program. If you used the -o option and specified a filename, enter the filename to run your program.
If an error occurs at run-time, a message appears on the terminal. See See for a description of run-time error conditions and messages.
You can pass command line parameters to your PL/I program, and access the parameters in your program. The following sections show how to write your code to access command line parameters, and how to run a program and specify command line parameters.
Kednos PL/I for UNIX provides two methods to access command line parameters:
In your main program, you can declare up to ten parameters to be passed from the command line when users run your program. You must declare these parameters CHARACTER VARYING, giving the actual length of the string as the maximum length.
PARAM: PROCEDURE (name,address,city,state,zip)
DECLARE (name,address,city,state,zip) CHAR(100) VARYING;
Your program can access these parameters only if the parameters are actually passed upon program invocation. To check the number of specified parameters, reference the external variable ARGC (argument count), included in the global definitions file pl1std.in, as shown in the example below.
You can access the command line parameters using the global variable ARGV (argument pointer), a pointer to an array of pointers to the actual parameters passed to the program. Again you can reference only as many parameters as were actually passed on the command line.
Both ARGC and ARGV are included in the global declarations include file, plistd.in, supplied with Kednos PL/I for UNIX.
The following example shows both methods of accessing command line parameters:
PARAM_TEST: PROCEDURE (name, address, city, state, zip)
OPTIONS(MAIN);
DECLARE (name, address, city, state, zip) CHARACTER(100)
VARYING;
PUT SKIP EDIT ('Name: ',Name) (a,a);
PUT SKIP EDIT ('Name is missing') (a);
PUT SKIP EDIT ('Address: ',Address) (a,a);
PUT SKIP EDIT ('Address is missing') (a);
PUT SKIP EDIT ('City: ',City) (a,a);
PUT SKIP EDIT ('City is missing') (a);
PUT SKIP EDIT ('State: ',State) (a,a);
PUT SKIP EDIT ('State is missing') (a);
PUT SKIP EDIT ('Zip: ',Zip) (a,a);
PUT SKIP EDIT ('Zip is missing') (a);
PUT SKIP EDIT ('Parameter ',i, 'is ',ARGS(i)->ARG_CV) (a,f(2),a,a);
To specify command line parameters, type them after the command that runs your PL/I program. For example, if you compile the preceding example using the -o command line option, and call your program param_test, run it as follows:
% param_test "Jocelyn Wood" "92 Forest Path" "Groveland" "New Hampshire" "01110"
This chapter describes how to use the dbg debugger with Kednos PL/I for UNIX programs. This chapter provides the following information:
A debugger helps you locate the cause of run-time errors like incorrect output, an infinite loop, or premature termination of your program. The debugger lets you observe and manipulate program execution interactively so you can find the point where it stopped working correctly. Using a debugger helps you isolate errors in your code much more quickly than you otherwise could.
To use a debugger, you must compile and link your program successfully -- your program must not contain illegal constructs in the source code.
By issuing debugger commands at your terminal, you can do the following:
Once you have found the error in your program, you can edit your source code, fix the problem, and compile, link, and run the corrected version.
Dbg is a high level symbolic UNIX debugger. Using dbg, you can refer to program locations by the symbols (names) you used for those locations in your program -- the names of variables, routines, labels, and so on.
The dbg debugger is specific to Kednos PL/I for UNIX. If you wrote your program in more than one language, the debugger executes all of the code, letting you use dbg commands to debug the PL/I sections.