..
PL/1
ACKNOWLEDGEMENTS
This manual was largely compiled from material prepared BY THE STAFF OF THE UNIVERSITY OF MICHIGAN COMPUTING CENTER.
Their documentation was invaluable and we are indebted to THEM FOR ALLOWING US TO USE IT. 1N PARTICULAR, THE FOLLOWING WERE MOST USEFUL:
MTS Users' Manual, Second Edition, Volumes I and II MTS Users' Manual, Third Edition, Volume 2
Introduction to MTS and the Computing Center (Flanigan) Computing Center News Items Computing Center Memos
The Computing Center wishes to personally acknowledge the ASSISTANCE OF MK i EALEXANDERAND DON BoETTNER WHO HELPED US TO ESTABLISH MTS AT THE UNIVERSITY OF ALBERTA.
Acknowledgement should also be made to the Computing Centre, University of British Columbia, for information obtained from SOME OF THEIR DOCUMENTATION AND TO I.B.M., WHOSE MANUALS PRO VIDED CERTAIN SECTIONS FOR OUR MANUALS.
DISCLAIMER
This MIS manual Is a combination of earlier manuals,
update notices, memos and limited experience with the system Itself. Because of this, certain discrepancies are bound to occur and the Computing Center would appreciate being notified
of all differences between what this manual says and what the sys tem actua 1 1y does.
This publication is intended to represent the current
state-of-the-system. However, it should not be construed as an obligation to maintain the system as so stated. The MTS
system, like most good systems, is continually being improved. As a result, additions, extentions, changes and deletions will occur. Notice of such changes will be made and provision for a manual updating service has been planned. Errors, comments and suggestions should be sent to: Information Coordinator Computing Center
Un i vers Ity of A1berta
PL/1 May 1970
PL/1 TA B L E O F C O N T E N T S
SUMMARY
1.01
LANGUAGE
DESCRIPTION
References Conventions
and
Printer/Punch
Data
2.01
Restrictions
Control
Interchange
Characters
2
2.01 2.01
2.03
03
Combination of pL/I with other Languages ...2*0A PROCESSOR
DESCRIPTION
Compiler Description Batch EXECUTION
Running How to
Options of Options Compilation
TIME
a
C O N S I D E R AT I O N S
PL/1 get
a
program dump
*PL1LIB
PL/1 batch CPUTIME ELAPSED IHEREAD IHERITE PLIADR PLCALL PLIRC band SIGNOFF USERID
3.01 3.02 3.03 3.05 A.01
A.01 A.03 A.OA
SUBROUTINES
5.01 5.01 5.01 5.02 5.03 5.03 5.OA 5.05 5.07 5.07 5.08 5.08
1.01 PL/I
SUMMARY
* P L 1
SCARDS = source input
SPRINT = listing & diagnostics SPUNCH = macro and/or object decks 0
=
object
Paramete
module
rs
PA R = [ I / O k e y w o r d s ] , [ o p t i o n s ] , . . . . I / O k e y w o r d fi l e m o d i fi e r p a r a m e t e r s : @ U - u n d e fi n e d l e n g t h @V @F
-
@B - blocked @A - attach CC bit @M - a 11ach MCC b i t
variable length fi x e d l e n g t h
Opt i ons:
[
iiMIfL
CHAR60
]
r COMP . ^'iToTCTMP-'
[,DECK .
NODECK^
r E B C D I C ,
r LIST .
"• TTY ^
NOLIST^
FLAGS
r,LOM ]
r
'•NOLOAD"'
MACDCK
,
r
NOMACDCK^ ^OSOURCE^
I, XREF .
FREE
rA
.
r.C60, r ld ,
NLD^
Default
^
1
STMT NOSTMT
r
D
Va 1 u e s :
SPRINT = *MSINK*@VA(129,125) SPUNCH = *PUNCH*@F80 =
GUSER
=
OPT SIZE
60
= =
=
01 lOP
(1
,72)
['n|] [.^]
[•Shd]
SCARDS = *MS0URCE*@U80
SM
[
^
[ 0 = n ] [ , L C = n ] [ , S[.SIZE=yyyP] IZE=v
LC
^'NONESTJ
Abbreviated
t'Nj
0
r nest ,
[,LINECNT= n] [,OPT = nn] [,SIZE = yyyP] r SORMGIN=(m,n,c),
NOXREF-*
Options
.
r S0URCE2 ] ^'N0S0URCE2
r SOURCE.
[. OPJJST. ^NOOPLIST^
MACRO
^'NOMACRO^
[,SM=(m,n,c)^
2.01
PL/I
LANGUAGE DESCRIPTION Refe
rences
The following IBM manuals are recommended as reference texts
.
1. A PL/1 Primer (C28-6808)
2. A Guide to PL/1 for Commercial Programmers (C20-1651) 3. A Guide to PL/1 for FORTRAN Users (C20-1637) A. PL/1 Reference Manual (C28-8201)
5. PL/1 (F) Programmer's Guide (C28-650A) The MTS Compiler is derived from IBM's 03/360 fourth version F - l e v e l P L / 1 C o m p i l e r w i t h m o d i fi c a t i o n s f o r M T S f e a t u r e s .
Conventions 1.
and
INCLUDE
Restrictions convention
The following is the sole support: INCLUDE ident i fi e r , . . . , i d e n t i fi e r ; w h e r e e a c h i d e n t i fi e r r e f e r s t o a n M T S fi l e . T h e s p e l l i n g r u l e s f o r a P L / 1 i d e n t i fi e r m u s t a p p l y . H e n c e , o n l y p e r m a n e n t fi l e s c a n b e used
2.
for
INCLUDE.
U n s p e c i fi e d fi l e n a m e s W h e r e fi l e n a m e s a r e n o t s p e c i fi e d , t h e P L / 1 c o m
piler will default to SPRINT/SCARDS instead of SYSPRINT/SYSIN. 3.
TI
ME
funet
ion
Returns the current time of day as a character
string of length eight in the form hh:mm:ss where hh is hours, rani is minutes and ss is seconds.
A.
D AT E
function
Returns the current data as a character string of length eight in the form mm-dd-yy where mm is m o n t h , d d i s d a y, y y i s y e a r. 5.
D E L AY
statement
If executed, will generally raise an error comment that delaying is not permitted in MTS. 6.
WAIT
statement
IsnotsupportedinMTS. 7 . M u 11 i - 1 a s k i n g
Is unsupported in MTS since a single MTS task can not
have
subtasks.
2 . 0 2
PL/I
Environment options in MTS. CONSECUTIVE
dataset
consists
only
of sequential records. This organization is as s u m e d i f n o n e i s s p e c i fi e d . INDEXED
dataset
is
an
whose
MTS
records
line
can
be
fi l e
pro
c e s s e d b y t h e i n d e x e d fi l e subrouti
REEC OCRO R D
nes.
RFDO R MFAOT R M A T F ( b l o c k s i z e , r e c o r d s i z e ) V(max-b1ocksize ,maxrecordsize ) U(max-block s i ze)
P I OI N N G P OOSSI TI T OI N IN
G
L E AV E
and REWIND options are used to position a magnetic tape volume when
t h e c o r r e s p o n d i n g P L / 1 fi l e closed or when swi tch occurs.
a
volume-
COBOL Opt i on S p e c i fi e s t h a t fi l e s w i t h t h i s a t t r i b u t e w i l l contain instructions mapped according to the COBOL
a l g o r i t h m . T h i s t y p e o f fi l e m a y b e u s e d o n l y f o r READ INTO and WRITE FROM statements. The following
fi g u r e s i l l u s t r a t e t h e e q u i v a l e n t P L / 1 d a t a t y p e s for COBOL data types. CO C OBBOOL L
PL/1 PICTURE with A and/or X
D I S P L AY
picture
character
COMPUTATIONAL
decimal length (=no. of 9s in p i cture) is 1
to
5 to 10 to
k
no equivalent
9 18
F I X E D B I N A RY ( i n t e g e r no equ i valent
C O M P U TAT I O N A L - 1
F L O AT ( n ) B l N A RY ( f o r n < 2 1 ) F L O AT ( n ) D E C I M A L ( f o r n b 6 )
C O M P U TAT I O M A L - 2
1) FLOAT(n)BINARY (for n << 221) F L O A T ( n ) D E C I M A L ( f o r nn << 66))
C O M P U TAT I O N A L - 3
FIXED DECIMAL (precision and scale as in COBOL pic ture) .
2.03 PL/I
Printer/punch
Control
Characters
Two options are available for RECORD CONSECUTIVE OUTPUT
fi l e s o n l y ; C C a n d M C C . T h e y h a v e t h e f o l l o w i n g m e a n i n g : CC
-
carriage
control
MCC - machine carriage control is used. These op tions allow spacing, skipping in record I/O
fi l e s . I t i s t h e u s e r ' s r e s p o n s i b i l i t y t o i n s u r e t h a t t h e fi r s t b y t e o f e a c h r e c o r d contains
a
valid
control
character.
These
options are ignored in stream I/O, and the
g e n e r a l d e f a u l t ( e x c e p t f o r p r i n t fi l e s ) i s
NOCC.
Data
Interchanqe
The ALIGNED and UNALIGNED attributes allow PL/1 programs to use FORTRAN unformatted records. The FORTRA unformatted set consists of records which are a concatenation of internal data items with
o u t r e g a r d t o a l i g n m e n t s t r i n g e n c y. For
example:
INTEGER*A LOGICAL^l
REAL*8
A B
C
WRITE(5)A,B,C This record can be declared as PL/1 structure of 3 data
i
tems
:
DECLARE 1 R UNALIGNED, 2 S F I X E D B I N A R Y, 2 T CHAR(l)
2 U FL0AT(16) ; There are two exceptions:
1. PL/1 (F version k) compiler does not support halfword binary data. 2. FORTRAN IOCS can split its logical records into
several physical records, a technique called spanning. Only unspanned FORTRAN records can be read by PL/1 using UNALIGNED structures.
II. For COBOL data interchange, see COBOL options on the previjou«5 p^g«.
2.0k PL/I
Combination
of
PL/1
with
other
languages
Possible combinations of modules written in other lang uages with those in PL/1 is considerably limited since most
other languages are not structured to support advanced fea tures of the PL/1 language. Assembler users must have an intimate knowledge on the object code structure and require
ments of PL/1 programs. Appendix C of PL/1 (F) Programmer's Guide (form 028-659^-3) describes the PL/1 structure in
de t a i 1 .
3.01
PL/I
PROCESSOR DESCRIPTION N ame : Con ten ts :
The initial object module of the MTS PL/1 Compiler Compilation of MTS PL/1 source programs.
Usage:
The F-level PL/1 compiler is invoked by an
appropriate $RUN command specifying *PL1 as the fi l e
where
the
object
module
is
to
be
found.
Log i ca1 I/O Units Refe
renced: SCARDS
source input followed by an implied e n d - o f - fi l e
S P R I N T SPUNCH
or
$ENDmLE
command,
listing output, in^uding diagnostics
\nacro deck and ob^ct deck output,
^ject module output. $RUN *PL1 Y^QUADRAT /
0
Examp1es:
[(whereXsCARDS ayl SPRINT default to
* S 0 U
SC\RDS:^RIME SPUNCH=-L0AD PAR=DECK,NLD,NT
$RUN $RUN Des cri pt i on
*PL1
SPUkl H^*PUNCH* PAR=M ,MD,NOCOMP ,S0URCE2
The MTS Compil^ iN^rived from IBM's OS/360 fourth versio^ F-leve\PL/l Compiler with mod i f i cat i orv6 for MTS features.
3 . 0 2
PL/I
Compi1er Opt i ons
Compiler options may be passed by the parameter list or in a control record. These options can be written in any order a n d m u s t b e s e p a r a t e d b y c o m m a s . i f c o n fl i c t i n g o p t i o n s a r e s p e c i fi e d , t h e l a s t s p e c i fi c a t i o n i n t h e o p t i o n l i s t w i l l b e I I C A H
Option
A / bbreviated
name
Defau1t
AT R / N O AT R
A/NA
NOATR
CHAR60/CHAR48
060/0^*8
CHAR60
COMP/NOCOMP
C/NC
COMP
DECK/NODECK
D/ND
NODECK
EBCDIC/TTY
EB/T
E B C D I C
EXTREF/NOEXTREF
E/NE
NOEXTREF
F L A G W / F L A G E / F L A G S;
FW/FE/FS
FLAGW
LC=60
L I N E C N T
LIST/NOLIST
L/NL
NOLIST
LOAD/NOLOAD
LD/NLD
LOAD
MACDCK/NOMACDCK
MD/NMD
NOMACDCK
MACRO/NOMACRO
M/NM
NOMACRO
NEST/NONEST
NT/NNT
NEST
OPLIST/NOOPLIST
OL/NOL
O P L I S T
0PT=01
O P T = n n
S I ZE=yyyP
S I Z E
SIZE=10P
SO RMGIN=(mmm,nnn ,ccc )/FREE
SM/F
SM=(1,72)
SOURCE/NOSOURCE
S/NS
SOURCE
S0URCE2/N0S0URCE2
S2/NS2
S0URCE2
STMT/NOSTMT
ST/NST
STMT
XREF/NOXREF
3 . 0 3
PL/I
Description
of attributes
of
listed.
In
each
i d e n t i fi e r
addition,
an
are
to
aggregate
be
length
table is produced for arrays and structures CHMeO/CH/KRkQ
DECK
allows the source language to be written in one of two character sets (60 or ^8 characters).
EBCDIC/TTY
to
s p e c i fi e s t h a t t h e o b j e c t m o d u l e wri
tten
on
be
SPUNCH.
these options allow the programmer to state
in
which
character
code
the
source
program is typed. The BCD option is not supported. The
following
table
gives the correspondence between teletype graphics and PL/1 symbols. TTY
Graphics
•
K e y Comb C o mi bnai nt a i t ion on
PL/I
Syi
sh i f t-0 sh i f t-L f
ot
sh i f t-N
o t h e r s EXTREF
causes a listing of
the
d i ct i ona ry (ESD) of t h e
external symbol object module to
be produced. FLAGW/FLAGE/FLAGS
s p e c i fi e s t h e s e v e r i t y o f d i a g n o s t i c messages to be listed. The following types of messages are indicated: le of message
lec i f i cation FLAGW
w a r n i n g e
r
FLAGE
ror
severe
FLAGS
error
terminal
error
FREE/SORMGIN=
(mmm,nnn ,ccc )
where
1
^
mmm
<
nnn
<
100. The
range
(mmm,nnn) represents the margins for scanning s p e c i fi e d ,
source statements. ccc, if must be outside the range
(mmm,nnn) and indicates the position
3.04 PL/I
in the input line to be used as a car riage
control
buffer.
character
Va l i d
control
in
the
SPRINT
characters
are
"» 0, +, and blank. The FREE option
is equivalent to SM=(1,100). LINECNT=XXX
s p e c i fi e s t h e n u m b e r o f l i n e s t o b e wr i t ten per page.
L!
s p e c i fi e s t h a t t h e g e n e r a t e d m a c h i n e Instructions, constants, etc. are to be
ST
p rInted. LOAD
s p e c i fi e s t h a t t h e o b j e c t m o d u l e I s t o be written on logical unit 0. causes the output records of the complletlme processor to be written on SPUNCH.
If this deck Is to be reprocessed, the s o u r c e m a r g i n s s h o u l d b e s p e c i fi e d S M = ( 2 , 7 2 ) . s p e c i fi e s t h a t c o m p l l e - t l m e p r o c e s s i n g I s required.
I f s p e c i fi e d , c a u s e s t h . e P L / 1 c o m p i l e r t o
indicate In the source listing the PROCEDURE and BEGIN block level count as well as DO 1 eve 1 count.
controls the listing of the options cur r e n t l y a c c e p t e d b y t h e c o m p i l e r. two levels of optimization are now available: 0 P T = 0 0
the object time storage requirements are
minimi
zed.
0PT=01 the execution speed is slightly im proved at the expense of object-time storage
space.
the compiler attempts to obtain nn pages of v i r t u a l m e m o r y. T h e f o l l o w i n g t a b l e s h o w s the text and dictionary blocks to be used. CO re size (in pages) block size (In pages) ^8
1
^50
2
^100
4
s p e c i fi e s t h a t t h e s o u r c e p r o g r a m I s t o b e 1 I s t e d o n S P R I N T.
3.05 PL/I
specifies ttiat th-e Input to the conptle'* time processor is to be listed.
specifies that extra code is to be produced to allow diagnostic messages printed during the execution time to contain statement numbers s p e c i fi e s t h a t c r o s s r e f e r e n c e s o f e a c h i d e n t i fi e r a r e t o b e l i s t e d .
The logical I/O units used by the PL/l-F compiler are as ro11ows: U n i t
Default record format
SCARDS SPRINT SPUNCH
U(IOO) U(129, 121) F(80) F(80)
0
Principal
Functions
source input
listing output object deck and macro deck
object module output
-SYSUT^
auxiliary
scratch
fi l e
for compile-time processor Batch compilation
Th e MTS PL /1 co mp i l e r c a
lThis u - is^IS achieved pachieved r o c e s sby mpreceding o r e t h athe n second o n e e(and xtern al cedure. This each n t ) ccompilation o m p i l a t i o n by b y aa c o n t r o l r e c o r d o f t h e f o r m : subsequent) % PROCESS('option list')
Tine h e Tirst fi r s t p position o s i t i o n must m u s t have have r
pro
a percent sign C^). There may
e lanks between the percent sign and the keyword PROCESS. _
I
«
•
.
PRnrpq^' should no blanks embedded between of thetheP op of PROCESS and thebe sem,co1 on. There is no carry-over tions used previously. If the user does not wish to specify any opt"ons, he should place the semicolon right after the
achTeved^ Following shows how batch compilation is $RUN >vpLi o = A PAR=LOAD ,NODECK [source program one ]
EPROCESS('LOAD,NOEXTREF,ATR') ; [source program two 1
EPROCESS; [source program three!
$ENDFILE
$RUN A+*PL1LIB
■'
^.01 PL/I
E X E C U T I O N T I M E C O N S I D E R AT I O N S
Running a PL/1 program
It Is an absolute necessity that the main program be written In PL/1. Otherwise, one may be greeted with the message
"IHEOO6I NO MAIN PROCEDURE". Running nothing with *PL1LIB will also produce the same message. A simple program may be run by specifying: $RUN MYPR0GRAM+*PL1LIB
Since stream I/O routines In PL/1 process character by char acter (rather than record by record), extra information describing record format and length may be needed. The following record formats are supported:
u[£]
(max-b1ocksIze)
(max-blocksize, max-recordsize)
F[B][fJ] (blocksi ze , records I ze) stands
for
u n d e fi n e d
format
records.
The
maximum blocksize Is the largest length that a
record
can
have.
stands for variable length records. The f o l l o w i n g fi g u r e I l l u s t r a t e s V - f o r m a t . ( u n b l o c k e d V- f o r m a t )
d a t a d a t a
d a t a
d a t a
( b l o c k e d V- f o r m a t ) w h e r e
d a t a
consists of data bytes, not less than 10 In
number
r e c o r d c o n t r o l fi e l d ( A b y t e s l o n g ) d e s c r i b e s the length of the record Including the record cont
ro1
fi e l d .
b l o c k c o n t r o l fi e l d ( A b y t e s ) s p e c i fi e s t h e overall block
length control
of
the
fi e l d .
block
Including
the
^.02 PL/I
The blocksize must be greater than or equal to record length plus
four. stands
for
fi x e d
records.
These
records
can be blocked together. The blocksize must be an integral multiple of the re cord
B
says
that
size.
records format
A
sets
the
CC
may
records
bit
on.
be
cannot
It
blocked. be
is
U-
blocked.
used
primarily
for printer and punch control characters
w h i c h a r e p l a c e d i n t h e fi r s t p o s i t i o n of data bytes . M
sets
the
MCC
bit
on.
I f A o r M i s n o t e x p l i c i t l y o r i m p l i c i t l y s p e c i fi e d a N O C C b i t w i l l b e s e t . S t a n d a r d P L / 1 fi l e s h a v e t h e f o l l o w i n g d e f a u I t s : PL/1
Print All
fi l e n a m e
fi l e s
such
Record
as
others
SPRINT
Format
VA ( 1 2 9 , 1 2 5 ) U(80)
R e c o r d f o r m a t s , c a n b e s p e c i fi e d b y i n s e r t i n g t h e s e i n PA R = 1. $RUN C0PY+*PL1LIB
PA R = S C A R D S = * S O U R C E ^ @ F
2. $RUN FMAINT+*PL1LIB
PAR=INTER=*TAPE*@F(2^00,600) MASTER=*OLDMAS*@U(132)
EXCEPTIONFILE=-E@U(300) SCARDS=*S0URCE*@F(80) 3.
conversational
$RUN BLDLIN #EXECUTI0N BEGINS SYSPRINT - SPECIFY FDNAME OR SEND END-OF-FILE
*SINK*@VA(U1 ,137) INTER - SPECIFY FDNAME OR SEND END-OF-FILE
*INTER*@FB(2400,600) L AY F I L E - S P E C I F Y F D N A M E O R S E N D E N D - O F - F I L E
- L AY F I L E @ F ( 1 7 6 ) / ' E X E C U T I O N T E R M I N AT E D
Filenames are automatically truncated to 8-characters. Also environment options can be extracted to default record format
4.03 PL/I
4. Passing parameter strings
$RUN
PA R + * P L 1 L L B *SINK*;ABC
PA R = S P R I N T ^
PAR; PROCCSTR) OPT(DNS (MAINl ; DCL(STR,PARSTR} CHAR(255)
VA R ;
I = INDEX(STR,' ;
IF l=0|i=LENGTH(STR) T H E N PA R S T R = ' ' ; E L S E
PAR=SUBSTR(STR,1 + 1) ; PUT DATA (PARSTR) ; E N D PA R ;
How to get a dump
In most cases, a single diagnostic message suffices and a
dump is rather useless and expensive. Hence PL/1 library rou
tines do not abend (except in catastrophic cases such as "IHE0041-INTERRUPT IN ERROR HANDLER") but return MTS with the
code set in the register 15. If a PL/1 user prefers to have a dump, he may insert a simple statement (or the like) in his p
rog
ram:
ON ERROR CALL IHEDUMP ;
This routine IHEDUMP prints useful information. The output is on the file PLIDUMP with the default "PL1DUMP=*SINK*".
The information consists of;
1) SPRINT buffer and intermediate buffers, if any
2) Files currently open 3 ) C u r r e n t fi l e i n u s e 4) Save areas
5) On -units, interrupts and other details
The routine IHEDUMP then calls on ERROR to dump everything if any $ERRORDUMP was previously encountered.
l^.ok PL/I
N ame : C o n t e n t s :
^PLILIB
The subroutine library for PL/1-compi1ed programs. * P L 1 L I B i s c o n c a t e n a t e d t o t h e fi l e c o n t a i n i n g
the object modules resulting from a PL/1 compilation in a $RUN command. $RUN
OBJECT+^PLlLiB
*PL1LIB contains the object modules of subroutines
which may be invoked by PL/1 compiled code. it is formatted as a library and hence only those object modules
which
are
referenced
pre
loaded.
1
5.01 P L / I
PL/1 SUBROUTINES
The following subroutines are intended to be called
« directly from PL/.I p rog rams .
i
Name:
Purpose:
B AT C H
To
determine
whether
ational
Declaration:
DECLARE
in
batch
or
convers
mode.
B AT C H
ENTRY
RETURNS(BIT(1)); Description; Example:
IF
Returns
'I'B
B AT C H
if
in
THEN
batch
mode;
otherwise
'O'B
STOP;
E L S E G O T O R E T R Y;
Name:
Purpose:
CPUTIME
To
obtain
in
seconds
the
CPU
time
since
the
start of the current program. Declaration:
DECLARE
CPUTIME
ENTRY
RETURNS (FLOAT BINARY) ; D e s c r i p t i o n : R e t u r n s t h e fl o a t i n g - p o i n t v a l u e i n s e c o n d s since the start of the program. Example:
S TA RT
TIME:
PROC;
DCL (TIMEl, TIME2) STATIC FLOAT BIN, CPUTIME ENTRY RETURNS (FLOAT BIN); TIME2 = CPUTIME; RETURN ;
T I M E : E N T R Y F L O AT B I N ; TIMEl = TIME2; TIME2 = CPUTIME;
RETURN (TlME2 - TlMEl); END ;
5 . 0 2
PL/I
Name:
ELAPSED
P u r p o s e : To o b t a i n i n s e c o n d s t h e e l a p s e d t i m e s i n c e the Declaration:
DECLARE
start
of
the
ELAPSED
program.
ENTRY
RETURNS (FLOAT BINARY);
D e s c r i p t i o n : R e t u r n s t h e fl o a t i n g - p o i n t v a l u e i n s e c o n d s ^ since
the
start
of
the
program.
'
Examp1e:
PUT EDIT ('ELAPSED TIME - ELAPSED, ' SECS') (A, F(15,3), A);
•i
5 . 0 3 PL/ 1
♦
Name :
IHEREAD, IHERITE
Pu rpose :
Allow PL/1 user to gain nearly complete control o v e r I / O , e s p e c i a l l y l i n e fi l e s .
De c 1 a rat i on :
DCL (IHEREAD,IHERITE) ENTRY ( /* character string preferably varying »/, B I T ( 3 2 ) , / * a 3 2 - b i t m o d i fi e r * / DEC FIXED (9,3), /* a line number in the
s
range from -99999.999 99999.999^/
to
F I L E / * fi l e n a m e * / ) ; Des cr i pt i on :
1 . T h e fi l e , i f i t i s t o b e u s e d b y I H E R E A D o r I H E R I T E , m u s t b e a r e c o r d fi l e w i t h u n d e fi n e d format
2.
It
or
will
mixes
unblocked
be
the
these
REWRITE
fi x e d
user's
format.
responsibility
subroutines
with
READ,
if
he
WRITE
or
statements.
3 . A n o u t p u t fi l e c a n n o t b e u s e d f o r I H E R E A D , n o r a n i n p u t fi l e f o r I H E R I T E . A n u p d a t e fi l e
A.
can
r
used
both
for
IHEREAD
and
IHERITE.
I f t h e i n d e x e d b i t o f a m o d i fi e r i s o n , a l i n e number must be provided. Otherwise, a data interruption may likely occur or some unpred ictable results will come up. In addition, in case of IHEREAD, the character string will be come a null fetring when there is no line as sociated
Examp1es :
be
with
the
line
number.
MAIN: PROCEDURE OPT 1ONS(MA 1N) ; DCL (IHEREAD,IHERITE) ENTRY (,BIT(32), DEC FIXED(9,3) ,FILE) , BUFFER CHAR(121)VARYING, MOD BIT(32) INIT ((32) 'O'B) , LINENR DEC FIXED (9,3), NUTS FILE; ON ENDFILE (NUTS) GO TO FINSH; OVER: CALL 1 HE READ(BUFFER,MOD,L1NENR,NUTS) ; PUT SKIP LIST (LINENR, BUFFER); GO TO OVER; /*THE ABOVE ACTS L1KE A "$LIS" COMMAND COMMAND*/
e
F I N I S H :
CLOSE FILE(NUTS); OPEN FILE(NUTS) UPDATE; SUBSTR(M0D,31) = 'I'B; /* TURN INDEXED BIT ON */ CALL IHERITE (' ' , MOD , 1 .0 , NUTS) ; /* DELETE LINE #1 */ CALL IHERITE (' THIS IS LINE #2.5', MOD, 2.5,NUTS); /* 1NSERT THE LINE #2.5 */ RETURN ; END MAIN;
5.04 PL/I
PL!ADR
To o b t a i n a p o i n t e r t o P L l s c a l a r c o n s t a n t s and Decla rat i on :
variables.
DECLARE PLIADR RETURNS(POINTER) ;
C a 11 I n g S e q u e n c e PLlADR(ARG)
ARG-any scalar constant or variable (not strings, arrays, or structures). R e s u 11 :
The
value
argument.
of
PLIADR
is
the
address
of
the
5 . 0 5
PL/I
Names:
PLCALL,
PLCALLD,
PLCALLE,
PLCALLF
P u r p o s e : To e n a b l e t h e c a l l i n g o f n o n - P L l C F O R T R A N a n d
assembler) procedures which require a standard S type linkage from PLl programs.
D e c l a r a t i o n s : D E C L A R E P L C A L L D R E T U R N S ( F L O AT, 1 6 ) ; DECLARE PLCALLE RETURNS (FLOAT, 6); D E C L A R E P L C A L L F R E T U R N S ( F I X E D B I N A RY ( 3 l ) ) ; Call Ing Seq uence:
CALL CALL CALL CALL Arguments:
FN
a
PLCALL(FN, N, PL) ; PLCALLD(FND, N, PL) ; PLCALLE(FNE , N, PL) ; PLCALLF(FNF, N, PL) ;
subroutine which has been declared to the ENTRY attribute and which does not a
FND
have return
va1ue.
a function which has been declared to the ENTRY attribute and which returns
have a double
p r e c i s i o n fl o a t i n g p o i n t v a l u e ( R E A L M S i n F O R T R A N ; l o n g fl o a t i n g r e g i s t e r 0 i n a s s e m b l y code). FNE
a
function
which
has
been
declared
to
have
the
ENTRY attribute and which returns a single pre
c i s i o n fl o a t i n g p o i n t v a l u e { R E A l * k i n F O R T R A N ; s h o r t fl o a t i n g r e g i s t e r 0 i n a s s e m b l y c o d e ) . FNF
a
function
which
has
been
declared
to
have
the
ENTRY attribute and which returns an integer
value (INTEGER*^ in FORTRAN; general register 0 in assembly code). N a number with attributes FIXED BINARYOD which is equal to the number of arguments
b e i n g p a s s e d t o F N , F N D , F N E , o r F N F. N may be 0.
PL a parameter list of the N arguments to be passed to FN, FND, FNE, or FNF in the order required
by the subprogram. The arguments are separated '
the
name
of
the
by commas. If the argument is a string var iable, array variable, or structure variable, argument or a pointer to the argument may be used; for example, ARC or
ADDR(ARG). If the argument is a scalar variable, a pointer to the argument must be used; for
example, ADDR(ARG). If the argument is a scalar constant, a pointer to the argument must be used
which can be produced by PLIADR, which see. If N = 0, there is no parameter list and no comma after
N.
5.06 PL/1
Res
u1ts
Return
:
The values of PLCALLD, PLCALLE, and PLCALLF are the values returned by FND, FNE, and FNF r e s p e c t I v e 1 y.
Code:
The return code placed in general register 15 by FN, FND, FNE, or FNF may be interrogated using
Examp1es:
PLIRC,
which
see.
/* ARSIN AND DARCOS ARE FORTRAN LIBRARY FUNCTIONS */
D E C L A R E P L C A L L E R E T U R N S ( F L O AT ( 6 ) ) ;
DECLARE PLCALLD RETURNS(FLOAT(16)); DECLARE (ARSIN, DARCOS) ENTRY; DECLARE (ARSIN, ANGLE) FL0AT(6); (ARCCOS, DANGLE) FL0AT(l6); D E C L A R E F 1 F I X E D B I N A R Y ( 3 1 ) I N I T ( l ) S TAT I C ;
ARCSIN = PLCALLE(ARSIN, Fl, ADDR(ANGLE) ) ; ARCCOS=PLCALLD(DARCOS, Fl, ADDR(DANGLE)); D E C L A R E D I S M N T E N T R Y; D E C L A R E 1 PA R A L I G N E D S TAT I C ,
2 LEN BIT(16),
2 TA P E C H A R ( 3 ) I N I T ( ' * T * ' ) ; LEN=BIN(3, 16, O) ; CALL PLCALL(DISMNT, Fl, PAR);
f
5.07 PL/1
PLl
N ame :
RC
To i n t e r r o g a t e t h e r e t u r n c o d e p a s s e d b a c k
by the last call on PLCALL, PLCALLD, PLCALLE, or PLCALLF or set by IHESARC.
DECLARE PLIRC RETURNS (F I XED BINARYOD);
Dec 1arat i ons :
C a 11 i n g S e q u e n c e : PLl
RC
The value of PLIRC Is the contents of general
Res u 1 t
register 15 when the procedure called using PLCALL, PLCALLD, PLCALLE, or PLCALLF returns; or the value set by IHESARC whichever is most recent. For FORTRAN subroutines, the value
returned in general register 15 is ^ times the value of the integer after RETURN IF PLrRC-4 THEN GO TO ERROR;
E xamp1e:
Name
:
RAN
D
Purpose: To compute random numbers between 0.0 and 1.0. Decla rat i on:
DECLARE RAND ENTRY
(FIXED BINARY (31)) RETURNS (FLOAT BINARY); Des c r i pt i on:
The argument I as in RAND(l) must be a variable initialized within the range (1,2 -2). The value returned by RAND(l) is between
T
0.0
and
1.0.
In
addition,
the
variable
is changed so that a different random number is
f
Examp1e:
generated.
R A N D O M : P R O C F L O AT B I N ;
D C L I F I X E D B I N ( 3 1 ) S TAT I C INIT (52A287) RAND ENTRY (FIXED BIN (31)) RETURNS (FLOAT BIN) ; RETURN (RAND ( I ) ) ; END ;
I \
5.08 P L / l
N ame :
S 1 GNOFF
P u rpose:
To s i g n o f f
Declarat
i
on
;
Des c r i p t i on :
D E C L A R E S I G N O F F E N T R Y;
C l o s e s a l l o p e n fi l e s , i f a n y , a n d t h e n
it
signs the user off E xamp1e :
I F B AT C H C A L L S t G N O F F ;
N ame :
USERID
Purpose:
To
Decla rat i on:
DECLARE USERID ENTRY
obtain
the
current
four
character
userid
RETURNS (CHARACTER (A) ) ; Des or i pt i on:
Return
Examp1e:
PUT LIST (USERID) ;
the
userid
V
%
/