Week 9 Controling I/O. Today’s program Review of the last quiz Q&A about last weeks topics New topic: I/O formatting.

Slides:



Advertisements
Similar presentations
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=
Advertisements

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 *
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.
Case studies over control structures and iterative structures Instructor – Gokcen Cilingir Cpt S 121 (July 6, 2011) Washington State University.
Chapter 5 Basic I/O Concepts Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul - Turkey Tel:
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Chapter 2 Basic Elements of Fortan
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.
File Input and Output Sequential Access Files. Format Function Syntax: –Format( expression, “format” ) Example: lblNumber.Caption = “You owe ” & Format(dblSum,
27 April, 2000 CS1001 Lecture 25 Files Internal Files.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
Introduction to Python
CHAPTER 3 INPUT/OUTPUT List-directed (free formatted) input/output As in section 2.6 Formatted input/output General Form: Read format-specifier, input-list.
Formatted Output What we know: write(*,*) x print *, x General Form: write (unit, format, options) list unit = * : write to the monitor format = *: no.
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 FILE PROCESSING. 2 Introduction  The most convenient way to process involving large data sets is to store them into a file for later processing.
1 BIL106E Introduction to Scientific & Engineering Computing Organizational matters Fortran 90 ( subset F ): Basics Example programs in detail.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 11, Lecture 2 (Wed)
Example in Final Fall 2006 PROGRAM EXAM IMPLICIT NONE INTEGER :: A=3, B=8 REAL :: CALC B = CALC(A, B) A = CALC(A, B) WRITE(*,*) A, B END PROGRAM EXAM a)
Generalized I/O. Mystery of stars I/O statements took the form read *, x, y,z print *, a,b,c Such I/O is said to be List-directed or in free format user.
How Computers Store Data
Fortran 1- Basics Chapters 1-2 in your Fortran book.
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
1 © 2000 John Urrutia. All rights reserved. Qbasic Constructing Qbasic Programs.
Pascal Programming Strings, Arithmetic operators and output formatting National Certificate – Unit 4 Carl Smith.
Tutorial 61 List Box Control Can be used to display a set of choices from which the user can select only one You also can create multi-selection list boxes.
Input, Output, and Processing
1 Week 2 n Organizational matters n Fortran 90 (subset F): Basics n Example programs in detail.
1 More Control over INPUT and OUTPUT (I / O) The interface between the user and the computer Formats and edit descriptors Input editing Output editing.
Chapter 7 Formatted input and output. 7.1 introduction Tax: This result is correct; but it would be better Maybe as $13, Make formatting.
Week 3 Let's review! Fundamental data types List-directed input/output.
INPUT / OUTPUT STATEMENTS
Chapter 3 Input and Output
21 April, 2000 CS1001 Lecture 22 Formatted Input and Output.
19 - 2/25/2000AME 150L1 Solving Systems of Linear Equations.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 2 (Tuesday)
Homework 1 (due:April 8th) Deadline : April 8th 11:59pm Where to submit? eClass “ 과제방 ” ( How to submit? Create a folder. The name.
INPUT, Output & storage devices
Homework 2 (due:April 17th) Deadline : April 17th 11:59pm Where to submit? eClass “ 과제방 ” ( How to submit? Create a folder. The.
Week 9 More Control over INPUT and OUTPUT (I / O).
Chapter 1: Introduction to Computers and Programming
EET 2259 Unit 13 Strings and File I/O
Topics Designing a Program Input, Processing, and Output
Using the Console.
Engineering Problem Solving With C An Object Based Approach
Chapter 1: Introduction to computers and C++ Programming
What Actions Do We Have Part 1
Chapter 8 More control over input and output
CPS120: Introduction to Computer Science
EGR 2261 Unit 3 Input/Output Read Malik, Chapter 3.
Computer Fundamentals
Input and Output Statements
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Input/Output Handouts: Quiz 2, Unit 3 practice sheets.
Python I/O.
File I/O in C Lecture 7 Narrator: Lecture 7: File I/O in C.
Prepared By: Deborah Becker
CS150 Introduction to Computer Science 1
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
FILE PROCESSING Opening Files Why Files?
Homework 2 (due:May 5th) Deadline : May 5th 11:59pm
EET 2259 Unit 13 Strings and File I/O
Variables in C Topics Naming Variables Declaring Variables
DATA TYPES AND OPERATIONS
Week 10 FILE PROCESSING.
OUTPUT DESIGN PRINT K, expression list K FORMAT (specification list)
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Week 9 Controling I/O

Today’s program Review of the last quiz Q&A about last weeks topics New topic: I/O formatting

I/O Keyboard Disk file Magnetic tape etc. Display Printer Disk file Magnetic tape etc. Input Output External mediaComputer’s memory real integer character etc. Convert to internal form Convert to external form

User interface of F programs Character-based interface read/print statements List-directed I/O “Intelligent” read read *, a, b, c, d “Reasonable” print print *, x, y, z

List-directed read Value separators: –, (comma) –/ (slash) –one or more consecutive blanks –end-of-record/end-of-line Be careful with character data (read the book!)

List-directed print It gives you a “reasonable”/readable output But… Not much control over the space between values, digits after the decimal point, etc.

I/O editing Keyboard Disk file Magnetic tape etc. Display Printer Disk file Magnetic tape etc. Input Output External mediaComputer’s memory real integer character etc. Convert to internal form Convert to external form

Format descriptors Instead of: read *, input_list print *, output_list read ch_expr, input_list print ch_expr, output_list

Format descriptors ch_expr is format specifier (ed_des1, ed_des2, …) edit descriptors - character-type data read "(edit_descriptor_list)", input_list print "(edit_descriptor_list)", output_list

Edit Descriptors Integer data iw Next w characters are to be read and interpreted as an integer read "(i9)", n read "(i3, i2, i5)", a, b, c

Edit Descriptors Tabs tcread at position c tlnn character before trnn character after

Edit Descriptors Integer data iw Next w characters are to be read and interpreted as an integer read "(i9)", n read "(i3, i2, i5)", a, b, c

Edit Descriptors Real data fw.d If there is a decimal point, read next w characters and interpret it as a real number If there is no decimal point, take d into account ew.d

Edit Descriptors Character data aw –w < len –w > len rightmost len characters stored a w = len assumed Logical data Lw t,true,.T,.true.,...

Output editing Essentially the same

More control... read (clist) input_list write (clist) output_list clistcontrol list keyword = value –unit = unit –fmt = ch_expr –iostat = io_status

Homework Homework # 7: Problem 9.11 from Ellis & Philips Deadline April 30. All previous homework [HW#1-6] deadline reset to April 23. Your last chance!