Академический Документы
Профессиональный Документы
Культура Документы
A Series ALGOL
Student Guide
Volume 1
Printed in US America
EL2015 SG 2015 R3
Student Guide
Volume 1
Unisys Proprietary
Printed in U S America
EL2015 SG 2015 R3
ClearPath HMP NX and A Series ALGOL
NO WARRANTIES OF ANY NATURE ARE EXTENDED BY THIS DOCUMENT.
Any product or related information described herein is only furnished pursuant
and subject to the terms and conditions of a duly executed agreement to
purchase or lease equipment or to license software. The only warranties made
by Unisys, if any, with respect to the products described in this document are
set forth in such agreement. Unisys cannot accept any financial or other
responsibility that may be the result of your use of the information in this
document or software material, including direct, special, or consequential
damages.
You should be very careful to ensure that the use of this information and/or
software material complies with the laws, rules, and regulations of the
jurisdictions with respect to which it is used.
SG 2015 R3
0–3
Page Status
Page Issue
i to xxii Original Front Matter
11 to 122 Original Section 1
21 to 210 Original Section 2
31 to 314 Original Section 3
41 to 414 Original Section 4
51 to 520 Original Section 5
61 to 620 Original Section 6
71 to 716 Original Section 7
81 to 832 Original Section 8
91 to 930 Original Section 9
101 to 10 Original Section 10
36
SG 2015 R3 iii
SG 2015 R3 iv
Contents
Purpose ....................................................................................
xvii
How to Use This Document ...................................................
xvii
Overview ..................................................................................
xvii
Organization ............................................................................
xviii
Software ...................................................................
xx
Reference Product Information .............................................
xx
Agenda .....................................................................................
xxi
Objectives ................................................................................
1–1
Benefit Statement ....................................................................
1–1
Materials / Reference ..............................................................
1–1
History ......................................................................................
1–3
Basic Elements ........................................................................
1–4
Statements ...............................................................
1–5
Declarations .............................................................
1–6
Identifiers and Reserved Words ...............................
1–7
Documentation .........................................................
1–8
SG 2015 R3 v
Arithmetic Expressions ..........................................................
1–9
Arithmetic Assignment Statements ..........................
1–10
Order of Precedence ................................................
1–11
Assignments in Expressions ....................................
1–12
Integers and Reals ...................................................
1–13
Program Input/Output .............................................................
1–14
The Remote File ......................................................
1–14
Declaring a File ........................................................
1–15
The Free-Format WRITE Statement .......................
1–16
The Free-Format READ Statement .........................
1–17
Messages to the User ..............................................
1–18
Application Example ...............................................................
1–19
Review Exercise 1 ...................................................................
1–20
Laboratory Exercise 1 .............................................................
1–21
Objectives ................................................................................
2–1
Benefit Statement ....................................................................
2–1
Materials / Reference ..............................................................
2–1
Program Modules ....................................................................
2–3
Procedure Declarations ..........................................................
2–4
Procedure Invocation ...............................................
2–5
Procedure Blocks and Rules of Scope .....................
2–6
Application Example ...............................................................
2–9
Laboratory Exercise 2 .............................................................
2–10
SG 2015 R3 vi
About This Course
Objectives ................................................................................
3–1
Benefit Statement ....................................................................
3–1
Materials / Reference ..............................................................
3–1
Boolean Expressions ..............................................................
3–3
Arithmetic Relation ...................................................
3–3
The IF Statement .....................................................................
3–4
Boolean Variables ...................................................................
3–5
Boolean Operators ...................................................
3–6
Nested and Chained IF Statements .........................
3–7
The Boolean READ and WRITE .............................................
3–9
Application Example ...............................................................
3–10
Review Exercise 3 ...................................................................
3–12
Laboratory Exercise 3 .............................................................
3–13
Objectives ................................................................................
4–1
Benefit Statement ....................................................................
4–1
Materials / Reference ..............................................................
4–1
CASE vs. Chained IF ...............................................................
4–3
Implicitly Numbered CASE ......................................
4–5
Labels and GO TO ...................................................................
4–6
Declaring and Placing Labels ...................................
4–6
Label Locations ........................................................
4–7
End-of-File Action Label ...........................................
4–9
Application Example ...............................................................
4–10
SG 2015 R3 vii
About This Course
Objectives ................................................................................
5–1
Benefit Statement ....................................................................
5–1
Materials / Reference ..............................................................
5–1
Efficient Iteration .....................................................................
5–3
WHILE .......................................................................................
5–4
DO .............................................................................................
5–6
FOR ...........................................................................................
5–8
Arithmetic Expression Lists ......................................
5–9
The STEP ................................................................
5–10
WHILE in the FOR ...................................................
5–12
THRU ........................................................................................
5–14
Application Example ...............................................................
5–15
Review Exercise 5 ...................................................................
5–19
Laboratory Exercise 5 .............................................................
5–20
Section 6. Arrays
Objectives ................................................................................
6–1
Benefit Statement ....................................................................
6–1
Materials / Reference ..............................................................
6–1
The REAL Array .......................................................................
6–3
Array Word Value Assignments ................................
6–4
Two-Dimensional Arrays ..........................................
6–5
Other Word Arrays ...................................................
6–7
viii SG 2015 R3
About This Course
Objectives ................................................................................
7–1
Benefit Statement ....................................................................
7–1
Materials / Reference ..............................................................
7–1
EBCDIC Arrays ........................................................................
7–3
Comparing Character Values ...................................
7–4
EBCDIC Characters .................................................
7–5
EBCDIC Array Row READ .......................................................
7–6
REPLACE .................................................................................
7–7
Array Row WRITE ....................................................
7–8
Converting Numbers to Characters ..........................
7–9
Application Example ...............................................................
7–10
Review Exercise 7 ...................................................................
7–13
Laboratory Exercise 7 .............................................................
7–14
SG 2015 R3 ix
About This Course
Objectives ................................................................................
8–1
Benefit Statement ....................................................................
8–1
Materials / Reference ..............................................................
8–1
The POINTER ..........................................................................
8–3
The Uplevel Pointer .................................................
8–4
Pointer Assignment Variations .................................
8–4
Pointer Expressions .................................................
8–5
SCAN ........................................................................................
8–6
The Residual Counter ..............................................
8–8
The Update Pointer ..................................................
8–10
More REPLACE Options .........................................................
8–12
Truthset Conditions ..................................................
8–13
Multiple Sources ......................................................
8–14
Pointer Location ......................................................................
8–15
OFFSET ...................................................................
8–15
REMAININGCHARS ................................................
8–16
DELTA ......................................................................
8–17
Character Conversion to Numbers ........................................
8–18
The INTEGER Function ...........................................
8–18
The REAL Function ..................................................
8–20
The DECIMAL Function ...........................................
8–21
Referencing Mixed Data .........................................................
8–22
The Array Reference ................................................
8–23
Pointers with Word Arrays ........................................
8–24
x SG 2015 R3
About This Course
Objectives ................................................................................
9–1
Benefit Statement ....................................................................
9–1
Materials / Reference ..............................................................
9–1
Procedure Parameters ............................................................
9–3
Parameter Declaration .............................................
9–3
Word Parameters .....................................................
9–4
Actual Parameters ...................................................
9–5
Call-by-Name ...........................................................
9–6
Thunks .....................................................................
9–7
Call-by-Value ............................................................
9–8
Array Parameters .....................................................................
9–9
RESIZE ....................................................................
9–10
POINTER Parameters .............................................
9–11
OWN Declarations ...................................................
9–12
Functions .................................................................................
9–13
BOOLEAN Procedures ............................................
9–14
INTEGER Procedures ..............................................
9–16
REAL Procedures .....................................................
9–18
System Intrinsic Functions .......................................
9–19
Application Example ...............................................................
9–21
SG 2015 R3 xi
About This Course
Objectives ................................................................................
10–1
Benefit Statement ....................................................................
10–1
Materials / Reference ..............................................................
10–1
A Series Word Organization ...................................................
10–3
The REAL ................................................................
10–4
Partial Word Notation ...............................................
10–5
Partial Word Assignment and Evaluation .................
10–6
Bits of TIME .............................................................
10–8
Type Conversion ......................................................
10–10
Bit Concatenation .....................................................
10–11
Word Operations .....................................................................
10–13
IS or ISNT ................................................................
10–15
The MASKSEARCH Function ..................................
10–16
Character Types .......................................................
10–18
Character Search .....................................................
10–19
Bit Rotation ..............................................................
10–20
Bit Functions ............................................................
10–22
The DEFINE .............................................................................
10–23
Statements in DEFINEs ...........................................
10–24
Parametric DEFINEs ................................................
10–25
Application Example ...............................................................
10–27
Review Exercise 10 .................................................................
10–34
xii SG 2015 R3
About This Course
Volume 2
Objectives ................................................................................
11–1
Benefit Statement ....................................................................
11–1
Materials / Reference ..............................................................
11–1
The Library System .................................................................
11–3
Parameters ..............................................................
11–4
Library Structure .....................................................................
11–5
$SHARING ...............................................................
11–6
FREEZE ...................................................................
11–7
Example Library Program ...............................
11–8
The Client Program Library Declaration ...................
11–9
Library Procedure Declaration .................................
11–11
Parameter Matching with COBOL and C .................
11–12
COMS Processing Item Libraries ..........................................
11–14
Parameter Usage .....................................................
11–15
The REAL Array .......................................................
11–15
The EBCDIC Arrays .........................................
11–16
The Procedure Parameter ...............................
11–16
Procedure Assignment .............................................
11–16
Data for Export ........................................................................
11–18
Connection Libraries ..............................................................
11–20
Declarations .............................................................
11–20
SG 2015 R3 xiii
About This Course
Operations ................................................................
11–22
LINKLIBRARY .................................................
11–22
Connection Matching and Resources ..............
11–24
Procedure Invocation ......................................
11–25
Procedure Types ......................................................
11–26
The PENDING Declaration ..............................
11–27
APPROVAL Procedure ....................................
11–28
CHANGE Procedure ........................................
11–30
Breaking Links ..........................................................
11–32
STATE Library Attribute ............................................
11–33
THISCL Function .............................................
11–33
Connection Block Data Exchange ............................
11–34
Composite Libraries .................................................
11–34
Application Example ...............................................................
11–35
Review Exercise 11 .................................................................
11–37
Laboratory Exercise 11 ...........................................................
11–39
Objectives ................................................................................
12–1
Benefit Statement ....................................................................
12–1
Materials / Reference ..............................................................
12–1
The Task ...................................................................................
12–3
The Task Variable .....................................................
12–4
Task Initiation ..........................................................................
12–6
External Procedures .................................................
12–8
CALL Tasks ..............................................................
12–10
xiv SG 2015 R3
About This Course
SG 2015 R3 xv
About This Course
Objectives ................................................................................
13–1
Benefit Statement ....................................................................
13–1
Materials / Reference ..............................................................
13–1
Process Control ......................................................................
13–3
EVENT Variables ......................................................
13–4
PROCURE and LIBERATE ......................................
13–5
FIX and FREE ..........................................................
13–7
CAUSE, WAIT and RESET ......................................
13–8
The INTERLOCK .....................................................
13–10
LOCKSTATUS .................................................
13–11
The EXCEPTIONEVENT ..........................................................
13–12
HI .............................................................................
13–13
Connection Library Events .......................................
13–14
Multiple WAIT Conditions .........................................
13–17
INTERRUPT Procedures .........................................................
13–18
EPILOG and EXCEPTION Procedures ....................
13–20
Connection Block EPILOG ..............................
13–22
PROLOG Procedures ..............................................
13–23
Events for EXPORT .................................................
13–24
Prolog, Epilog, Global Event ....................................
13–25
Application Example ...............................................................
13–27
Review Exercise 13 .................................................................
13–30
Laboratory Exercise 13 ...........................................................
13–32
Optional: ..........................................................
13–34
xvi SG 2015 R3
About This Course
Objectives ................................................................................
14–1
Benefit Statement ....................................................................
14–1
Materials / Reference ..............................................................
14–1
Avoiding DS .............................................................................
14–3
TRY Alternatives ......................................................
14–4
The ON Statement ...................................................
14–6
Program Dumps ......................................................................
14–9
OPTION Options ......................................................
14–13
PROGRAMDUMP ....................................................
14–14
Task History ..............................................................
14–15
Recovery ..................................................................
14–16
EXCEPTIONTASK ...........................................
14–17
Debugging ...............................................................................
14–18
DISPLAY ..................................................................
14–18
Literals .............................................................
14–18
Pointer Expressions .........................................
14–19
String Expressions ...........................................
14–19
ACCEPT ..................................................................
14–20
Compiler Control Options .........................................
14–22
Compiler Files ..........................................................
14–28
Compile-Time Facility ..............................................
14–28
TADS .........................................................................................
14–29
Program Requirements ............................................
14–30
Basic Operations ......................................................
14–30
SG 2015 R3 xvii
About This Course
Objectives ................................................................................
15–1
Benefit Statement ....................................................................
15–1
Materials / Reference ..............................................................
15–1
Workstation I-O .......................................................................
15–3
Terminal Control Codes ............................................
15–3
Remote File Attributes .............................................
15–6
Spcfy Key Input ........................................................
15–7
Port Files ..................................................................................
15–8
Basic Port File Attributes ..........................................
15–10
Open Options ...........................................................
15–11
Subfile Matching ......................................................
15–13
Subfile I/O ................................................................
15–14
Subfile FILESTATE ..................................................
15–16
Closing the Port .......................................................
15–18
Port Files for Sockets ...............................................
15–19
Port Files for Named Pipes .......................................
15–20
Security ............................................................
15–21
Core-to-Core Communication ................................................
15–22
Storage Queues .......................................................................
15–24
Port File Application Examples .............................................
15–26
Review Exercise 15 .................................................................
15–30
xviii SG 2015 R3
About This Course
Objectives ................................................................................
16–1
Benefit Statement ....................................................................
16–1
Materials / Reference ..............................................................
16–1
Disk File Attributes and Operations ......................................
16–3
Attribute Interrogation ..............................................
16–4
Update and Extend ..................................................
16–5
OPEN Issues ............................................................
16–6
Random I-O .............................................................
16–8
Sort ..........................................................................
16–10
Variable-Length Record Files ...................................
16–12
Security ....................................................................
16–14
I - O Results .............................................................................
16–15
SG 2015 R3 xix
About This Course
Directory ..................................................................................
B–1
xx SG 2015 R3
About This Course
SG 2015 R3 xxi
Course Description
Objectives:
At the completion of this course, the student should be able to:
· Write an ALGOL program which will perform computations and display the
results.
· Declare and use arrays and pointers program.
· Declare and use Typed Procedures
· Identify various functions available to ALGOL programs
· Use partial word notation in expressions and assignments.
· Use the Masksearch function.
· Create a library program.
· Write a program to invoke library procedures.
· Initiate, monitor and control programs with an ALGOL program.
· Employ Event or Interlock variables to control operations.
· Construct and use Interrupt procedures.
· Identify the uses of Epilog, Prolog and Exception procedures.
· Identify methods of error identification, avoidance and recovery.
· Identify methods of testing and debugging programs.
· Identify terminal control codes and the means to employ them.
· Operate port files.
· Use the SORT intrinsic function.
· Bind object code modules into a single excutable file.
SG 2015 R3 xxiii
Audience:
This course is intended for ClearPath HMP NX and A Series programmers and
system support personnel
Prerequisites
Working knowledge of CANDE or EDITOR is recommended as a prerequisite.
Experience in programming is highly recommended.
Key Topics:
· ALGOL Declarations and Statements
· Procedures
· Processing character data
· Parameters
· Functions
· Partial Word Notation
· Defines
· Libraries
· Task Processing
· Shared resource control
· Error detection and recovery
· Port file operations
· Direct Files and Arrays
· Object code binding
SG 2015 R3 xxiv
About This Course
Purpose
The purpose of the course is to enhance the existing ClearPath HMP NX and A
Series languages curriculum by supplying training in the use and implementation of
the advanced functionality and features provided with the ALGOL language on the
ClearPath HMP NX and A Series system.
The goal of this course is to provide basic and intermediate level training. However
it is expected that students have had some experience with a ClearPath HMP NX or
A Series system and with programming. The course covers the common ALGOL
extensions specific to the Unisys ClearPath HMP NX and A Series system compilers
but not the advanced enhancements provided with the DCALGOL, DMALGOL,
BDMSALGOL or NEWP compilers..
Overview
ALGOL is the basis for ClearPath HMP NX and A Series system software as well as
a highly flexible language with which to develop applications. Because of its
efficiency, ease of use and flexibility, it is an industry leader worldwide and an
important justification for users to aquire ClearPath HMP NX or A Series
mainframes.
This course is updated for use through System Software Release 44.1.
SG 2015 R3 xxv
Organization
This document is divided into two volumes with sixteen sections.
Volume 1
Section 1 Program Structure
With very few structural constraints an ALGOL program can be written to do
real work.
Section 2 The PROCEDURE
Organization into Procedures gives a program flexibility and the modular
structure makes a program easier to document and maintain.
Section 3 Conditional Statements
Logical directions in programs are provided with conditional statements.
Section 4 Cases and Labels
CASE statements are a simpler alternative to extended IF statements. Labels
provide a simple means to branch forward or backward.
Section 5 Iteration Statements
Iteration statements provide efficiency in operations as well as convenience to
programmers.
Section 6 Arrays
Arrays provide data processing efficiency and convenience.
Section 7 Processing Character Data
EBCDIC arrays and pointers provide a very efficient means of processing
character data.
Section 8 Pointer Operations
Pointers, the SCAN statement and extensions of the REPLACE statement
provide many programming tools to character processing.
Section 9 Parameters and Functions
Parameters give procedures additional flexibility. Typed procedures provide an
additional value on return and can be used as arithmetic or Boolean expressions.
Applications can call typed procedures available as system intrinsic functions.
SG 2015 R3 xxvi
Page Status
Section 10 Bits and Defines
Partial words and the Masksearch function enhance processing effiency, and
partial word storage saves disk space for large files. Defines are programming
and documentation conveniences.
Volume 2
Section 11 Libraries
Library programs give system software and applications versatility and
efficiency.
Section 12 Task Processing
An application can be modularized into separate tasks which can operate
asynchronously to obtain greater efficiency, be available to other applications,
and are easier to maintain.
Section 13 Events and Interrupts
Events or Interlocks are necessary for preventing conflicts over shared resources
among asynchronous processes. Interrupt, Epilog and Exception procedures can
perform critical operations without being invoked.
Section 14 Error Detection
Before programs are placed in production, they should be thoroughly tested and
debugged. Methods of preventing faults and expediting the testing procedures
are of great value.
Section 15 Communication Techniques
With terminal control codes, userfriendly screen libraries may be created for use
by all applications. Port files facilitate data exchange among programs of all
types.
Section 16 Disk Files
Data file processing can be more efficient through control of file attributes. The
SORT intrinsic facilitates the reorganization of file records. Binding object code
files together simplifies and expedites program maintenance.
SG 2015 R3 xxvii
Software
A ClearPath HMP NX or A Series ALGOL compiler of any release level is required
to complete this course.
The following data files are important for students in the course. The files can be
copied from the course tape (EL2015R3).
ALG/DATA/6
ALG/DATA/7
ALG/DATA/8
ALG/DATA/10
Other files may be made available to students, including application examples and
laboratory solutions.
ClearPath HMP NX and A Series File Attributes Programming Reference Manual
(8600 0064)
The Extended Algol Primer, Volume One, Donald J. Gregory, Gregory Publishing
Company, 1983
The Extended Algol Primer, Volume Two, Donald J. Gregory, Gregory Publishing
Company, 1984
The Extended Algol Primer, Volume Three, Donald J. Gregory, Gregory Publishing
Company, 1985
xxviii SG 2015 R3
Page Status
Agenda
Day 1
Section 1. Program Structure
Section 2.The PROCEDURE
Section 3.Conditional Statements
Section 4. Cases and Labels
Day 2
Section 5. Iteration Statements
Section 6. Arrays
Day 3
Section 7. Processing Character Data
Section 8. Pointer Operations
Day 4
Section 9. Parameters and Functions
Section 10. Bits and Defines
Day 5
Section 11. Libraries
Day 6
Section 12. Task Processing
Day 7
Section 13. Events and Interrupts
Day 8
Section 14. Error Detection
Day 9
Section 15. Communication Techniques
Day 10
Section 16. Disk Files
SG 2015 R3 xxix