Chapter9 - Chapter 9 File Processing 1 Introduction All the...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Chapter 9 File Processing
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Introduction All the programs we have created so far store data temporarily. As soon as the program is closed, all its data is lost. Program data RAM volatile There is need for a permanent data storage mechanism that will preserve data even when the computer is turned off. Files Hard Disk, CD ROM non-volatile
Background image of page 2
3 File Processing A File is a block of memory which stores non-volatile data. File Input : Transferring data from an existing file into the program. File Output : Saving program output to a new or existing file.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 File Types Files are divided in two categories: binary files and text (ASCII or Unicode) files . These names (binary and text) refer to the way a file stores information. We will cover text files only. To understand the differences between these two file types, we need to talk about data types.
Background image of page 4
5 Binary Data Type Example Dim n As Integer n = 45 An integer occupies 4 bytes in memory. What is the binary value of n ? Answer: 0000 0000 0000 0000 0000 0000 0010 1101 Memory Location Memory Content (binary value) byte1 0000 0000 byte 2 0000 0000 byte 3 0000 0000 byte 4 0010 1101 2 5 2 3 2 2 2 0
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 ASCII Data Type Binary representation makes sense for numeric types but what about strings? How is a string, say “East #45” stored in memory? Strings are composed of characters such as ‘a’, ‘b’, ‘(‘, ‘?’, etc. E a s # 4 t 5
Background image of page 6
7 ASCII Characters Computer memory can hold only numbers. Every alphanumeric character has to be stored as a number (binary) in memory. This numeric code is called the ASCII value. ASCII values are stored in what is called the ASCII Character Set .
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 ASCII Character Set 30 40 50 60 70 80 90 100 110 120 0 NA ( 2 < F P Z d n x 1 NA ) 3 = G Q [ e o y 2 * 4 > H R \ f p z 3 ! + 5 ? I S ] g q { 4 , 6 @ J T ^ h r | 5 # - 7 A K U _ i s } 6 $ . 8 B L V ` j t ~ 7 % / 9 C M W a k u NA 8 & 0 : D N X b l v NA 9 ' 1 ; E O Y c m w NA
Background image of page 8
9 ASCII Strings Memory location Character ASCII value Memory content (binary value) byte 1 ‘E’ 69 0100 0101 byte 2 ‘a’ 97 0110 0001 byte 3 ‘s’ 115 0111 0011 byte 4 ‘t’ 116 0111 0100 byte 5 ‘ ‘ 32 0010 0000 byte 6 ‘#’ 35 0010 0011 byte 7 ‘4’ 52 0011 0100 byte 8 ‘5’ 53 0011 0101
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10 ASCII Files In an ASCII file, all data are treated as ASCII. This is true even for numbers such as 45 or 1.235. This is possible because the ASCII character set includes numeric characters ‘0’, ‘1’, ‘2’, etc., as well as letters and other symbols.
Background image of page 10
11 ASCII File Example ‘E’ ‘a’ ‘s’ ‘t’ ‘ ‘ ‘#’ ‘4’ ‘5’ CR LF ‘J’ ‘a’ ‘c’ ‘k’ ASCII 69 97 115 116 32 33 52 53 13 10 74 97 99 107 byte # 1 2 3 4 5 6 7 8 9 10 11 12 13 14 CR and LF stand for C arriage R eturn and L ine F eed. These are special control characters that indicate the end of the current line.
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
12 FacilityLocation FacilityLocation1 FacilityLocation2 FacilityLocation3
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 139

Chapter9 - Chapter 9 File Processing 1 Introduction All the...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online