IDL Tutorials : Day 5 Michael Hahn

Slides:



Advertisements
Similar presentations
Introduction to C Systems Programming Concepts. Introduction to C A simple C Program A simple C Program –Variable Declarations –printf ( ) Compiling and.
Advertisements

Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Pemrograman C Risanuri Hidayat. Why C  Compact, fast, and powerful  “Mid-level” Language  Standard for program development (wide acceptance)  It is.
The Print Formatting Statement … named printf. 2 Introduction to printf statements print and println statements don’t allow us to easily format output.
Input from STDIN STDIN, standard input, comes from the keyboard. STDIN can also be used with file re-direction from the command line. For instance, if.
1 Unix Talk #2 AWK overview Patterns and actions Records and fields Print vs. printf.
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
EGR 106 – Truss Design Project (cont.) Truss design programs Graphical interface tools in Matlab Saving and loading data Formatted output Project Assignment.
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
1 9/8/08CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
Basic C Programming Data Types and Arithmetic Operations 01/30/15.
The little language that could Remember C is a “small language”
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 6P. 1Winter Quarter I/O in C Lecture 6.
Homework Reading –Finish K&R Chapter 1 (if not done yet) –Start K&R Chapter 2 for next time. Programming Assignments –DON’T USE and string library functions,
The printf Method The printf method is another way to format output. It is based on the printf function of the C language. System.out.printf(,,,..., );
IDL Tutorial: Day 2 Michael Hahn
Homework Reading Programming Assignments
Chapter 2: C Fundamentals Dr. Ameer Ali. Overview C Character set Identifiers and Keywords Data Types Constants Variables and Arrays Declarations Expressions.
11 Chapter 3 DECISION STRUCTURES CONT’D. 22 FORMATTING FLOATING-POINT VALUES WITH THE DecimalFormat CLASS We can use the DecimalFormat class to control.
IDL Tutorials: Day 1 Michael Hahn
CS 102 Computers In Context (Multimedia)‏ 01 / 28 / 2009 Instructor: Michael Eckmann.
Chapter 5: Data Input and Output Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills
CIS Computer Programming Logic
1 The CONST definition CONST Pi = , City = ‘New York’; Constant identifiers are used when you do not want the value of an identifier to change why.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
IDL Tutorials Day 2 Henry (Trae) Winter
Introduction to C Programming Chapter 2 : Data Input, Processing and Output.
An Introduction to Java Programming and Object-Oriented Application Development Chapter 7 Characters, Strings, and Formatting.
Synthesis ENGR 1181 MATLAB 11. Topics  No new material  Covers topics that will be on the Midterm 2 Exam MATLAB 01 – Program Design MATLAB 02 – Introduction.
Sha Tin Methodist College F.4 Computer Studies Pascal Programming.
IDL Tutorial Day 1 Goals: 1) Introduce IDL basics 2) Describe fundamental IDL structures Angela Des Jardins
Control Statements I: Loop. Control Statements Used to specify the order in which computations will be carried out Three types Loop: for, while, repeat.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
Input and Output I: ASCII and Binary files. Data formats ASCII Binary netCDF HDF.
Khalid Rasheed Shaikh Computer Programming Theory 1.
Pascal Programming Today Chapter 11 1 Chapter 11.
EGR 115 Introduction to Computing for Engineers Formatted File Input / Output Wednesday 12 Nov 2014 EGR 115 Introduction to Computing for Engineers.
Basic Variables & Operators Web Programming1. Review: Perl Basics Syntax ► Comments: start with # (ignored by Perl) ► Statements: ends with ; (performed.
String Formatting Preparing strings for output. Printing println( arg ) prints its one argument on a line println can be used to print any single value,
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Input and Output.
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Files A collection of related data treated as a unit. Two types Text
Simple Console Output CS 21a. What we will briefly discuss System.out.println( … ) System.out.print( … ) System.out.printf( … )
Expressions and Data Types Professor Robin Burke.
Python: File Management Damian Gordon. File Management We’ve seen a range of variable types: – Integer Variables – Real Variables – Character Variables.
+ Note On the Use of Different Data Types Use the data type that conserves memory and still accomplishes the desired purpose. For example, depending on.
Formatted I/O ä ä Standard Output ä ä printf() family of functions ä ä Standard Input ä ä scanf() family of functions.
File I/O. I/O Flags Flags are passed to give some information about how the file is to be used. – Read only file – flag=0x0 – Write only file – flag=0x1.
Input and Output: I/O Finish reading chapters 1 and 2 of the text
ECE Application Programming
INC 161 , CPE 100 Computer Programming
John Carelli, Instructor Kutztown University
Input and Output Lecture 4.
System.out.println for console output
Lecture 13 Input/Output Files.
Matlab review Matlab is a numerical analysis system
Govt. Polytechnic,Dhangar
IDL Tutorials Day 4 Henry (Trae) Winter
Conversion Check your class notes and given examples at class.
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
Repetition Structures
Introduction to C CSE 2031 Fall /15/2019 8:26 AM.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Presentation transcript:

IDL Tutorials : Day 5 Michael Hahn

Todays Topics Writing and Reading a text file Using the format command

Opening a Textfile First you must open the file: Use- - openr ; opens a file to reade - openw; opens a file to write - openu; opens a file for updates Syntax: > openw, lun, ‘filename’, /Optional_Keywords lun: A number or a variable containing the “logical unit number”. Used by IDL to manage files Important Keywords - /APPEND; Starts writing at the end of an existing file instead of overwriting the file - /GET_LUN; IDL assigns a number for the lun variable

Writing To a Textfile Once the file is open write to it just as you would write to the screen, except use printf instead of print. Syntax: > printf, lun, “stuff to be printed”, “More stuff”, Format=“(2A12)” Once you’re finished with the file you need to close it -close, lun ; closes the file associated with lun -Close, /All; closes all open files

Using the Format Keyword The FORMAT keyword allows you to format the data output Syntax: >…, FORMAT=‘(5A6)’ formats the next 5 strings with six characters each > …,FORMAT=‘(3F7.3)’ Formats the next 3 numbers. 7 total digits (including a – sign if needed, and decimal) and 3 digits past the decimal point > …,FORMAT=‘(3D7.3)’ Does the same as the above, except with double precision > …, FORMAT=‘(2A6, 1D7.2,A5)’ The expressions in the print statement will be formatted: the first two are strings, 6 characters each Next expression is a double with 7 total characters and 2 past the decimal The last is a string with 5 characters

Reading a Textfile Open a file using the openr procedure Ascii files can be aread with a wide array of procedures and functions. Most common is readf > readf, lun, var1, var2, FORMAT=‘(some format)’ Once you’re finished with the file you need to close it.