Subprograms1 THE CALL STATEMENT (chp. 16) Purpose: a calling that executes another program; allows portions of code to be treated as a “black box”. Syntax.

Slides:



Advertisements
Similar presentations
Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
Advertisements

Sub and Function Procedures
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Macro Processor.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Eight Sub and Function Procedures.
1 Chapter Three Using Methods. 2 Objectives Learn how to write methods with no arguments and no return value Learn about implementation hiding and how.
(1) ICS 313: Programming Language Theory Chapter 10: Implementing Subprograms.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
Compiling and Linking. Compiling is quite the same as creating an executable file! Instead, creating an executable is a multistage process divided into.
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
Flow of Control. 2 Control Structures Control structure: An instruction that determines the order in which other instructions in a program are executed.
Chapter 6: Modularity Using Functions. In this chapter, you will learn about: – Function and parameter declarations – Returning a single value – Returning.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 7 Sub and Function Procedures.
Testing Methods Carl Smith National Certificate Year 2 – Unit 4.
Subprograms CE 311 K - Introduction to Computer Methods Daene C. McKinney.
Objective At the conclusion of this chapter you will be able to:
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
Programming Logic and Design Using Methods. 2 Objectives Review how to use a simple method with local variables and constants Create a method that requires.
CPS120: Introduction to Computer Science Decision Making in Programs.
CSC3315 (Spring 2008)1 CSC 3315 Subprograms Hamid Harroud School of Science and Engineering, Akhawayn University
CPS120: Introduction to Computer Science Functions.
CPS120: Introduction to Computer Science Lecture 14 Functions.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Higher Grade Computing Studies 3. High Level Language Constructs Higher Computing Software Development S. McCrossan 1 Simple Data Types Integer: An integer.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 6 Defining Functions.
1 Remember: Examination is a chance not ability. By ILTAF MEHDI, IT LECTURER, MIHE, KATR-E-PARWAN BRANCH, KABUL.
IBM-Mainframes COBOL Class-1. Background and History  COBOL is an acronym for: Common Business Oriented Language  COBOL was developed in 1959 by the.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Lecture 101 String Processing Operations on numeric edited fields i.e., view the PIC as a string of characters –Reference modification read/write substrings.
ERRORS. Types of errors: Syntax errors Logical errors.
Chapter 8: Advanced Method Concepts. Understanding Parameter Types Mandatory parameter – An argument for it is required in every method call Four types.
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
Functions Math library functions Function definition Function invocation Argument passing Scope of an variable Programming 1 DCT 1033.
Functions  A Function is a self contained block of one or more statements or a sub program which is designed for a particular task is called functions.
Chapter 6 Methods Chapter 6 - Methods.
04/02/ Procedures Top-down approach / Stepwise Refinement & Sub Procedures.
Chapter 4: More Object Concepts. Objectives Understand blocks and scope Overload a method Avoid ambiguity Create and call constructors with parameters.
16- 1 Chapter 16.  To familiarize you with  COPY statement for copying parts of a program stored in a library  CALL statement for executing called.
1 Sections 6.4 – 6.5 Methods and Variables Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Chapter 9: Value-Returning Functions
Chapter 7: Function.
Oracle11g: PL/SQL Programming Chapter 5 Procedures.
THE SORT STATEMENT for files (chp. 14)
JAVA Script : Functions Ashima Wadhwa
Chapter 10: Void Functions
UNIT - V STORED PROCEDURE.
Function There are two types of Function User Defined Function
C-language Lecture By B.S.S.Tejesh, S.Neeraja Asst.Prof.
Designing and Debugging Batch and Interactive COBOL Programs
Starting Out with Programming Logic & Design
CSC 533: Programming Languages Spring 2015
Programming Logic and Design Fourth Edition, Comprehensive
Programming in COBOL-85 For IBM Mainframe System 390
More About Objects and Methods
Topics Introduction to Functions Defining and Calling a Function
Chapter 8 Advanced SQL.
A function is a group of statements that exist within a program for the purpose of performing a specific task. We can use functions to divide and conquer.
Starting Out with Programming Logic & Design
Flow of Control.
Procedures Oracle & MySQL
Software Development Chapter 1.
CSC 533: Programming Languages Spring 2018
CSC 533: Programming Languages Spring 2019
CPS125.
Agenda for Unit 3: Functions
Presentation transcript:

Subprograms1 THE CALL STATEMENT (chp. 16) Purpose: a calling that executes another program; allows portions of code to be treated as a “black box”. Syntax Definition : CALL “subprogram-name” [ USING { [BY REFERENCE] identifier-1 … BY CONTENT identifier-2… } … ] [END-CALL] Examples : CALL “ConvertTime” USING military-time. CALL “tablesort” USING emp-table num-recs. For Your Information The CALL statement: is placed in the Procedure Division. represents a section of code which could have been placed at that logical point in the program, but instead is physically located elsewhere. passes the parameters to the subprogram The subprogram-name: does not include an extension! is case sensitive! can contain a path (like select stmt) The USING clause: identifies the fields in the calling program that are passed to the subprogram. These can be referred to as parameters or arguments. must list the passed fields in sequence that the subprogram requires. defines “by reference” to mean the address of the field in the calling program is passed; is default. defines “by content” to mean the passed data is stored in a new field in the subprogram.

Subprograms2 The SUBPROGRAM For Your Information A subprogram is a program that is called by a calling program. Before a subprogram can be called by another program, it must be compiled and ready for execution. NOTE: this is why it doesn’t matter what language the subprogram is in!!! Cannot be executed on its own Purpose: a program that is executed by another program Syntax Definition : 3 parts  Examples: SEE handouts LINKAGE SECTION. * Must be defined in the subprogram * Identifies items passed to and from * Does not exist if no parameters are passed * Value clauses are not permitted * Coded after the working-storage section PROCEDURE DIVISION USING… * Includes all fields defined in the linkage section * Must match up with variables in CALL statement (although order does not matter) * The name can be the same or different EXIT PROGRAM. * Passes execution control from the subprogram back to the calling program, passing the parameters back as well * Can have multiple statements

Subprograms3 Advantages of calling subprograms avoids duplication of effort improves programmer productivity simplification of main reduces overall development time takes advantage of individual programmer's strengths/talents separate compilation and testing easier to debug and maintain divides tasks for multiple programmers provides greater flexibility changes to the called program can be made without the need to modify the calling program. results in greater standardization DISADVANTAGES extra step to join program and subprogram together (linking) slightly longer execution time because of procedure calls can not be run independently