Flow of Control MINS298c Fall 1998 Chapter 9. Overview ABAP Programming Structures for: –Iteration –Decisions Control Flow –If … Then –Do & While loops.

Slides:



Advertisements
Similar presentations
IF statement (i) Single statement. IF ( logical expression ) statement Example: read(*,*) a if (a. lt. 0) a = -a write(*,*) a Or read(*,*) a if (a < 0)
Advertisements

ICE1341 Programming Languages Spring 2005 Lecture #13 Lecture #13 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
1 ABAP Basics III Northern Arizona University College of Business.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
ABAP Chapter 2 Report Statement Write & Format Statement Flow Control in ABAP Manipulating Character Data Report Driven : Page Report (List Header)
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
IS437: Fall 2004 Instructor: Dr. Boris Jukic Program Flow Control: Decisions and Conditions (Branching) Controlled Repetition (Looping)
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection)
CS 117 Spring 2002 Review for Exam 2 March 6, 2002 open book, 1 page of notes.
Operators. Perl has MANY operators. –Covered in Chapter 3 of Prog.Perl Most operators have numeric and string version –remember Perl will convert variable.
Chapter 5: Control Structures II (Repetition)
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
Geography 465 Assignments, Conditionals, and Loops.
Shell Programming 1. Understanding Unix shell programming language: A. It has features of high-level languages. B. Convenient to do the programming. C.
Lab 8 Shell Script Reference:
Python Lab: Control Statements Conditionals, Loops, Iterations Proteomics Informatics, Spring 2014 Week 4 18 th Feb, 2014
Computer Science Selection Structures.
Chapter 3 Control Flow Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Presentation © Copyright 2002, Bryan Meyers Top-Down, Structured Program Design Chapter 5.
Shell Programming. Creating Shell Scripts: Some Basic Principles A script name is arbitrary. Choose names that make it easy to quickly identify file function.
CONTROLLING PROGRAM FLOW
BACS 287 Programming Logic 1. BACS 287 Programming Basics There are 3 general approaches to writing programs – Unstructured – Structured – Object-oriented.
CHAPTER 4: Selection Control Structure. Objectives  Use the relational comparison operators  Learn about AND logic  Learn about OR logic  Make selections.
Chapter 3. Outline Relational Operators Loops Decisions Logical Operators Precedence Summary.
If…else statements. Boolean Expressions Boolean expression - An expression whose value is either true or false true = 1 false = 0 Datatype: boolean.
Control Structures CPS120: Introduction to Computer Science Lecture 5.
© ABB University - 1 Revision C E x t e n d e d A u t o m a t i o n S y s t e m x A Chapter 11 Structured Text Course T314.
(A Very Short) Introduction to Shell Scripts CSCI N321 – System and Network Administration Copyright © 2000, 2003 by Scott Orr and the Trustees of Indiana.
A loop is a repetition control structure. body - statements to be repeated control statement - decides whether another repetition needs to be made leading.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Shell Script2 Reference: Linux Shell Scripting Tutorial v1.05r3 A Beginner's handbook
Topic 2: Working with scalars CSE2395/CSE3395 Perl Programming Learning Perl 3rd edition chapter 2, pages 19-38, Programming Perl 3rd edition chapter.
Shell Programming Features “Full” programming language “Full” programming language Conditional statements Conditional statements Arithmetic, String, File,
# 1# 1 Nested If Statements in VBA What is a compound condition that we evaluate? What is a Nested If statement? How do we use ElseIf? CS 105 Spring 2010.
Flow Control. The order in which commands execute in a shell script is called the flow of the script. When you change the commands that execute based.
BOOLEAN OPERATIONS AND CONDITIONALS CHAPTER 20 1.
Lab 8 Shell Script Reference: Linux Shell Scripting Tutorial v1.05r3 A Beginner's handbook
Shell script – part 2 CS 302. Special shell variable $0.. $9  Positional parameters or command line arguments  For example, a script myscript take 2.
File Handle and conditional Lecture 2. File Handling The Files associated with Perl are often text files: e.g. text1.txt Files need to be “opened for.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
1 Lecture 8 Shell Programming – Control Constructs COP 3353 Introduction to UNIX.
Chapter 5: Control Structures II (Repetition)
Sequence, Selection, Iteration The IF Statement
PROGRAM CONTROL STRUCTURE
Topics The if Statement The if-else Statement Comparing Strings
Expressions and Control Flow in JavaScript
Topics The if Statement The if-else Statement Comparing Strings
CPS120: Introduction to Computer Science
Control Structures: if Conditional
Control Structures: for & while Loops
Three Special Structures – Case, Do While, and Do Until
Selection Statements.
Summary Two basic concepts: variables and assignments Basic types:
Controlling Program Flow
PowerShell Flow of Control Copyright © 2016 – Curt Hill.
Boolean Expressions to Make Comparisons
Presented by, Mr. Satish Pise
Relational Operators.
The Selection Structure
Repetition (While Loop) LAB 9
DATA TYPES AND OPERATIONS
INTRODUCTION to PERL PART 1.
ICS 101 Lab 3 Hossain Arif ICS Dept
Decision Making Using the IF and EVALUATE Statements
REPETITION Why Repetition?
Control Structures.
Presentation transcript:

Flow of Control MINS298c Fall 1998 Chapter 9

Overview ABAP Programming Structures for: –Iteration –Decisions Control Flow –If … Then –Do & While loops In Class Exercise

Decisions Conditions are created with logical operators Simple or Compound (with parentheses) Standard Logical Operators = eq EQUAL > gt GREATER THAN <> ne NOT EQUAL < lt LESS THAN >= ge GREATER THAN or EQUAL TO <= le LESS THAN or EQUAL TO New Operators a BETWEEN b AND c means (a >= b) AND (a <= c) IS INITIAL means variable has initial condition

New Operators Between a BETWEEN b AND c means (a >= b) AND (a <= c) IS INITIAL means variable has initial condition Character Strings –CA : contains any characters of the right side –CO : contains only characters from right side –CS : contains string from right side ignore trailing blanks; not case sensitive –CP : contains pattern from right side use * for any char string and + for any single char

String Operators var1(6) value ‘ABAP/4’. IF var1 ca ‘XP’. IF var1 co ‘ABP4’. IF var1 cs ‘AA’. IF var1 cp ‘*/4’. IF var1 cp ‘*/4++’. True or False Given

If IF condition. process one. ELSEIF condition. process two. ELSE. process three. ENDIF. Things to watch - no THEN - periods

If IF condition. process one. ELSEIF condition. process two. ELSE. process three. ENDIF T T F F

Comparisons of different types IF a < b {where a and b are of different types} Hierarchy of conversion rules –same type then pad –one type f all type f –one type p all type p –one type d (or t) convert other –comparing n to c or to x converts all to type p –type x and type c converts x to c

Will it write or not? data: num1(4) value ‘124’, num2(5) value ‘00124’. if num1 = num2. write ‘numbers are equal’. endif.

Case Requires same item in every comparison CASE variable WHEN value1. same as (variable = value1) process1. WHEN value2. process2. WHEN value3. process3. WHEN OTHERS. catches all the other conditions process4. ENDCASE. !!! Only deals with =

Looping DO loops - –does at least once –may be counted or unconditional WHILE Loops –conditional: may or may do initially EXIT SY-INDEX

Two Dos –DO process condition to exit (Use EXIT Command) –ENDDO –DO x times process alternate condition to exit (Use EXIT Command) –ENDDO

While –WHILE condition process change in condition –ENDWHILE

Do vs While T T

Efficiencies Compound Conditions –ANDs put most restrictive condition first –ORs puts least restrictive condition first CASE and nested IF statements –put most likely conditions first

In-class Assignment #5 Create a program to display all the numbers between 0 and 100 and report which are divisible by 2, 3, or 5 Assignment 5 MINS298c Spring 1998 Number Divisible by no no no … 30 yes yes yes