Chapter 5+ Input / Output Sec. 5.4 & 5.5 (p. 283 – 295) File Processing ( 檔案處理 )

Slides:



Advertisements
Similar presentations
Fundamentals of Computer and programming in C Programming Languages, Programs and Programming Rohit Khokher.
Advertisements

Input and Output READ WRITE OPEN. FORMAT statement Format statements allow you to control how data are read or written. Some simple examples: Int=2; real=
Revision.
CHAPTER 5 INPUT/OUT FORMAT. Introduction READ (*,*) x WRITE (*,*) x This is free format: the first * is for I/O device number (* = input is keyboard *
Repetition Control Structures School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 9, Friday 3/07/2003)
Fortran 4- Reading and Writing from Data Files Chapter 4 of your Fortran book.
1 Basic I/O Input and Output. 2 The READ Statement Basic Version l Performs a list-directed read from the file (or device) indicated by the unit number.
Flow Master  Flow Master is used to design and analyze single pipe.  It is very flexible as no unit conversion is needed.  Data can be entered with.
A loop is a repetition control structure. it causes a single statement or block to be executed repeatedly What is a loop?
Input and output. Input streams n there are two ways of handling I/o n list-directed –done using default settings –PRINT*, num –READ*, num n formatted.
27 April, 2000 CS1001 Lecture 25 Files Internal Files.
1 Lecture 14 Chapter 6 Looping Dale/Weems/Headington.
1 10/9/06CS150 Introduction to Computer Science 1 for Loops.
Formatted Output What we know: write(*,*) x print *, x General Form: write (unit, format, options) list unit = * : write to the monitor format = *: no.
JAVA 1.5 New Features Dr V. The syntax of the enhanced for loop (for each) for (type variableName : arrayName) { statements } arrayName could be any.
Chapter 5 Input / Output. 2 Control over input & output  The input and output are basically facilitates a communication between the user and the program.
Chapter 6 - Visual Basic Schneider
CHAPTER 6 FILE PROCESSING. 2 Introduction  The most convenient way to process involving large data sets is to store them into a file for later processing.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Repetition Statements.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 6 Repetition Statements.
Chapter 6 AN INTRODUCTION TO FILES AND FILE PROCESSING Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering.
4-1 Coding Complete COBOL Programs: The PROCEDURE DIVISION Chapter 4.
4-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
1 Chapter 4. To familiarize you with methods used to 1. Access input and output files 2. Read data from an input file 3. Perform simple move operations.
Outlines Chapter 3 –Chapter 3 – Loops & Revision –Loops while do … while – revision 1.
The WinMine Toolkit Max Chickering. Build Statistical Models From Data Dependency Networks Bayesian Networks Local Distributions –Trees Multinomial /
Flowcharts! January 13, 2005 These are today’s notes! Do you think we will get more snow?
CHAPTER 2 PART #3 INPUT - OUTPUT 1 st semester King Saud University College of Applied studies and Community Service Csc
Chapter 7 File I/O 1. File, Record & Field 2 The file is just a chunk of disk space set aside for data and given a name. The computer has no idea what.
Why Files? ♦ the amount of data read and / or produced is huge ♦ repetitive data is needed for more than one program ♦ data may be entered by other people.
Visual Basic.net Loops. Used to do multiple executions of the same block of code Do while loops Do until loops For next loops.
Computer Science: A Structured Programming Approach Using C1 2-7 Input/Output Although our programs have implicitly shown how to print messages, we have.
Chapter 6 Looping CS185/09 - Introduction to Programming Caldwell College.
Data Structures Using Java1 Chapter 2 Inheritance and Exception Handling.
Branches and Program Design
Some Fortran programming tips ATM 562 Fall 2015 Fovell (see also PDF file on class page) 1.
CS Class 05 Topics  Selection: switch statement Announcements  Read pages 74-83, ,
Count and add list of numbers From user input and from file.
A Level Computing#BristolMet Session ObjectivesU2#S12 MUST describe the terms modal and pretty printing in term of input and output facilities. SHOULD.
Chapter 11: Data Files and File Processing Files and streams Creating a sequential access file Reading data from a sequential access file Using fgetc()
GAME203 – C Files stdio.h C standard Input/Output “getchar()”
19 - 2/25/2000AME 150L1 Solving Systems of Linear Equations.
Chapter 4 PROCEDURE DIVISION. Paragraphs PROCEDURE DIVISION divided into paragraphs Each is independent module or routine Made up of series of instructions.
Aggregator  Performs aggregate calculations  Components of the Aggregator Transformation Aggregate expression Group by port Sorted Input option Aggregate.
1 Chapter 8: File Processing Part 1. 2 Outline  Why Files?  Opening Files  Reading from Files  Writing to Files  Working with Multiple Files  Closing.
Decoder Chapter 12 Subject: Digital System Year: 2009.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Programming II I/O Streams and Data Files 1(c) Asma AlOsaimi.
Introduction Every program takes some data as input and generate processed data as out put . It is important to know how to provide the input data and.
Chapter 7 Text Input/Output Objectives
Chapter 7 Text Input/Output Objectives
1-1 Logic and Syntax A computer program is a solution to a problem.
Control Flow Constructs: Conditional Logic
Decisions Chapter 4.
CHAPTER 5A Loop Structure
Think What will be the output?
Chapter 5: Loops and Files.
User-Defined Functions
Topics Introduction to File Input and Output
CHAPTER 5 (PART 2) JAVA FILE INPUT/OUTPUT
Structured Program Design
Chapter 8 The Loops By: Mr. Baha Hanene.
Chapter 3: Input/Output
What does this do? def revList(L): if len(L) < = 1: return L x = L[0] LR = revList(L[1:]) return LR + x.
A LESSON IN LOOPING What is a loop?
FILE PROCESSING Opening Files Why Files?
Assignment #3 Programming Language, Spring 2003
Building Java Programs
Topics Introduction to File Input and Output
Week 10 FILE PROCESSING.
Presentation transcript:

Chapter 5+ Input / Output Sec. 5.4 & 5.5 (p. 283 – 295) File Processing ( 檔案處理 )

The WRITE Statement and the General READ Statement WRITE (6, *) Gravity, Weight An output device having unit number 6 WRITE (*, *) Gravity, Weight PRINT *, Gravity, Weight READ (5, *) Code, Time, Rate An input device having unit number 5 READ (5, 10) Code, Time, Rate 10 FORMAT (I6, 2F6.2)

The WRITE Statement WRITE (6, *) Gravity, Weight An output device having unit number 6 is equivalent to the following form: WRITE (6, FMT = *) Gravity, Weight WRITE (UNIT = 6, FMT = *) Gravity, Weight or WRITE (Output_Unit, *) Gravity, Weight WRITE (UNIT = Output_Unit, FMT = *) Gravity, Weight

The General READ Statement READ (5, *) Code, Time, Rate An input device having unit number 5 is equivalent to the following form: READ (5, FMT = *) Code, Time, Rate READ (UNIT = 5, FMT = *) Code, Time, Rate or READ (In, *) Code, Time, Rate READ (UNIT = In, FMT = *) Code, Time, Rate

The WRITE Statement The WRITE statement has more complicated syntax than the PRINT statement, but it is a more general output statement. The ADVANCE = clause is used to specify whether output should advance to a new line after the current output has been completed.

ADVANCE ADVANCE = “ NO ” causes nonadvancing output, where ADVANCE = “ YES ” is the default ( 棄權 ; 系統默認值 ) condition and causes an advance to a new line of output after the WRITE statement has been executed.

ADVANCE PRINT *, “ Enter last name to be used: ” READ *, LastNumber WRITE (*, ‘ (A) ’, ADVANCE = “ NO ” ) & “ Enter last name to be used: ” READ *, LastNumber Enter last name to be used: 10

5.5 File Processing ( 檔案處理 ) OPEN (UNIT = 12, FILE = “ INFO.DAT ”, & STATUS = “ OLD ”, & ACTION = “ READ ”, & POSITI ON = “ REWIND ”, & IOSTAT = OpenStatus) IF (OpenStatus > 0) STOP “ *** Cannot open file *** ” IF (OpenStatus > 0) ! End of file READ (12, *) Code, Temperature, Pressure

File Input/Output DO READ (12, *, END = 20) Code, & Temperature, Pressure ‧ ‧ ‧ ‧ ‧ Count= Count +1 END DO ‧ ‧ ‧ ‧ ‧ 20 CONTINUE ‧ ‧ ‧ ‧ ‧

File Processing OPEN (UNIT = 13, FILE = “ REPORT ”, & STATUS = “ NEW ”, & ACTION = “ WRITE ”, & IOSTAT = OpenStatus) WRITE (13, ‘ (1X, I3, F7.0, F10.2) ’ ) & Code, Temperature, Pressure CLOSE (13)