Introduction PL/1 Programming

Similar documents
Chapter 1 INTRODUCTION. SYS-ED/ Computer Education Techniques, Inc.

1 Chapter Plan...1 Exercise - Simple Program...2

Short Notes of CS201

CS201 - Introduction to Programming Glossary By

Computer Programming C++ (wg) CCOs

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

INTRODUCTION 1 AND REVIEW

Chapter 2 CREATING DATA FIELDS. SYS-ED/ Computer Education Techniques, Inc.

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

CS Programming In C

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION

Language Reference Manual simplicity

A Fast Review of C Essentials Part I

C++ (Non for C Programmer) (BT307) 40 Hours

S Y B Voc Software Development Syllabus

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)

CPSC 3740 Programming Languages University of Lethbridge. Data Types

Type Checking. Prof. James L. Frankel Harvard University

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions.

Data Storage and Query Answering. Data Storage and Disk Structure (4)

X Language Definition

Introduction to Programming Using Java (98-388)

Review of the C Programming Language for Principles of Operating Systems

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

Chapter 1 INTRODUCTION. SYS-ED/ Computer Education Techniques, Inc.

Absolute C++ Walter Savitch

Week 3 Lecture 2. Types Constants and Variables

Computers Programming Course 5. Iulian Năstac

Review of the C Programming Language

by Pearson Education, Inc. All Rights Reserved. 2

GnuCOBOL Quick Reference

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

Tokens, Expressions and Control Structures

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

Contents. Preface. Introduction. Introduction to C Programming

CS107 Handout 13 Spring 2008 April 18, 2008 Computer Architecture: Take II

Data Types. Data Types. Introduction. Data Types. Data Types. Data Types. Introduction

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

C-LANGUAGE CURRICULAM

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

Chapter 2: Basic Elements of C++

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

BLM2031 Structured Programming. Zeyneb KURT

CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C Syntax Out: 15 September, 1995

Introduction to C Language (M3-R )

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

CHAPTER 5 VARIABLES AND OTHER BASIC ELEMENTS IN JAVA PROGRAMS

Objectives. In this chapter, you will:

Programming in C++ 4. The lexical basis of C++

Declaring Pointers. Declaration of pointers <type> *variable <type> *variable = initial-value Examples:


CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

UNIT- 3 Introduction to C++

1. Lexical Analysis Phase

COMPATIBILITY CONSIDERATIONS OF THE PL/1 IMPLEMENTATION

CS201 Some Important Definitions

The New C Standard (Excerpted material)

c Microsoft, 1977, 1978, 1979

Run time environment of a MIPS program

LESSON 5 FUNDAMENTAL DATA TYPES. char short int long unsigned char unsigned short unsigned unsigned long

I BCA[ ] SEMESTER I CORE: C PROGRAMMING - 106A Multiple Choice Questions.

KLiC C Programming. (KLiC Certificate in C Programming)

C Review. MaxMSP Developers Workshop Summer 2009 CNMAT

APPENDIX E SOLUTION TO CHAPTER SELF-TEST CHAPTER 1 TRUE-FALSE FILL-IN-THE-BLANKS

Deep Dive: Pronto Transformations Reference

Control Abstraction. Hwansoo Han

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

QUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:

A flow chart is a graphical or symbolic representation of a process.

UNIVERSAL SERIAL INTERFACE

Special Topics for Embedded Programming

Goals of C "" The Goals of C (cont.) "" Goals of this Lecture"" The Design of C: A Rational Reconstruction"

BSM540 Basics of C Language

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

SOME ASSEMBLY REQUIRED

CS304 Object Oriented Programming Final Term

Number Systems, Scalar Types, and Input and Output

Table of Contents at a Glance

Name :. Roll No. :... Invigilator s Signature : INTRODUCTION TO PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

Programming. C++ Basics

Lecture 2 Tao Wang 1

DEPARTMENT OF MATHS, MJ COLLEGE

Programming languages - C

CS & IT Conversions. Magnitude 10,000 1,

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

TILE PROCESSOR APPLICATION BINARY INTERFACE

Chapter 2: Introduction to C++

CERTIFICATE IN WEB PROGRAMMING

JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University)

Computer Science (330)

Chapter 8 :: Composite Types

Data Representation and Storage. Some definitions (in C)

Transcription:

Chapter 1: Introduction Performance Objectives You will learn: Facilities and features of PL/1. Structure of programs written in PL/1. Data types. Storage classes, control, and dynamic storage allocation. Language features. Types and use of statements. What is PL/1? The PL/1 programming language: Is machine independent. Utilizes structured programming constructs. Provides exception handling capabilities. Utilizes dynamic storage management. Offers a comprehensive use of data types. Uses data aggregates - arrays, structures, unions, and combinations thereof. Has extensive I/O capabilities. Provides built-in functions: string, mathematical, arithmetic, precision, array, storage control, condition handling, and date/time. CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 1 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 2 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 3 Free-form Machine Independence Macro Facility PL/1 has no reserved keywords. PL/1 determines the meaning of keywords from the context of use. Defaults help in avoiding inadvertent keyword coding errors. PL/1 defines its data types without regard for any hardware. The implementers deliver even if the machine has no support for such data type or precision. Permits conditional compilation and modification of PL/1 source before the compilation. A programmer can include specific code during development and testing, and exclude it from a production program. CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 4 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 5 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 6 Program Structure Structured Programming Constructs Data Types PL/1 is a block-oriented language consisting of: packages procedures begin blocks statements PACKAGEs, PROCEDUREs, and BEGIN blocks Permit a high degree of data and program logic encapsulation. SELECT... WHEN... OTHERWISE logic Provide for sophisticated case logic. DO statement Provide for grouping of a number of statements as a single unit that can be executed unconditionally one time, forever, or while a condition is true or until a condition becomes true. Data types include: Real or complex, floating-point or fixed-point, signed or unsigned binary or decimal, and numeric and editable picture data with programmer selected precision. Varying or non-varying, character or bit or graphic, run-time adjustable or compile-time fixed length strings. Program control data supporting pointer and offset locators, adjustable or fixed size areas for grouping of dynamic allocations, entry data, on pointers and file, label, and format data. Areas may be written out to the disk and read back at a later date permitting preservation of linked-lists. CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 7 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 8 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 9 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1:1

Data Arrays, Structures, and Unions Data aggregates can be: Arrays Arrays of structures or unions Structures Structures or unions of arrays Unions Combinations of the above. Data Manipulation Data may be manipulated as individual items or as an aggregate. Built-in Functions PL/1 supports these categories of built-in functions: Character, bit, and graphic string manipulation Arithmetic and mathematical computation Floating point inquiries and floating point manipulation Integer manipulation Precision handling Array manipulation Storage control Condition handling Input/output Date/time manipulation CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 10 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 11 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 12 Storage Classes, Control, and Dynamic Storage Allocation There are four different storage classes: AUTOMATIC STATIC Condition Handling Handles a variety of conditions that can arise during PL/1 program execution. These conditions may be expected or unexpected and may be detected by the hardware (e.g. ZERODIVIDE) or detected by PL/1 (e.g. CONVERSION) or the operating system or other software. Program Checkout Conditions can be enabled in a variety of ways to have a program automatically diagnosed for: Array subscripts being out of range. String and substrings being out of range. Data exceeding declared or machine supported precisions. CONTROLLED BASED CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 13 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 14 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 15 Input and Output I/O Conditions Blocks PL/1 programs have the capability to: process various sizes and type of records. access various devices. edit and validate various kinds of input and output data. produce report files. Two types of I/O are provided: Record-oriented input/output. Stream input/output. PL/1 provides the following I/O conditions: ENDFILE ENDPAGE KEY RECORD TRANSMIT UNDEFINEDFILE FILEOPEN ONKEY ONSOURCE ONCHAR ONFILE PAGENO LINENO PL/1 is a block-structured language. External Procedure, is the outermost block, it provides the shell for all code and data. Procedures are executed only as subroutines or functions. Begin-blocks, are executed inline, can be nested to any depth. CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 16 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 17 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 18 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1:2

Keywords Data Defaults PL/1 does not have reserved words. PL/1 has keywords which are recognized only in context, and may otherwise be used freely by the programmer. A variable and keyword can use the identical designation. PL/1 offers the programmer control over data attributes. A variable can be specified to the number of digits or bits it is to occupy. Strings can have constant lengths or vary from zero to a maximum number of bits or bytes, with the compiler keeping track of the current length. PL/1 provides an extensive system of defaults. In the minimal case, data does not need to be declared at all. A set of default attributes will be provided depending on the context in which it is used. CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 19 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 20 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 21 Storage can be: AUTOMATIC STATIC BASED EXTERNAL Storage I/O Input-output is an integral part of PL/1; it is not an add-on library function. Files can be processed as streams of bytes or as individual records which can be fixed-length or variable. Files can be processed sequentially or randomly by record or key. Programs can start an I/O operation and later be interrupted on completion. Exceptions PL/1 has a detailed system for handling exceptions, which can asynchronously result from I/O errors, hardware-generated or program-generated. Handlers for each condition can be specified via the ON statement; handlers can be stacked and unstacked. CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 22 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 23 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 24 Character Set Character Types Special Characters SBCS: Single-byte character set. DBCS: Double-byte character set. PL/1 supports these character types: Alphabetic and extra lingual characters Decimal digits Binary digits Hexadecimal digits b - (. % > = * ) ' ; & < + /, " : _ CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 25 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 26 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 27 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1:3

Composite Symbols Identifiers Programmer-defined Names > >= > -= ** = /* => *= < <= */ += /= An identifier is a series of characters that are not contained in a comment or a constant. The first character of an identifier must be an alphabetic or extralingual character. External user names must not start with IBM, PLI, CEE, _IBM, _PLI, and _CEE. In a PL/1 program, names are given to variables and program-control data. There also are built-in names, condition names, and generic names. = &= \= **= CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 28 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 29 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 30 Blanks Comments Statements Each operator or delimiter can be surrounded with blanks (b). One or more blanks must separate identifiers and constants that are not separated by some other delimiter. Any number of blanks can appear wherever one blank is allowed. Comments are allowed wherever blanks are allowed as delimiters. A comment is treated as a blank and used as a delimiter. Comments are ignored and do not affect the logic of a program. Identifiers, delimiters, operators, and constants are used to construct PL/1 statements. There are few restrictions in the format of PL/1 statements, and programs can be written without considering special coding rules or ascertaining whether each statement begins in a specific column. A statement can begin in the next position after the previous statement, or it can be separated by any number of blanks. CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 31 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 32 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 33 Simple Statements Compound Statements Groups There are three types of simple statements: Keyword Assignment null There are four compound statements: IF ON WHEN OTHERWISE A group is either a: do-group select-group CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 34 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 35 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 36 CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1:4

CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1: 37 Introduction Program Structure STRUCT: PROCEDURE OPTIONS (MAIN); /* The declarations of variables in a procedure are usually, but not necessarily, placed at the beginning of the procedure. */ DECLARE (X,Y,Z) FIXED, MESSAGE CHARACTER(80), TOTAL FLOAT; /* Executable statements are placed following variable declarations */ X = 0; PUT SKIP LIST(MESSAGE); FINISH: PROCEDURE; DECLARE TEXT (5) CHARACTER (20); END FINISH: /* All procedures must terminate with END statements */ END STRUCT; CETI/ COMPUTER EDUCATION TECHNIQUES, INC. 1:5