Chapter 17: Files Storing Information For

Similar documents
SPECIAL VOWEL SOUNDS

Problem Solving Session 1: Electric Dipoles and Torque

Incorporating Statistical Process Control and Statistical Quality Control Techniques into a Quality Assurance Program

Contents Stochastic Ray Tracing

Panel Discussion: Evolving DoD Security Requirements for Cloud

Physics. Lesson Plan #9 Energy, Work and Simple Machines David V. Fansler Beddingfield High School

Factors that Influence Memory

Authenticated Encryption. Jeremy, Paul, Ken, and Mike

Handout 3. Free Electron Gas in 2D and 1D

HEAT TRANSFER ANALYSIS OF LNG TRANSFER LINE

Who uses our services? We have a growing customer base. with institutions all around the globe.

Defending DoD Missions in the Commercial Cloud

ISSeG EGEE07 Poster Ideas for Edinburgh Brainstorming

Enterprises and OEMs. Securing identity and access.

The Casino Experience

Chapter 4: Thinking Like a Programmer

Tank Level GPRS/GSM Wireless Monitoring System Solutions

The example is taken from Sect. 1.2 of Vol. 1 of the CPN book.

Instruction: Solving Exponential Equations without Logarithms. This lecture uses a four-step process to solve exponential equations:

Continuity Cloud Virtual Firewall Guide

YouthWorks Youth Works (yüth- w rkz), n.

Basis risk. When speaking about forward or futures contracts, basis risk is the market

Before attempting to connect or operate this product, please read these instructions carefully and save this manual for future use.

QUANTITATIVE METHODS CLASSES WEEK SEVEN

Oscar & Associates Photography and Video Services

IT Update - August 2006

Inside the Vault Oil. Demand and Supply It s What Economics Is About! Lesson Plan

Magic Message Maker Amaze your customers with this Gift of Caring communication piece

Load Balancing Algorithm Based on QoS Awareness Applied in Wireless Networks

Cookie Policy- May 5, 2014

Paper Technics Orientation Course in Papermaking 2009:

Texas Instruments 30X IIS Calculator

Financial Mathematics

Lecture 3: Diffusion: Fick s first law

New Basis Functions. Section 8. Complex Fourier Series

How To Write A Storybook

Extending Probabilistic Dynamic Epistemic Logic

Comparing plans is now simple with metal plans. What Does it Mean to Have a 6-Tier Pharmacy Plan? Tie. Individual Health Insurance

Sun Synchronous Orbits for the Earth Solar Power Satellite System

Lecture 20: Emitter Follower and Differential Amplifiers

THE NAVAJO NATION Department of Personnel Management JOB VACANCY ANNOUNCEMENT INFORMATION SYSTEMS TECHNICIAN

Porametr Leegomonchai North Carolina State University Raleigh, NC and

^^^^H Present, Past, and Future Tenses

The Beer-Bouguer-Lambert law. Concepts of extinction (scattering plus absorption) and emission. Schwarzschild s equation.

Compression Outline. LZ77: Sliding Window Lempel-Ziv. Lempel-Ziv Algorithms. CPS 296.3:Algorithms in the Real World

Remember you can apply online. It s quick and easy. Go to Title. Forename(s) Surname. Sex. Male Date of birth D

5 2 index. e e. Prime numbers. Prime factors and factor trees. Powers. worked example 10. base. power

PCA vs. Varimax rotation

Fetch. Decode. Execute. Memory. PC update

FACULTY SALARIES FALL NKU CUPA Data Compared To Published National Data

is knowing the car market inside out.

Reach Versus Competition in Channels with Internet and Traditional Retailers

Coverage Assessment and Target Tracking in 3D Domains

The Full-Wave Rectifier

Logo Design/Development 1-on-1

Online Load Balancing and Correlated Randomness

DATAPLAY: Mapping Game Mechanics to Traditional Data Visualization

Mathematics. Mathematics 3. hsn.uk.net. Higher HSN23000

Aegis Identity Software, Inc. Experts in Identity Management 100% Focused on Education

June Enprise Rent. Enprise Author: Document Version: Product: Product Version: SAP Version:

A Place to Choose Quality, Affordable Health Insurance

TELL YOUR STORY WITH MYNEWSDESK The world's leading all-in-one brand newsroom and multimedia PR platform

Reliability-Driven Reputation Based Scheduling for Public-Resource Computing Using GA

Keep Te d C u b e. TedCube

Outside Cut 1 of fabric Cut 1 of interfacing

Recognition of Handwritten Textual Annotations using Tesseract Open Source OCR Engine for information Just In Time (ijit)

HOMEWORK FOR UNIT 5-1: FORCE AND MOTION

C H A P T E R 1 Writing Reports with SAS

CPS 220 Theory of Computation REGULAR LANGUAGES. Regular expressions

Using SAS s PROC GPLOT to plot data and lines

Question 3: How do you find the relative extrema of a function?

fiziks Institute for NET/JRF, GATE, IIT JAM, JEST, TIFR and GRE in PHYSICAL SCIENCES NUCLEAR AND PARTICLE PHYSICS NET/JRF (JUNE-2011)

700 EN S e r i e s

Adverse Selection and Moral Hazard in a Model With 2 States of the World

Palliative Care Collaborative: 8th Annual Regional Conference

Econ 371: Answer Key for Problem Set 1 (Chapter 12-13)

Gravitation. Definition of Weight Revisited. Newton s Law of Universal Gravitation. Newton s Law of Universal Gravitation. Gravitational Field

Finite Dimensional Vector Spaces.

Simple Interest Loans (Section 5.1) :

HOW Interactive Design Conference Advanced HTML 5 / CSS 3 / jquery Chris Converse. codify kōd fī

Updating the E5810B firmware

AREA COVERAGE SIMULATIONS FOR MILLIMETER POINT-TO-MULTIPOINT SYSTEMS USING STATISTICAL MODEL OF BUILDING BLOCKAGE

5.4 Exponential Functions: Differentiation and Integration TOOTLIFTST:

Vision Mouse. Saurabh Sarkar a* University of Cincinnati, Cincinnati, USA ABSTRACT 1. INTRODUCTION

ELM for Exchange version 5.5 Exchange Server Migration

Causal, Explanatory Forecasting. Analysis. Regression Analysis. Simple Linear Regression. Which is Independent? Forecasting

NOTE: The Flatpak version has the same pinouts (Connection Diagram) as the Dual In-Line Package. *MR for LS160A and LS161A *SR for LS162A and LS163A

Additional File 1 - A model-based circular binary segmentation algorithm for the analysis of array CGH data

Multiple choice questions [70 points]

(6)(2) (-6)(-4) (-4)(6) + (-2)(-3) + (4)(3) + (2)(-3) = = 0

at 10 knots to avoid the hurricane, what could be the maximum CPA? 59 miles - 54 nm STEP 1 Ship s Speed Radius (e-r) 10 k nm every 6 minutes

FEE-HELP INFORMATION SHEET FOR DOMESTIC FULL FEE STUDENTS

Important Information Call Through... 8 Internet Telephony... 6 two PBX systems Internet Calls... 3 Internet Telephony... 2

off campus housing survival guide Student Services Services aux étudiants

Transistor is a semiconductor device with fast respond and accuracy. There are two types

A New replenishment Policy in a Two-echelon Inventory System with Stochastic Demand

Basic C Shell. helpdesk@stat.rice.edu. 11th August 2003

How to create a default user profile in Windows 7

Transcription:

Chapt 17: Fls Stong Infomaton Fo Lat. Pag 255 Chapt 17: Fls Stong Infomaton Fo Lat. W hav xplod th comput's shot tm mmoy wth vaabls and aays but how do w sto thos valus fo lat? Th a many dffnt tchnqus fo long tm data stoag. BASIC-256 suppots wtng and adng nfomaton fom fls on you had dsk. That pocss of nput and output s oftn wttn as I/O. Ths chapt wll show you how to ad valus fom a fl and thn wt thm fo long tm stoag. Radng Lns Fom a Fl: Ou fst pogam usng fls s gong to show you many of th statmnts and constants you wll nd to us to manpulat fl data. Th a sval nw statmnts and functons n ths pogam. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 # c17_adlfl.kbs # ad a smpl txt fl nput "fl nam> ", fn$ f not xsts(fn$) thn pnt fn$ + " dos not xst." nd nd f # n = 0 opn fn$ whl not of l$ = adln n = n + 1 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. 15 16 17 18 19 Pag 256 pnt n + " " + l$ nd whl # pnt "th fl " + fn$ + " s " + sz + " byts long." clos Pogam 110: Rad Lns Fom a Fl fl nam> 2_c17_tst.txt 1 Ths a th tms that 2 ty mn's souls. 3 - Thomas Pan th fl 2_c17_tst.txt s 57 byts long. Sampl Output 110: Rad Lns Fom a Fl xst(xpsson) Look on th comput fo a fl nam spcfd by th stng xpsson. Dv and path may b spcfd as pat of th fl nam, but f thy a omttd thn th cunt wokng dctoy wll b th sach locaton. Rtuns tu f th fl xsts; ls tuns fals. 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. opn opn opn opn Pag 257 xpsson (xpsson) flnumb, xpsson (flnumb, xpsson) Opn th fl spcfd by th xpsson fo adng and wtng to th spcfd fl numb. If th fl dos not xst t wll b catd so that nfomaton may b addd (s wt and wtln). B su to xcut th clos statmnt whn th pogam s fnshd wth th fl. BASIC-256 may hav a total of ght (8) fls opn 0 to 7. If no fl numb s spcfd thn th fl wll b opnd as fl numb zo (0). of of() of(flnumb) Th of functon tuns a valu of tu f w a at th nd of th fl fo adng o fals f th s stll mo data to b ad. If flnumb s not spcfd thn fl numb zo (0) wll b usd. 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. Pag 258 adln adln() adln(flnumb) Rtun a stng contanng th contnts of an opn fl up to th nd of th cunt ln. If w a at th nd of th fl [ of(flnumb) = tu ] thn ths functon wll tun th mpty stng (""). If flnumb s not spcfd thn fl numb zo (0) wll b usd. sz sz() sz(flnumb) Ths functon tuns th lngth of an opn fl n byts. If flnumb s not spcfd thn fl numb zo (0) wll b usd. clos clos() clos flnumb clos(flnumb) Th clos statmnt wll complt any pndng I/O to th fl and allow fo anoth fl to b opnd wth th sam numb. If flnumb s not spcfd thn fl numb zo (0) wll b usd. 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. Pag 259 Wtng Lns to a Fl: In Pogam 110 w saw how to ad lns fom a fl. Th nxt two pogams show dffnt vaatons of how to wt nfomaton to a fl. In Pogam 111 w opn and cla any data that may hav bn n th fl to add ou nw lns and n Pogam 112 w appnd ou nw lns to th nd (savng th pvous data). 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 # c17_stwt.kbs # wt txt to a fl, go back to bgnng # and dsplay th txt opn "2_c17_stwt.dat" pnt "nt a blank ln to clos fl" # cla fl (st) and stat ov st whl tu nput ">", l$ f l$ = "" thn xt whl wtln l$ nd whl # go th th stat and dsplay contnts sk 0 k = 0 whl not of() k = k + 1 pnt k + " " + adln() nd whl clos nd Pogam 111: Cla Fl and Wt Lns 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. Pag 260 nt a blank ln to clos fl >ths s som >data, I am typng >nto th pogam. > 1 ths s som 2 data, I am typng 3 nto th pogam. Sampl Output 111: Cla Fl and Wt Lns st o st() o st flnumb st(flnumb) Cla any data n an opn fl and mov th fl pont to th bgnnng. If flnumb s not spcfd thn fl numb zo (0) wll b usd. 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. Pag 261 sk xpsson sk(xpsson) sk flnumb,xpsson sk (flnumb,xpsson) Mov th fl pont fo th nxt ad o wt opaton to a spcfc locaton n th fl. To mov th cunt pont to th bgnnng of th fl us th valu zo (0). To sk to th nd of a fl us th sz() functon as th agumnt to th s statmnt. If flnumb s not spcfd thn fl numb zo (0) wll b usd. wtln xpsson wtln(xpsson) wtln flnumb,xpsson wtln (flnumb,xpsson) Output th contnts of th xpsson to an opn fl and thn appnd an nd of ln mak to th data. Th fl pont wll b postond at th nd of th wt so that th nxt wt statmnt wll dctly follow. If flnumb s not spcfd thn fl numb zo (0) wll b usd. 1 2 3 4 5 6 7 # c17_appndwt.kbs # appnd nw lns on th nd of a fl # thn dsplay t opn "2_c17_appndwt.dat" pnt "nt a blank ln to clos fl" 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Pag 262 # mov fl pont to nd of fl and appnd sk sz whl tu nput ">", l$ f l$ = "" thn xt whl wtln l$ nd whl # mov fl pont to bgnnng and show contnts sk 0 k = 0 whl not of() k = k + 1 pnt k + " " + adln() nd whl clos nd Pogam 112: Appnd Lns to a Fl nt a blank ln to clos fl >sd sd sd >vm vm vm > 1 ba ba ba 2 foo foo foo 3 gap gap gap 4 sd sd sd 5 vm vm vm Sampl Output 112: Appnd Lns to a Fl 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. Pag 263 Rad() Functon and Wt Statmnt: In th fst th pogams of ths chapt w hav dscussd th adln() functon and wtln statmnt. Th a two oth statmnts that wll ad and wt a fl. Thy a th ad() functon and wt statmnt. ad ad() ad(flnumb) Rad th nxt wod o numb (tokn) fom a fl. Tokns a dlmtd by spacs, tab chaacts, o nd of lns. Multpl dlmts btwn tokns wll b tatd as on. If flnumb s not spcfd thn fl numb zo (0) wll b usd. wt wt wt wt xpsson (xpsson) flnumb,xpsson (flnumb,xpsson) Wt th stng xpsson to a fl fl. Do not add an nd of ln o a dlmt. If flnumb s not spcfd thn fl numb zo (0) wll b usd. 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. Pag 264 Ths pogam uss a sngl txt fl to hlp us mantan a lst of ou fnd's tlphon numbs. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 # c17_phonlst.kbs # add a phon numb to th lst and show flnam$ = "c17_phonlst.txt" pnt "phonlst.kbs - Manag you do nput "Add, Lst, Qut (a/l/q)? f lft(low(acton$),1) = "a" addcod(flnam$) f lft(low(acton$),1) = "l" lstfl(flnam$) untl lft(low(acton$),1) = "q" nd phon lst." ",acton$ thn call thn call suboutn lstfl(f$) f xsts(f$) thn # lst th nams and phon numbs n th fl opn f$ pnt "th fl s " + sz + " byts long" whl not of # ad nxt ln fom fl and pnt t pnt adln nd whl clos ls pnt "No phons on fl. Add fst." nd f 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. 27 28 29 30 31 32 33 34 35 36 37 38 Pag 265 nd suboutn suboutn addcod(f$) nput "Nam to add? ", nam$ nput "Phon to add? ", phon$ opn f$ # sk to th nd of th fl sk sz() # w a at nd of fl - add nw ln wtln nam$ + ", " + phon$ clos nd suboutn Pogam 113: Bg Pogam - Phon Lst phonlst.kbs - Manag you phon lst. Add, Lst, Qut (a/l/q)? l th fl s 46 byts long jm, 555-5555 sam, 555-7777 doug, 555-3333 Add, Lst, Qut (a/l/q)? a Nam to add? ang Phon to add? 555-0987 Add, Lst, Qut (a/l/q)? l th fl s 61 byts long jm, 555-5555 sam, 555-7777 doug, 555-3333 ang, 555-0987 Add, Lst, Qut (a/l/q)? q Sampl Output 113: Bg Pogam - Phon Lst 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. Pag 266 Excss: s n p o t b n y f p x k k m s l o o s z t n w t t t l z t c s s m l k q f d s l t h l a o y j w s l a d d p c o f d n clos, dlmt, dctoy, of, xsts, fl, opn, ad, adln, st, sk, sz, tokn, wt, wtln wods 17.1. Cat a fl n th dctoy wh you sav you pogams namd numbs.txt. Opn t wth a txt dto, lk Notpad n Wndows o gedt n LINUX, and typ n a lst of dcmal numbs. Put ach on on a spaat ln. Now wt a pogam to ad th numbs fom th fl, on ln at a tm. Calculat th total of th numbs n th fl and th avag. Rmmb to us th float() functon to convt th stng you ad fom th fl to a numc valu bfo you add t to th unnng total. 17.2. Cat a fl n th dctoy wh you sav you pogams namd popl.txt. Opn t wth a txt dto, lk Notpad n 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. Pag 267 Wndows o gedt n LINUX, and typ n th data blow. Jm,M,47 May,F,23 Bob,M,67 John,M,13 Su,F,18 Wt a pogam that wll ad n th data fom th popl fl. Us stng handlng functons fom Chapt 16 to bak ach ln nto th pats: 1) nam, 2) gnd, and 3) ag. Tally th total of th ags, th numb of popl, and th numb of mals as you ad th fl. Onc you hav ad all of th cods dsplay th pcntag of mals and th avag ag of th popl n th fl. 17.3. Cat a fl n th dctoy wh you sav you pogams namd assgnmnts.txt. Opn t wth a txt dto, lk Notpad n Wndows o gedt n LINUX, and typ n th data blow. Jm,88,45 Jo,90,33 May,54,29 Mauy, 57,30 Wt a pogam that wll ad n th data fom th assgnmnts fl and wt out a nw fl namd fnalgad.txt wth th studnt's nam, a comma, and th cous gad. Calculat th cous gad fo ach studnt basd on th two assgnmnt gads. Th fst assgnmnt was woth 100 ponts and th scond assgnmnt was woth 50 ponts. Th output should look somthng lk: Jm,88 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)

Chapt 17: Fls Stong Infomaton Fo Lat. Pag 268 2014 Jams M. Rnau (CC BY-NC-SA 3.0 US)