0% found this document useful (0 votes)
92 views12 pages

PL/I Module 1

PL/I Module 1

Uploaded by

ArvindUpadhyay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views12 pages

PL/I Module 1

PL/I Module 1

Uploaded by

ArvindUpadhyay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 12

BASIC PL/1 INTRODUCING PL/1

Module 01 Page 0 of 10
BASIC PL/1 INTRODUCING PL/1
MODULE 01
INTRODUCING PL/1
Module 01 Page 1 of 10
BASIC PL/1 INTRODUCING PL/1
THE COMPILATION PROCESS
The job of a programmer is to code programs! The program will be
typed into a sequential fle using TSO/SPIFFY. In order to get that
program to "run", to do the job it was designed to do, it has to undergo a
certain process.
Compilation: The source program as coded by the programmer is read
by the PL/1 compiler. The compiler checks the coding to ensure that it is
syntactically correct, e.g. no commas missing, and when it is satisfed
that the program is valid, it translates the statements in the program into
machine code - executable instructions. This is called an Object Module.
These instructions are not yet ready to execute. They have to be
processed by the Linkage Editor.
Linkage Editing: The object module is read by the linkage editor,
which looks at the JCL, (Job Control Language), to see if other
object modules will be required to make the program run. These
might be other modules which have been written and compiled by
other programmers as part of the our program or they may just be
standard modules that every PL/1 program requires. The Linkage
Editor gathers all these modules together into one single unit called
a Load Module.
Execution: The Load Module produced by the Linkage Editor is a
ready-to-run program. When it is time for the program to be run,
the Load Module is brought into main storage and executed. All
fles that it requires must of course be made available to it at this
stage: they have to be specifed in the JCL.
This course deals with the coding of the statements that are read
by the compiler in the frst of these stages.You will have separate
courses on:
The use of TSO/SPIFFY
Job Control Language
Module 01 Page 2 of 10
BASIC PL/1 INTRODUCING PL/1
PL/1 CODING
We code a PL/1 program following a certain set of rules. These are
applied when we code directly onto the screen using TSO. These
rules cover:
What characters we can use in our program
How we create names of things to which we need to refer in our
program
How we lay out our coding on the sheet or screen to make it easier
for other people to follow
How we add comments to our program to describe what it is
setting out to do
In the frst Unit of this course we'll be looking at some of these
basic rules, and then as we go through the course, and learn new
features, we'll apply the rules we learnt at this stage.
Module 01 Page 3 of 10
BASIC PL/1 INTRODUCING PL/1
CHARACTERS IN PL/1 PROGRAMS
As we code our program, there is a certain set of characters we can
use. They are:
Numeric Digits 0123456789
Alphabetic Characters ABCDEFGHUKLMNOPQRSTUVWXYZ
Special Alphabetics # @
Space
Special Characters + - / * & | = ( ) , . ; : ' % _ ? < >

Each of the above special characters has a purpose in PL/1,
except the ?, and we'll learn them as we go through the course.
Note that these are the characters we use to code our programs-
they are not the only characters that can be in the data that the
program will process.
Module 01 Page 4 of 10
BASIC PL/1 INTRODUCING PL/1
PL/1 IDENTIFIERS
We have various things in out programs to which we give names.
Specifcally:
Variables
Files
Procedures (parts of the program)
Using only some of the PL/1 character set, we can compose names
according to the following rules:
Internal Names
Internal names are names known only inside our program, and so
we have only the PL/1 constraint.
Maximum Length: 31 characters
First Character: A to Z, #, @,
Other Characters: A to Z #, ,@ 0 to 9, _
External Names
External names are names which are known not only inside our
program but also to MVS and its various components. These
names have a further set of limitations imposed by MVS.
Maximum Length: 7 characters
First Character: A to Z
Other Characters: A to Z and 0 to 9
Module 01 Page 5 of 10
BASIC PL/1 INTRODUCING PL/1
Valid Internal Names
A_FLIGHT
GROSS
NOT_ANOTHER_PERISHING_NAME
Valid External Names
RJEFILE
RECLINK
OUTPTR
Invalid Internal Names
A FLIGHT (SPACE NOT ALLOWED)
&GROSS (& NOT ALLOWED)
NOT_ANOTHER_PERISHING_NAME_TO_SHOW_THE_RULES
(TOO LONG)
Invalid External Names
RJE_FIL (_ NOT ALLOWED)
RJELFILE (TOO LONG)
Module 01 Page 6 of 10
BASIC PL/1 INTRODUCING PL/1
PL/1 STATEMENTS
A PL/1 Program is composed of a series of statements.
Each statement must end with a semicolon (;).
PL/1 always looks at the frst "word" of a statement to decide upon
the type of statement, if a statement starts "READ" then its
probably a READ statement!
Our learning of PL/1 will consist of learning more and more
statements and their use. Statements divide into two basic types:
Executable statements, which are a command to do something.
Declarative statements, which simply describe something in our
program.
Statement labels
PL/1 gives us the facility to label a statement in our program. We
do this by giving it a name. The name is coded in front of the
statement, and separated from it by a colon, e.g.
START: STATEMENT;
Here the statement has been labelled 'START'.
Note: On-Tyne standards do not allow the use of labels on any
statements other than the end of procedure and end of program
statements.
Module 01 Page 7 of 10
BASIC PL/1 INTRODUCING PL/1
A COMPLETE PL/1 PROGRAM
JR117: PROC OPTIONS(MAIN);
DECLARE PXF FILE INPUT RECORD;
DECLARE 1 PXF_REC,
R_T!PE CHAR(1),
A_C_COUNT FIXED DEC (),
A_C_CAP! FIXED DEC (),
SER"_DATE CHAR(#);
DECLARE PLANE_COUNT FIXED DEC ($);
OPEN FILE (PXF);
READ FILE (PXF) INTO (PXF_REC);
DO WHILE(R_T!PE % &A&);
PLANE_COUNT % PLANE_COUNT '
A_C_COUNT;
READ FILE(PXF) INTO(PXF_REC);
END ;
END JR117;
In this coding there are 11 statements (because there are 11 semicolons).
Each statement has been coded on a line by itself, and the amount by which it
has been indented is used to describe its function and place. As far as PL/1 is
concerned, there are no lines, no margins. PL/1 simply reads from the frst
character in the frst line down to the last character in the last line, and that is
the program. The coding above could have been re-written as:
JR117: PROC OPTIONS(MAIN); DECLARE
PXF FILE INPUT RECORD; DECLARE 1 PXF_REC,
R_T!PE CHAR(1), A_C_COUNT
FIXED DEC () A_C_CAP!
FIXED DEC (), SER"_DATE CHAR(#);
DECLARE PLANE_COUNT FIXED DEC ($);OPEN FILE
(PXF); READ FILE (PXF) INTO (PXF_REC); DO
WHILE(R_T!PE % &A&); PLANE_COUNT % PLANE_COUNT
' A_C_COUNT; READ FILE(PXF) INTO(PXF_REC);
END ; END JR117;
but would have been almost unreadable if it had. So we must use
this "free-form" capability to code our program in such a way that it
is easy to read and its function is clear.
Module 01 Page 8 of 10
BASIC PL/1 INTRODUCING PL/1
COMMENTS
We can insert into our program "comments". These have no efect
on what the program does, but if another programmer comes to
look at our coding (or even if we look at it ourselves after a break of
a few weeks) then comments help to make it clear what the
program is setting out to do.
Comments can contain anything we want, except the pair of
characters */ together. A comment starts with /* and fnishes with
*/. So a comment in our program might look like:
()))))))))))))))))))))))))))))))))))))))))))))))(
() ON*T!NE STANDARDS STATE THAT COMMENTS
SHOULD)( () +E WRITTEN AS COMMENT +OXES, THE! MUST
)( () APPEAR ON A NEW LINE FROM CODE,
)(
()))))))))))))))))))))))))))))))))))))))))))))))(
The compiler would ignore that, but it would be useful and
informative to anyone reading the program. As a general rule, we'll
try to comment every main section of the program as well as any
particularly difcult bits of logic. But in any case we must always
insert a standard block of comments at the start of the program,
before any coding, as has been done in this case:
()))))))))))))))))))))))))))))))))))))))))))))))))(
() JR117 * SCHEDULE TO SER"ICE )(
() )(
() RE"ISION HISTOR! )(
() )(
() "ERSION DATE CHANGED APPRO"ED REASON( )(
() +! +! REFERENCE )(
() )(
() 1,1 DDMMM!! NAME NAME (REASON) )(
() )(
() 1,- DDMMM!! NAME NAME (REASON) )(
() )(
() DESCRIPTION: )(
() DESCRIPTION OF PROCESS,,,,,,,, )(
() )(
Module 01 Page 9 of 10
BASIC PL/1 INTRODUCING PL/1
()))))))))))))))))))))))))))))))))))))))))))))))))(
Module 01 Page 10 of 10
BASIC PL/1 INTRODUCING PL/1
PROCEDURE AND END STATEMENTS
Two statements from the above example stand out as being
particularly important.
The PROCEDURE statement
We must always have one of these as the frst PL/1 statement in
our program. It has the form:
PGMNAME: PROCEDURE OPTIONS (MAIN);
where PGMNAME is an EXTERNAL name that we make up.
(remember the rules for EXTERNAL names). PROCEDURE is one
of the PL/1 keywords, and may be abbreviated to PROC. The
PROC statement tells PL/1 the name of the program, and that this
is the frst statement in it. It is ended of course by a semicolon.
The END statement
This correspondingly marks the end of our program. The basic
format is quite Simple:
END;
but when we use it to mark the end of a procedure, then we code
the procedure name on the END statement, to identify to PL/1 that
this is the end of the procedure.
END JR117;
We will see several further uses for the END statement as the
course progresses, and so it becomes important to show what this
particular END is doing.
Module 01 Page 11 of 10

You might also like