Upload
omar-al-sabek
View
140
Download
0
Embed Size (px)
Citation preview
Pascal Programming Language
Omar ElSabek & Fayez GhazzawiIT Engineering3th year – UNKNOWN Department
programming II
Sets RecordFiles (Text & Binary)Pointers Linked Lists Unit
Course Index :
Files
Binary Files
Files
Two Types Of Files In Pascal:
1- Text Files2- Binary Files
Binary FilesConcepts
human unreadablenot editablefile content has a data typelike array of data on HD
Concepts in Pascal:Sequential (SE)
Introduction to DBMSopen before / close afterread OR writewrite = override
Binary FilesA binary file is a computer file which may contain any type of data, encoded in binary form for computer storage and processing purposes; for example, computer document files containing formatted text. Many binary file formats contain parts that can be interpreted as text; binary files that contain only textual data—without, for example, any formatting information—are called plain text files. In many cases, plain text files are considered to be different from binary files because binary files are made up of more than just plain text. When downloading, a completely functional program without any installer is also often called program binary, or binaries (as opposed to the source code).
from www.wikipedia.com
B-file:Definition and assign:
Defining Binary Files
Binary Files ExampleProgram test;TypeSTD = Record
Fname : string[20]; { 20 Byte}M : integer; { 2 Byte }State : Boolean; { 1 Byte }
End;Var
T,f : file of Std;VSTD : Std;
Writing Binary Files
Assign(f , “C:\STDfile”);Rewrite(f);For I:=1 to 100 doBegin
With VSTD doReadln ( fname , M , state);
Write (f , VSTD );End;Close(f);
Reading Binary Files
Reset( f );While not eof(f) doBegin
Read(f,vstd);With VSTD dowriteln ( fname , M , state);
End;Close( f );
Editing Binary FilesReset( f );Assign (T,’c:\temp’);Rewrite(T);While not eof(f) do Begin
Read (f , Vstd);VSTD := VSTD.M + 10 ;Write(T,VSTD);
End;Close(f);Close(T);
Editing Binary FilesReset( T );Rewrite (f);While not eof(T) doBegin
Read (T , VSTD);Write(f , VSTD);
End;Close (T);Close (f);Rewrite(T); Close(T);
We’re finished
for today !