Kednos PL/I for UNIX

User's Manual for Digital UNIX

April 1996

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

Software Version: Kednos PL/I for UNIX
Version 1.3

 

Kednos Corporation
Pebble Beach, California
Second Printing (Update), April 1996

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:

Kednos Corporation
1051 Rodeo Road
Pebble Beach, CA  93953

Table of Contents

Preface ix

Intended Audience ix

Structure of This Manual ix

Where to Find More Information x

Conventions x

Chapter 1 --

Overview of Kednos PL/I for UNIX 1-1

Chapter 2 --

Developing a PL/I Program 2-1

Creating Source Files 2-1

Compiling and Linking a PL/I Program 2-1

The pl1 Command 2-1

Compilation with pl1 2-2

Compiling Multi-Language Programs 2-4

Driver Options 2-4

Linking Objects using the pl1 Command 2-8

Run-Time Libraries 2-8

Library Search Path 2-9

PL/I Preprocessor 2-10

Preprocessor Compilation Control 2-11

Preprocessor Procedures 2-12

Compiler Listing Files 2-14

Compiler Error Messages 2-18

Running a PL/I Program 2-20

Run-Time Errors 2-20

Passing Command Line Parameters to a PL/I Program 2-20

Accessing Command Line Parameters in PL/I Programs 2-20

Specifying Command Line Parameters 2-22

Chapter 3 --

Using the dbg Debugger 3-1

Overview 3-1

General Information 3-3

Terminology 3-3

Accessing Data 3-6

Accessible Data 3-6

Accessing Static Data 3-6

Accessing Automatic and Parameter Data 3-7

Accessing Based 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

The dbg Command 3-10

Creating .dbginit Files 3-11

Ending the Debugging Session 3-11

Using the dbg Command Line Editing Features 3-11

Getting Started with Command Line Editing 3-12

The Initialization File, ~/.inputrc 3-13

The Sample Program 3-14

The Debugger Commands 3-16

Debugger Error Messages 3-18

ALIAS 3-19

AUDIT 3-21

BREAK 3-22

CLEAR BREAK 3-26

CONTINUE 3-28

DESCRIBE 3-29

DIRECTORY 3-31

DOWN 3-32

ENVIRONMENT 3-33

EXIT 3-35

HELP 3-36

INITIALIZE 3-37

LIST 3-39

PLAYBACK 3-42

PROMPT 3-43

RECORD 3-44

REGISTER 3-45

SET 3-46

SHELL 3-48

SHOW 3-49

SIGNAL 3-51

STEP 3-53

UP 3-55

WALKBACK 3-56

Chapter 4 --

The File System 4-1

File Control 4-1

Using the UNIX File System for I/O 4-2

PL/I Files and UNIX File Specifications 4-2

Using the TITLE Option 4-3

Using Environment Variables 4-4

Environment Variables in TITLE Values 4-4

Process Standard System File Names 4-5

Expanding File Specifications 4-6

Error Handling 4-7

Values Returned by PL/I Built-In Functions for Error Handling 4-8

Writing an Error Handler 4-8

Default Error Handling for the File System 4-9

Chapter 5 --

File Organizations and Input/Output 5-1

File Organizations 5-1

Access Modes for Record I/O 5-3

Sequential Access 5-3

Direct Access 5-4

Direct and Sequential Access 5-4

Access by Record Identification 5-4

Record Formats 5-5

Fixed-Length Records 5-5

IBM Dialect Fixed Length Environment Options 5-5

Variable-Length Records 5-6

IBM Dialect Variable Length Environment Options 5-6

Stream Files 5-6

Stream Files Organization 5-6

Creating a Stream File 5-7

Appending Records to an Existing File 5-8

Superseding an Existing File 5-8

Relative Files 5-8

Relative File Organization 5-8

Creating a Relative File 5-9

Using Relative Files 5-10

Populating a Relative File 5-11

Updating a Relative File 5-12

Reading a Relative File Sequentially 5-12

Error Handling 5-13

Chapter 6 --

Options of the ENVIRONMENT Attribute 6-1

Specifying and Using Environment Options 6-1

Arguments for Environment Options 6-1

Expressions 6-2

Variable References 6-3

Boolean Values 6-3

Interpretation of ENVIRONMENT Options for Existing Files 6-3

Conflicting and Invalid ENVIRONMENT Options 6-3

Summary of ENVIRONMENT Options 6-4

APPEND Option 6-11

BLKSIZE Option 6-11

CONSECUTIVE Option 6-12

DEFAULT_FILE_NAME Option 6-12

DELETE Option 6-13

F, FB, FS, or FSB Option 6-14

FILE_ID Option 6-14

FILE_ID_TO Option 6-15

FIXED_LENGTH_RECORDS Option 6-16

GROUP_PROTECTION Option 6-16

MAXIMUM_RECORD_SIZE Option 6-17

OWNER_PROTECTION Option 6-18

RECORD_ID_ACCESS Option 6-19

RECSIZE Option 6-19

SCALARVARYING Option 6-20

SHARED_READ Option 6-22

SUPERSEDE Option 6-22

TEMPORARY Option 6-23

V, VB, VS, or VSB Option 6-24

WORLD_PROTECTION Option 6-25

ENVIRONMENT Options for File Protection and File Sharing 6-26

File Protection 6-26

Defining File Protection 6-27

File Sharing 6-28

Chapter 7 --

Input/Output Statement Options 7-1

Option Format 7-1

Summary of Input/Output Statement Options 7-2

NO_ECHO Option 7-3

PROMPT Option 7-3

PURGE_TYPE_AHEAD Option 7-4

RECORD_ID Option 7-5

RECORD_ID_TO Option 7-6

Chapter 8 --

File-Handling Built-In Subroutines 8-1

FLUSH Built-In Subroutine (DEC Dialect Only) 8-1

REWIND Built-In Subroutine (DEC Dialect Only) 8-2

Chapter 9 --

General Information 9-1

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 Storage 9-8

Using the Return Code 9-9

Specifying Input and Output Routines 9-10

Specifying a File Prefix 9-10

Specifying Message Level 9-10

Input and Output Routines 9-11

Using the PLIRETC Built-In Subroutine 9-11

Writing Input Routines 9-12

Writing Output Routines 9-14

Programming Examples 9-15

Calling the PLISRTA Entry Point 9-15

Calling the PLISRTD Entry Point 9-16

Chapter 10 --

Error Handling 10-1

RESIGNAL Built-In Subroutine 10-1

VAXCONDITION Condition 10-2

ON-Unit Actions 10-4

Handling the Condition 10-4

Resignaling the Condition 10-5

Executing a Nonlocal GOTO 10-6

Stopping the Program 10-8

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

Multiple Conditions 10-17

Scope of ON-Units 10-20

ON-Unit Examples 10-20

Condition-Handling Built-In Functions 10-22

ONCODE Built-In Function 10-22

ONFILE Built-In Function 10-24

ONKEY Built-In Function 10-24

Chapter 11 --

Using PL/I in the Common Language Environment 11-1

The UNIX Procedure Calling and Condition Handling Standard 11-2

Parameter-Passing Mechanisms 11-2

Passing Parameters by Reference 11-3

Using the ANY Attribute 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

OPTIONS(VARIABLE) Option 11-8

OPTIONAL Attribute 11-8

TRUNCATE Attribute 11-9

Calling Routines 11-9

Determining the Type of Call 11-10

Declaring an External Routine and Its Arguments 11-10

Calling the External Routine 11-10

Appendix A --

GNU Software Information A-1

GNU Copyleft A-1

Preamble A-1

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION A-2

How to Apply These Terms to Your New Programs A-8

Figures

Figure 3-1. Specifying Environments 3-5

Figure 5-1. Relative File 5-9

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

Figure 10-4. Search for an ON-Unit 10-17

Figure 10-5. Effect of Multiple Conditions 10-18

Tables

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

Table 11-2. Assignment of Data Type to Dummy Arguments 11-7

Reader's Comments Card Back of Book
Figures

Figure 3-1. Specifying Environments 3-5

Figure 5-1. Relative File 5-9

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

Figure 10-4. Search for an ON-Unit 10-17

Figure 10-5. Effect of Multiple Conditions 10-18

Tables

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

Table 11-2. Assignment of Data Type to Dummy Arguments 11-7

Preface

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.

Intended Audience

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).

Structure of This Manual

This manual is divided into the following sections:

  • See gives an overview of the Kednos PL/I for UNIX compiler.
  • See explains developing a PL/I program.
  • See explains debugging PL/I programs.
  • See describes the file system.
  • See explains record and stream input/output.
  • See summarizes ENVIRONMENT options.
  • See explains input/output statement options.
  • See explains file-handling built-in subroutines.
  • Chapter 9 describes the Sort program interface, valid for the ibm dialect.
  • See describes condition handling.
  • See explains using PL/I in the common language environment

See contains the Free Software Foundation's Copyleft.

Where to Find More Information

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:

man 3pl1 intro

 

The Digital UNIX documentation set gives complete information on the operating system.

Conventions

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.

 
. Documentation Conventions Table

Conventions

Meaning

 

This symbol represents a single stroke of the RETURN key on the keyboard.

 

This symbol represents a control key combination. The letter X can be bny keyboard character. To generate a control key combination, hold down the CTRL key while pressing the specified letter.

command

System text and code in examples and in text appears in the Courier typeface. Since the UNIX operating system differentiates between lowercase and uppercase characters, literal strings in examples and text must be entered exactly as shown.

bold

User input in interactive examples appears in the bold Courier typeface.

bold

Bold words in text indicate the first use of a new term.

italic

File and variable names appear in italics..

 

Vertical ellipses indicate that irrelevant parts of the program text or program output have been omitted..

quotation mark
apostrophe

The term quotation mark is used only to refer to the double quotation mark character ("). The term apostrophe is used to refer to the single quotation mark character (').

#

A # symbol is used in some contexts to indicate a single ASCII space character.)

pl1(1)

Specifies a manual page. For more information, type:
man section page

 

This margin icon indicates that the paragraph contains important information to which you should pay close attention.

SYNTAX

Syntax (format) diagrams appear in the Helvetica typeface.

. . .

Horizontal ellipses indicate that additional parameters, options, or values can optionally be entered. When a comma precedes an ellipsis, it indicates that successive items must be separated by commas. Used in syntax diagrams.

[ ]

Square brackets indicate that a syntactic element is optional and you need not specify it. Used in syntax diagrams

 

Brackets surrounding two or more stacked items indicate conflicting options, one of which can optionally be chosen. Used in syntax diagrams

 

Braces surrounding two or more stacked items indicate conflicting options, one of which must be chosen. Used in syntax diagrams

FILE (file-reference)

An uppercase word or phrase indicates a keyword that must be entered as shown; a lowercase word or phrase indicates an item for which a variable value must be supplied. This convention applies to syntax diagrams, not to code examples.

 

 

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.

 

Developing a PL/I Program

This chapter describes how to create, compile, link, and run a Kednos PL/I for UNIX program.

Creating Source Files

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:

Compiling and Linking a PL/I Program

The following sections discuss the pl1 command and the command options.

The pl1 Command

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.

Format
pl1 [option] ... filename.suffix [filename.suffix ...]
 
option

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 .

filename.suffix

An input source file containing the program or module to be compiled. You must specify a file suffix. Valid suffixes are:

  • PL/I: .pli or .pl1
  • Object code: .o

You can include more than one file specification on the same command line by separating the file specifications with a space as follows:

pl1 file1.pl1 file2.pl1

 

Compilation with pl1

The driver command, pl1, invokes the following processing phases to compile and optionally link edit the source file:

  • PL/I compiler: The front-end processes the source file, producing an internal language called ucode. PL/I then converts the optimized ucode to assembly language.
  • Assembly: Converts the assembly-language code to an object file.
  • Link edit: Merges object files and libraries producing an executable binary.

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.

For example:

pl1 file.pli -c

 

This produces the linkable object file.o.

The default name of the executable binary is a.out. For example:

pl1 file.pl1

 

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:

pl1 file.pl1 -o file

 

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:

pl1 file.o -o file

 

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:

pl1 file1.o file2.o -o file

 

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.

Compiling Multi-Language Programs

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:

pl1 -c plifile.pli

cc -c cfile.c

 

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.

Driver Options

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.

. Alphabetic List of PL/I Driver Options

Option

Long Option

Meaning

-a

--align

Specifies natural alignment. On Alpha processors, -a is equivalent to -a8

-an

--align=n

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.

Note: Some programs rely on structures not being padded for alignment.

-c

--compile_only

Suppresses the loading phase of the compilation. Produces an object file even when you compile only one program.

-D dialect

--dialect=dialect

Defines the dialect of the compiler, where dialect is one of the following: ibm, dec, ansi. The default dialect is ansi.

See the Kednos PL/I for UNIX Reference Manual for information on the differences in dialects.

-g

--debug

Produces debugger symbol table information. This option implies the -N option.

-Idir

--include_dir=dir

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.

-k

--check

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.

See the Kednos PL/I for UNIX Reference Manual for more information on the STRINGRANGE and SUBSCRIPTRANGE conditions.

-lname

--library=name

When linking, search an object library named libname.a, where name is a string.

-L

--library_dir

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.

-Ldir

--library_dir=dir

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

--case lower

Specifies that all identifiers are case insensitive and externals are converted to lower case. This is the default.

-m mix

--case mix

Specifies that all identifiers are case sensitive. Allows mixed case identifiers

-m upper

--case upper

Specifies that all identifiers are case insensitive and externals are converted to upper case.

-M lower

-M mix

-M upper

--include_case lower

--include_case mix

--include_case upper

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.

-N

--non_shared

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.

-o file

--output file

Generates an executable binary with the specified file name. If you do not use this option, the compiler names the executable binary a.out.

-O

--optimize

Performs all optimizations, including global register allocation.

Use this option to create ucode object files for all PL/I source files. The newly created ucode object files, ucode object files specified on the command line, the run-time start-up routine, and all the run-time libraries are ucode linked. The compiler optimizes the resulting ucode linked file, then links it as usual, producing an executable binary. The ucode linking does not produce an .o file.

 

Restrictions: The -c option cannot be specified with the -O option. The -O option must precede all source file arguments.

-p
or
-p1

--profile
or
--profile=1

Generate information for profiling.

Use this option to prepare for profiling by periodically sampling the program counter value. The option affects run-time loading. When loading occurs, the standard run-time start-up is replaced by the profiling run-time start-up routine. The level 1 profiling library libprof1.a is searched.

-p0

--profile=0

Do not generate information for profiling. This is the default.

-P
or
-P1

--preprocessor
or
--preprocessor=1

Turns on the preprocessor phase of compilation. This is the default for the -D dec dialect.

See the Kednos PL/I for UNIX Reference Manual for more information on the preprocessor.

-P0

--preprocessor=0

Turns off the preprocessor phase of compilation. This is the default for the -D ibm and -D ansi dialects.

-s

--list

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.

-T variant

--variant variant

Defines the compilation variant used by the VARIANT preprocessor built-in function. Ignored if you compile without using the preprocessor.

See the Kednos PL/I for UNIX Reference Manual for more information.

-u suffixname

--suffix suffixname

Defines the file suffix for include files. Supplied for compatibility with Digital and valid for the -D dec dialect only.

-v

--verbose

Displays the compiler passes, with their arguments, input, and output files, as they execute. Also displays resource usage in the C shell time format.

-w

--nowarn

Suppresses compiler warning messages.

-x

--xref

Includes cross reference information in the listing file. Implies -s; you need not use -s if you use -x.

Linking Objects using the pl1 Command

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.

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:

  • libpli.a

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.

  • libplit.a

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.

  • Indexed file support is an add-on option to Kednos PL/I for UNIX.
  • libpliisam.a

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:

pl1 . . . -lx11

 

Library Search Path

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:

1st directory specified by -L
  1. 2nd directory specified by -L
  2. Last directory specified by -L
  3. The default search directories, as listed in the manpage for ld on your system, unless you specified the -L option without a path

PL/I Preprocessor

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.

Preprocessor Compilation Control

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.

For example:

%DECLARE HOUR FIXED;

%HOUR = SUBSTR(TIME(),1,2);

 

%IF HOUR > 7 & HOUR < 18

%THEN %FATAL 'Please compile this outside of prime time';

 

%DECLARE T CHARACTER;

%ACTIVATE T NORESCAN;

%T = '''Compiled on '||DATE()||'''';

 

DECLARE INIT_MESSAGE CHARACTER(60) VARYING INITIAL(T);

 

%IF VARIANT() = ''| VARIANT() = 'NORMAL'

%THEN

%INFORM 'NORMAL';

%ELSE

%DO;

%IF VARIANT() = 'SPECIAL';

%THEN

%INFORM 'SPECIAL';

%ELSE

%IF VARIANT() = 'NONE';

%THEN %;

%ELSE

%DO;

%T = '''unknown variant '||variant()||'''';

%WARN t;

INIT_MESSAGE=INIT_MESSAGE||' with '||T;

%END;

%END;

PUT SKIP LIST (INIT_MESSAGE);

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.

Preprocessor Procedures

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:

  • Preprocessor statements can invoke preprocessor procedures. In addition, preprocessor statements from within preprocessor procedures can invoke other preprocessor procedures.
  • Statements from the source program can invoke preprocessor procedures.

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:

  • Positional argument lists end with a right parenthesis. They use parameters sequentially, as in a parenthesized list. Positional argument lists can be used in any preprocessor procedure.
  • Keyword argument lists end with a semicolon. They use parameters in any order, as long as each keyword matches the name of a parameter. Therefore, the order in which you list them does not affect the correct matching of parameters and arguments. You can only use keyword argument lists when the preprocessor procedure contains the STATEMENT option and is invoked from a nonpreprocessor statement.

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.

Preprocessor Statements and Procedures

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

single variable */

%DECLARE (A,B) CHARACTER; /* a factored preprocessor

declaration */

%HOUR = SUBSTR(TIME(),1,2); /* preprocessor assignment

statement using two built-in

functions */

 

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.

Preprocessor Built-In Functions

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.

Compiler Listing Files

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-2 1 0

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-8 1 0

0-9 1 0 put skip list ('What is the answer?: ');

0-10 1 0 get list (input_y);

0-11 1 0 put skip list ('Type the most common file name: ');

0-12 1 0 get list (input_x);

0-13 1 0

0-14 1 0 if (x = input_x) & (y = input_y)

0-15 1 0 then

0-16 1 0 valid=real_programmer();

0-17 1 0 else begin;

0-18 2 0 put skip list ('You''re not a real programmer!');

0-19 2 0 goto exit;

0-20 2 0 end;

0-21 1 0

0-22 1 0 real_programmer: procedure() returns(bit(1));

0-23 2 0

0-24 2 0 /* this exists to show another subroutine level */

0-25 * 2 0 /* in the listing file */

0-26 2 0

0-27 2 0 declare real_prog bit(1);

0-28 2 0

0-29 2 0 put skip list ('You''re a Real Programmer!!!');

0-30 2 0 real_prog = '1'B;

0-31 2 0

0-32 2 0 end; /* real_programmer */

0-33 1 0

0-34 1 0 exit:

0-35 1 0

0-36 1 0 end Test;

<FF>

 

***** EXTERNAL ENTRY POINTS ***** Ã

 

name class size loc attributes

 

TEST constant ENTRY EXTERNAL

 

procedure TEST on line 1

 

name class size loc attributes

EXIT constant LABEL

def ref set

34

19

 

INPUT_X automatic 8c 84 CHAR(8) UNALIGNED INITIAL

def ref set

4

12

14

 

INPUT_Y automatic 1 96 FIXED BIN(15,0) ALIGNED PRECISION INITIAL

def ref set

6

10

14

 

REAL_PROGRAMMER

constant ENTRY RETURNS INTERNAL

def ref set

22

16

 

SYSIN constant FILE EXTERNAL

def ref set

1

10

12

 

SYSPRINT constant FILE EXTERNAL

def ref set

1

9

11

18

29

 

VALID automatic 1b 112 BIT(1) UNALIGNED INITIAL

def ref set

7

16

X automatic 8c 92 CHAR(8) UNALIGNED INITIAL

def ref set

3

14

Y automatic 1 128 FIXED BIN(15,0) ALIGNED PRECISION INITIAL

def ref set

5

14

 

begin block on line 17

 

no declared names

 

procedure REAL_PROGRAMMER on line 22

 

name class size loc attributes

 

REAL_PROG automatic 1b 96 BIT(1) UNALIGNED

def ref set

27

30

 

***** ENTRY POINTS AND ARRAY OF LABELS *****

 

name class size loc attributes

 

TEST constant ENTRY EXTERNAL

REAL_PROGRAMMER

constant ENTRY RETURNS INTERNAL

def ref set

22

16

 

<FF>

 

*****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.

Compiler Error Messages

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.*****

message-text

 

The nn specifies the error number.

The s specifies the severity of the error. The following letters represent possible severities:

  • 4-- Fatal. The compiler stops executing, does not continue the compilation, and does not produce an object module. You must correct the error before you can compile the program.
  • 3-- Error. The compiler continues, but does not produce an object module. You must correct the error before you can successfully compile the program.
  • 2-- Warning. The compiler produces an object module. It attempts to correct the error in the statement, but you should verify that the compiler's action is acceptable. Otherwise, your program may produce unexpected results.

The compiler produces messages with warning severity if it encounters the following:

  • Syntax errors (such as a missing END statement) that the compiler attempts to fix.
  • Language elements (such as undeclared variables) that are not part of the PL/I General-Purpose subset but do belong to full PL/I.
  • Legal PL/I General-Purpose Subset usage (such as assignment of a bit-string value to a fixed-point binary variable) that nonetheless may represent a programming error or produce unexpected results.
  • 1 -- Informational. This message usually appears with other messages to inform you of specific actions taken by the compiler. Informational messages also indicate nonstandard constructs and items that are syntactically correct, but that may contain programming errors. No action is necessary on your part. You may, however, want to check that your code performs as expected, and possibly modify the specified line.

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.

Running a PL/I Program

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.

Run-Time Errors

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.

Passing Command Line Parameters to a PL/I Program

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.

Accessing Command Line Parameters in PL/I Programs

Kednos PL/I for UNIX provides two methods to access command line parameters:

Through procedure parameters in the main program.

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.

For example:

PARAM: PROCEDURE (name,address,city,state,zip)

OPTIONS(MAIN);

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.

  1. Through array of pointers to parameters.

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:

%INCLUDE pl1std;

 

PARAM_TEST: PROCEDURE (name, address, city, state, zip)
OPTIONS(MAIN);

DECLARE (name, address, city, state, zip) CHARACTER(100)
VARYING;

DECLARE i FIXED BIN;

 

IF ARGC >= 1 THEN

PUT SKIP EDIT ('Name: ',Name) (a,a);

ELSE

PUT SKIP EDIT ('Name is missing') (a);

 

IF ARGC >= 2 THEN

PUT SKIP EDIT ('Address: ',Address) (a,a);

ELSE

PUT SKIP EDIT ('Address is missing') (a);

 

IF ARGC >= 3 THEN

PUT SKIP EDIT ('City: ',City) (a,a);

ELSE

PUT SKIP EDIT ('City is missing') (a);

 

IF ARGC >= 4 THEN

PUT SKIP EDIT ('State: ',State) (a,a);

ELSE

PUT SKIP EDIT ('State is missing') (a);

 

IF ARGC >= 5 THEN

PUT SKIP EDIT ('Zip: ',Zip) (a,a);

ELSE

PUT SKIP EDIT ('Zip is missing') (a);

 

DO I = 1 TO ARGC;

PUT SKIP EDIT ('Parameter ',i, 'is ',ARGS(i)->ARG_CV) (a,f(2),a,a);

END; /* of do loop */

 

END; /* of program */

 

Specifying Command Line Parameters

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"

 

  • Command line format varies in different UNIX shells. If this format does not work, see the manual pages for your shell for the correct format.

 

Using the dbg Debugger

This chapter describes how to use the dbg debugger with Kednos PL/I for UNIX programs. This chapter provides the following information:

Overview

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.

In addit