PL/I

PL/I Logo

Why you should consider using PL/I:

  1. The best part of PL/I is the input and output. You can rely on it.

    The input/output is achieved with statements that are ready to use, and easy to use.

    There's no setting up to do. They are not procedures or functions dressed up to look like statements.

    In formatted output, you don't get silly numbers displayed when you include the format specification, but omit the name of the variable (as happens in the language C, for instance); nor when you use the wrong format (e.g. I4 with a FORTRAN REAL variable). PL/I converts to/from the type that you specify, be it integer, fixed-point, or string. You don't get silly things happening because you left off the "&" from the "scanf" function in C. That's because the input operation (GET) is a statement, not a function.

    And when you want formatted output, you have a variety of formats that you can choose, such as PICTURE format, with drifting signs and drifting $ sign. You can insert commas or spaces in very long numbers, to make the output readable (e.g. 123,456,789.356,251 is better than 123456789.356251). You can use either PICTURE formats or the specific codes to get integer, decimal fixed-point, and floating-point outputs.

    If you are using the European convention for numbers, that's easily done with PICTURE formats (e.g., to produce 123.456.789,00).

    And if you don't want to be bothered with formats, you can use simple free-formatted output, e.g. PUT (X);

  2. For business applications, you can have decimal data, whereby data is stored exactly (e.g. 5.14 is stored EXACTLY, not as 5.13999), and arithmetic operations give exact results (e.g. 3 x 5.14 gives you 15.42 precisely, not 15.41998)

  3. Files are easy to use. If you can do output to the screen, and input from the keyboard, you can do Input/Output to files, simply by inserting the file name into the GET or PUT statement thus: GET FILE (MYDATA) etc.

Outstanding and helpful PL/I facilities include:

  1. The debugging facilities are all part of the language (for example, checking for subscript bound errors and string reference errors with SUBSCRIPTRANGE and STRINGRANGE etc are most helpful, along with appropriate ON statements to display the values of variables).

    The best part is that you can display everything you need (statement number, values of variables, a trace of procedure calls, etc) instead of those cryptic messages (from other languages) such as "floating-point trap" at some unidentified location somewhere in the program. (When you've had this message in a 20,000 line program, you'll know what I mean!)

  2. And if your program gets stuck in a loop, just hit CTRL-BREAK, and your ATTENTION ON-unit will tell you precisely which statement it's executing. Not only that, it lets you do anything you want, including printing the values of all (or preselected) variables, and changing any or all of the values of variables.

    You don't have to re-run your program (with new output statements) to find out in which loop it's stuck! (and then run it yet again to display the values of variables you think you need).

    And if your program was running OK after all, you can resume execution again, as if nothing had happened.

  3. The ability to intercept errors (via ON statements) and to continue execution;

  4. The simple, handy I/O statements GET LIST, PUT LIST, along with the very handy PUT DATA statement (for debugging mostly).

  5. Everything is "ready to go" unlike some other languages, such as Ada!

  6. The "whole-array" operations simplify programming and increase under- standing, and increases execution speed into the bargain; If A and B are arrays, you can write A = B; to copy an array. You can use PUT (A); to print an array. [these are trivial examples -- much more is available]

  7. Dynamic arrays provide the means to write a general program for any size of array. You aren't bound by some artificial limit. You automatically obtain exactly the amount of storage you need for an array.

  8. The COMPLEX data type is provided, which simplifies the preparation of programs because commonsense complex arithmetic is available.

    A number of essential functions is at hand for producing: complex square root, the conjugate, the absolute value, and for extracting either the real or complex components, and for fabricating a complex number from two real numbers (SQRT, CONJG, ABS, REAL, IMAG, CPLX). The ** operator is available for raising a complex number to a given power. A range of (complex) trigonometric functions is provided (includes SIN, COS, SINH, COSH, etc, and mathematical functions such as LOG).

    Even more importantly, debugging is simplified, because the error messages are specific to complex number operations. (If you have used complex arithmetic without using the COMPLEX facilities, the best that the error messages can tell you is in terms of real (floating-point) operations, which don't necessarily make sense).

    And the COMPLEX type can be applied to integer as well as to float- ing-point data.

  9. PL/I has excellent string-handling facilities. First, there are two types of string -- the fixed-length string and the varying-length string. These two data types are supported by a range of functions that speed up string processing compared to other languages. It isn't necessary to write your own "string-search" routines like you need to in other languages such as C and Pascal, for example. The search functions are already there (INDEX, SEARCH, SEARCHR). What's more, if the machine has a "search" instruction, it can use that, and search faster than some hand code using a loop. (Having to write your own search routine is like having to turn out your own nuts and bolts on a machine lathe.)

    PL/I can search from either the right-hand end or from the left-hand end of a string (e.g., SEARCH and SEARCHR).

    Many string operations are achieved simply in PL/I:

    • Joining strings is a simple operation (catenation). And with VARYING-length stings, you don't get "extra: blanks thrown in at the end of the first string, like you get with some languages.
    • The length of a string can be discovered by using the LENGTH function (a fast operation).
    • Strings containing blanks (or any unwanted characters) at the beginning or the end can be removed using the TRIM function.
    • Strings can be centered using the CENTER built-in functions (helps with page headings, etc) and so on.

Other functions include TRANSLATE, for changing ASCII <--> EBCDIC, and for converting upper to lower case, or for replacing special codes such as TAB with a blank, or for any other conversion; and VERIFY, for performing a search, validating data etc.

  • Doing some Year 2000 work? PL/I has the DATETIME function, returning a four-digit year. IBM's VisualAge PL/I for OS/2, Windows, AIX, and OS/390 have built-in functions that support the Millennium Language Extensions that are now part of all their compilers (Enterprise and VisualAge). With these extensions, PL/I can work on 2-digit dates, without the need to have the external data in 4-digit form.
    Thus, in some situations, old programs (manipulating dates having 2-digit years) can handle dates from the year 2000 and beyond. And all that is needed are trivial alterations to declarations! That translates to a huge saving in Y2K conversion costs.
    In VisualAge and Enterprise PL/I, the DATETIME built-in function can produce the date in any one of 37 different formats (e.g., year first, day first, month as Feb or FEB, for example). The other functions (which also support the Y2K facilities) are: DAYS, DAYSTODATE, DAYSTOSECS, SECS, SECSTODATE, SECSTODAYS, VALIDDATE and WEEKDAY. With these functions, it is easy to perform day computations -- even those that extend into the year 2000 -- for example, to calculate the day name of a day that is, say, 40 days hence.
    These functions include REPATTERN, Y4DATE, Y4JULIAN, and Y4YEAR, the latter three converting 2-digit years to 4-digit years.

  • A macro pre-processor is available for PL/I on IBM mainframe (OS) and IBM VisualAge PL/I for OS/2 for the PC, Windows NT, AIX, OS/390, and Liant OPEN PL/I, and probably others.

  • And when you need to do something special (rarely, but it's nice to know that you have something to fall back on in an emergency) it's there -- With UNSPEC you can peek at the bits of a data item (be it a character string, an integer, bit string, or floating-point data).

    For further information about PL/I, systems, and suppliers, please read on . . .

    Need to know what's in PL/I ? There are also informative newsletters The PL/I Newsletter and The PL/I Connection to keep you up-to-date.

    Like some information about IBM's PL/I products including PL/I for OS/2? Or would you just like specific details about the enhanced PL/I for OS/2? Or PL/I Set for AIX? (the compiler is also available on Windows 98 and Windows NT).

    Also try

    Liant's PL/I which you can use on a variety of Unix systems and Windows systems including Windows XP, 2000, Me/98 (Intel), Redhat Linux (Intel), HP 9000 HP-UX, SPARC Solaris 2.x, Solaris ix (Intel), and IBM RS/6000 AIX. Contact Liant for other systems.

    Digital Equipment Corporation's PL/I . Available for Compaq systems is Kednos PL/I for Digital Unix which is available on a range of Compaq's systems. Kednos PL/I for Compaq Alpha (including a free hobbyist's licence) can be found by browsing at Kednos.

    Look at some Frequently-asked Questions and their Answers.

    You might also like to browse PL/I.

    Other PL/I resources include: A comparison of PL/I and C? and Reverse Engineering Tool for PL/I, which is is undergoing beta testing. For further information, email info@levtech.com
    If this site is down, visit them at Levtech.

    PL/I source code, to implement the new built-in functions (on non-VisualAge PL/I systems) SEARCH SEARCHR and VERIFY (3-argument version) and VERIFYR) (these are in plain text form).
    These are just a few samples. There are more in the PL/I Resources page.

    Further PL/I examples of a tutorial nature are an Shell Sort and a linked list creation procedure (under construction).

    Here you'll find a catalog of PL/I resources including source codes. In particular, you'll find source codes for Year 2000 dates.

    Updated 14 May 2003.


    This document is available from: http://www.users.bigpond.com/robin_v/pli.htm