For decades, IBM's implementation of strings in its PL/I
compilers have been limited to 32,767 characters, even though
computers now have considerably larger memories than that.
Back in the days when the first full PL/I compiler was introduced
in 1966 - for the S/360 - main memories of 64K bytes and 128K bytes were
fairly typical, and strings of 32,767 characters were
considered large.
From the 1970s, the size of main memories have increased,
and following the
advent of the PC, have increased so phemomenally that 256Mb main
memories now seem commonplace.
Now, at last, it seems that this issue is being addressed,
with the provision of five functions that effectively handle
strings of any size. However, the implementation is
not consistent with the existing mechanisms for handling
strings of size up to 32,767 characters, and so is not an
extension of it.
This provision in no way meets the need for
long strings in accordance with its longstanding implementation,
particularly as regards varying strings.
Nevertheless, we welcome IBM's recognition of the need for
long strings.
We welcome your contributions to this newsletter. It will
continue only through your efforts. Thank you in advance.
Please send any comments and contributions for the next newsletter to
r|o|b|i|n|51 at dodo dot com dot au
The seventh issue may be downloaded from:
The PL/I Newsletter, No. 7, December 2004.
The sixth issue may be downloaded from:
The PL/I Newsletter, No. 6, December 2003.
The fifth issue may be downloaded from:
The PL/I Newsletter, No. 5, August 2002.
The fourth issue may be downloaded from:
The PL/I Newsletter, No. 4, November 2001.
The third issue may be downloaded from:
The PL/I Newsletter, No. 3, June 2001.
The second issue may be downloaded from:
The PL/I Newsletter, No. 2, September 2000.
The first issue may be downloaded from:
The PL/I Newsletter, No. 1, July 2000.
IBM Releases Version 3.4 of PL/I
by Robin Vowels
In December 2004 IBM released Version 3.4 of PL/I.
This version applies to z/OS, AIX, and Windows systems.
In this version :
- The built-in function REPLACEBY2 has been added.
- The pre-processor has some new built-in functions:
LOWERCASE, UPPERCASE, MACNAME, and TRIM.
- The DEFAULT statement supports the syntax of the earlier
mainframe compilers.
- RETURN statements may be used in BEGIN blocks.
- The NOINIT attribute has been added.
- A new compiler option has been added - PRECTYPE -
for decimal arithmetic when
mixed binary and decimal operands are used.
The format item V and some new built-in functions
were added in Version 3.
The built-in function XMLCHAR is for XML strings.
The built-in functions MEMINDEX, MEMSEARCH, MEMSEARCHR,
MEMVERIFY, and MEMVERIFYR,
are intended to address the limitations of
of strings (maximum length 32767 characters), and permit
strings containing up to 2,147,483,647 characters
to be processed.
Each function searches a buffer defined as an array of CHARACTER(1).
The key is either a character string or another buffer
(again defined as an array of CHARACTER(1) ).
Note: In all of these functions, it is the programmer's
responsibility to ensure that the length of the data
does not exceed the length of the buffer.
The new built-in function REPLACEBY2 is intended to
facilitate conversion of European characters - such
as those requiring the umlaut - to western style.
(However, there is no complementary reverse function.)
The V format descriptor was added for EDIT-directed input.
- MEMINDEX is like INDEX in that it searches a buffer
using a key. The function returns the position of the key
in the buffer. Usage:
MEMINDEX (b, k, key)
where b is a buffer, k is the number of characters in the buffer,
and key is a character string for searching the buffer.
MEMINDEX (b, k, keybuffer, keylength)
In this function reference, keybuffer is an array of
CHARACTER(1) and keylength
is the number of characters in keybuffer.
-
MEMSEARCH is like SEARCH. The function returns
the position in the buffer of the first character
that matches a character in the key.
MEMSEARCH (b, k, key)
where b, k, and key are as for MEMINDEX.
MEMSEARCH (b, k, keybuffer, keylength)
where b, k, keybuffer, and keylength, are as for MEMINDEX.
- MEMSEARCHR is the same as MEMSEARCH, except that the search
is conducted from the right-hand end of the data in the buffer.
- MEMVERIFY is like VERIFY. The function returns
the position in the buffer of the first character
that does not match any character in the key.
MEMVERIFY (b, k, key)
where b, k, and key are as for MEMINDEX.
MEMSEARCH (b, k, keybuffer, keylength)
where b, k, keybuffer, and keylength, are as for MEMINDEX.
- MEMVERIFYR is the same as MEMVERIFY, except that
the search is conducted from the right-hand of the data
in the buffer.
- REPLACEBY2 is like TRANSLATE.
Usage:
REPLACEBY2 (string, rep, original)
searches a copy of string. If a character in original
exists in string,
the corresponding pair of characters in rep are substituted.
The function returns the modified string.
Example: REPLACEBY2 (s, 'ssae', 'ßæ')
Let s contain the string 'alphaß betaæ'.
The function returns 'alphass betaae'.
Let s contain the string 'verblaßtem'.
The function reference REPLACEBY2 (s, 'ss', 'ß')
returns the value 'verblasstem'.
The function can also be used for duplicating any apostrophes
within a string, e.g., Let s contain the
characters Tom's.
REPLACEBY2 (s, "''", "'") yields Tom''s.
- XMLCHAR for handling XML strings.
-
The new compiler option for the ADD, SUBTRACT, MULTIPLY, and DIVIDE
built-in functions is PRECTYPE. It specifies the type of the
result when mixed binary and decimal operands are used. It also
specifies whether the third and fourth arguments are to be
interpreted as specifying the number of binary digits or decimal digits.
-
The new compiler option STRINGOFGRAPHIC is available
for choice of GRAPHIC used with STRING.
-
The V-format item may be used only with GET EDIT.
When it is used, data to the end of the line is assigned to the
variable in the GET statement.
In this respect, it is the same as the L-format item.
However, the file pointer is not advanced (that is,
the buffer if not cleared). In order to advance to the
next line in the file, a GET statement using one of the other
descriptors must be used, or a GET SKIP statement.
Essentially, the V descriptor is a view descriptor,
permitting the user to look at the record (without changing
the position of the file).
-
The new attribute NOINIT specfies that no initialization
of a variable is to take place.
It is intended to be used with structures defined with the
LIKE attribute, thus avoiding any initialization that
would otherwise be inherited from the other structure.
For more information, visit
http://www-306.ibm.com/software/awdtools/pli/plizos/library/
SOME USEFUL TIPS
by Robin Vowels
This is an example of what you can do with PL/I in the scientific area,
namely, to read in an array, to report typos, and provide a summary.
ARRAYIN: PROCEDURE OPTIONS (MAIN);
DCL A (20) FLOAT;
dcl Error_count fixed initial (0);
on conversion begin;
put skip list ('A faulty data field ' || onsource ||
' was encountered in element number ' || trim(count(sysin)+1));
onsource() = '0';
Error_count = Error_count + 1;
END;
GET (A);
put skip edit ('Summary: ', Error_Count, ' errors were encountered') (a);
put skip list (a);
end arrayin;
Data:
123 45 6t 9) 31 35 79
-9 4e 27 35 61 24 19
14 1;2 3 5 435 691 7E2
Output:
A faulty data field 6T was encountered in element number 3
A faulty data field 9) was encountered in element number 4
A faulty data field 4E was encountered in element number 9
A faulty data field 1;2 was encountered in element number 16
Summary: 4 errors were encountered
Another useful enhancement for matrices:
ARRAYIN: PROCEDURE OPTIONS (MAIN);
DCL A (5,5) FLOAT;
dcl (i, j) fixed binary;
dcl Error_count fixed initial (0);
on conversion begin;
put skip list ('A faulty data field ' || onsource ||
' was encountered in element number ' || trim(count(sysin)+1));
put edit ('in row ' || trim(i) || ', column ' || trim(j)) (a);
onsource() = '0';
Error_count = Error_count + 1;
END;
GET (((A(i,j) do j = 1 to 5) do i = 1 to 5));
put skip edit ('Summary: ', Error_Count, ' errors were encountered') (a);
put skip list (a);
end arrayin;
Data:
123 45 6t 9) 31 35 79
-9 4e 27 35 61 24 19
14 1;2 3 5 435 691 7E2
894 781 7o9 7.5
Output:
A faulty data field 6T was encountered in element number 3 in row 1, column 3
A faulty data field 9) was encountered in element number 4 in row 1, column 4
A faulty data field 4E was encountered in element number 9 in row 2, column 4
A faulty data field 1;2 was encountered in element number 16 in row 4, column 1
A faulty data field 7O9 was encountered in element number 24 in row 5, column 4
Summary: 5 errors were encountered
Usefulle Webbe Lynx ...
Peter Flass is building a resource at:
Peter Flass's PL/I home page.
The spring 2000 edition of the
COBOL and PL/I newsletter
has some topics about PL/I. The specific PL/I
topics may be viewed separately, or the entire newsletter in PDF
format may be downloaded.
Of particular interest is the use of PL/I as a programming
language for the Common Gateway Interface (CGI).
The PL/I
Connection
newsletter.
The PL/I Connection Newsletter No. 11 , December 1997.
The PL/I Connection Newsletter No. 10 , April 1997.
Current IBM PL/I offerings in the U.S.
IBM has enhanced VisualAge® PL/I with powerful features to increase
development productivity, simplify the maintenance of your legacy code,
and provide seamless portability from your host to your workstation. It
also provides the tools needed to identify your Year 2000 date-related
fields on both OS/2 and Windows NT.
VisualAge PL/I Enterprise Edition Version 2.1 combines the two separate
offerings from the previous release of VisualAge PL/I (Standard and
Professional) into a single offering available on both the OS/2 and
Windows NT platforms. By doing so, it provides these productivity
features:
- remote edit/compile
- redevelopment tools
- cross platform development
- year 2000 assessment strategies, find and fix, and test capabilities
Also included as an extra bonus offering is VisualAge CICS® Enterprise
Application Development, which enables CICS host application development
on the workstation.
- Product number 04L6564: VisualAge PL/1 Enterprise V2.1
- 04L6565: VisualAge PL/I Enterprise V2.1 Upgrade from Prior
IBM PL/I Workstation or Competitive Products Program Package
CD-ROM
- 04L6567: VisualAge PL/I Enterprise V2.1 Upgrade from
Professional V2.0 Program Package CD-ROM
- 04L6566: VisualAge PL/I Enterprise V2.1 Upgrade from Standard
V2.0 Package CD-ROM