Delphi Ders11 Aslı Ergün.

Slides:



Advertisements
Similar presentations
Files Used to transfer data to and from disk. Opening an Output File Stream #include // File stream library. ofstream outfile;// Declare file stream variable.
Advertisements

1 Doğrudan Erişimli Dosya class Dosya { RandomAccessFile personnelFile; DataInputStream dataIn; int outputBufLength = 200; byte outputBuf[] = new byte[outputBufLength];
Naredba If..Then..Else... Procedure TForm1.Button1Click ( SEnder: Tobject ); Var x, y, Max : Integer; Begin x := StrToInt ( Edit1.Text ); y := StrToInt.
IDL Tutorials : Day 5 Michael Hahn
L which include file needs to be used for string manipulation? what using statement needs to be included fro string manipulation? l how is a string assigned.
Files in C Rohit Khokher. Files in C Real life situations involve large volume of data and in such cases, the console oriented I/O operations pose two.
An Introduction to Hashing. By: Sara Kennedy Presented: November 1, 2002.
1 PHP Statement Constructs Server Scripting. 5-2 Basic Statement All Statements end in a semicolon. Statements are delimited from the HTML code by enclosing.
Translating Pseudocode into computer languages Lecture 14.
Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates.
Delphi Jon Krueger Matt Merkel Jack Neil. Overview Paradigm and problem domains Language concepts Sample code The history of Delphi Language Comparison.
1 CS 3870/CS 5870: Note 07 Lab 3 Lab 4 Test 1: Two Tables.
Logic (continuation) Boolean Logic and Bit Operations.
Sha Tin Methodist College F.4 Computer Studies Pascal Programming.
ISM 2110 Programming for Business Applications Lecture 2 - Section 2 Delphi and Object Pascal Basic By Tony Chun-Kuen WONG Tutorial after 12/09/2002.
Language Find the latest version of this document at
Higher Computing Science 2016 Prelim Revision. Topics to revise Computational Constructs parameter passing (value and reference, formal and actual) sub-programs/routines,
Custom Functions © Copyright 2014, Fred McClurg All Rights Reserved.
SQL. Originally developed by IBM Standardized in 80’s by ANSI and ISO Language to access relational database and English-like non-procedural Predominant.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
Input, Output and Variables GCSE Computer Science – Python.
VISUAL BASIC 6.0 Designed by Mrinal Kanti Nath.
Unit 2 Technology Systems
Information and Computer Sciences University of Hawaii, Manoa
Visual Basic 6.0 Final Review
Variables Variables are used to store data or information.
Programming constructs
Module 5 Working with Data
CS Computer Science IA: Procedural Programming
JavaScript.
Lecture 25 The Tao that can be talked about is not the true Tao
What is a File? A file is a collection on information, usually stored on a computer’s disk. Information can be saved to files and then later reused.
C++, OBJECT ORIENTED PROGRAMMING
CPSC Pascal Brent M. Dingle Texas A&M University 2001, 2002
Indexer AKEEL AHMED.
CSC115 Introduction to Computer Programming
FILE INPUT OUTPUT Skill Area 315 Part B Materials Prepared by
Files and Streams Lect3 CT1411.
Introduction to Python
البرمجة بلغة فيجول بيسيك
Paskal Dil Karşılaştırması
Паскаль тілінде бағдарламалау II Бөлім
مراحل كتابة البرنامج بلغة فيجول بيسك ستديو
File class File myFile=new File(“c:/javaDemo/aa
Chapter 7: Strings and Characters
C Stuff CS 2308.
Dosyalar.
Introduction to Python
Topics Introduction to File Input and Output
Chapter 7 Files and Exceptions
البرمجة بلغة الفيجول بيسك ستوديو
البرمجة بلغة فيجول بيسك ستوديو
Handles disk file 0000: array of file-offsets 0001: 0002: 0003: 0: …
kbkjlj/m/lkiubljj'pl;
Fundamentals of Data Structures
I210 review.
BTEC COMPUTING – UNIT 1 SECTION B - FLOWCHARTS
University of Kurdistan
Variables and Expressions
Variables Kevin Harville.
Variables In today’s lesson we will look at: what a variable is
Introduction to Programming
CMPE 152: Compiler Design February 21 Class Meeting
Java: Variables, Input and Arrays
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Just Basic Lessons Mr. Kalmes.
Topics Introduction to File Input and Output
Сабақтың тақырыбы: Мәлімет типтері. Шамалардың сипатталуы
Lecture 9: JavaScript Syntax
Array Fundamentals A simple example program will serve to introduce arrays. This program, REPLAY, creates an array of four integers representing the ages.
Presentation transcript:

Delphi Ders11 Aslı Ergün

Text Dosyalara Yazmak Uses FileCtrl ; procedure NewTxt; var f: Textfile; myFile : TextFile; text : string; begin assignfile(myFile, ‘c:\Test.txt'); ReWrite(myFile); WriteLn(myFile, 'Delphi Text dosyası Ornek Satır-1'); // Close the file CloseFile(myFile); end; procedure TForm15.Button1Click(Sender: TObject); NewTxt();

Text Dosyadan Okuma procedure ReadTxt; var myFile: Textfile; str: string; begin AssignFile(myFile, ‘d:\Test.txt’); {Dosya atandı} Reset(myFile); {Dosyayı okuma amaçlı açtı} Readln(myFile, str); ShowMessage(‘Text dosyasının ilk satırı:’ + str); Closefile(myFile); {myFile dosyasını kapat} end;

Dosya Sonuna Kadar Okumak while not Eof(myFile) do begin Readln(myFile, str); ShowMessage(str); end;

Text Dosyaya Ekleme procedure AddTxt; var myFile : Textfile; begin AssignFile(myFile , ‘d:\Test.txt’); {Dosya atandı} Append(myFile); {Dosyayı düzenleme amaçlı açtı} Writeln(myFile, ‘Delphi dpsya satır ekleme örneği…’); Closefile(myFile); {myFile dosyası kapatıldı} end;

Binary Dosyaya Yazma type TMember = record Name : string[50]; eMail : string[30]; Posts : LongInt; end; var Members : array[1..50] of TMember; var F : file of TMember; AssignFile(F, 'Members.dat') begin AssignFile(F,'members.dat'); Rewrite(F); try for i:= 1 to 50 do Write (F, Members[i]); finally CloseFile(F);

Binary Dosyadan Okuma type TMember = record Name : string[50]; eMail : string[30]; Posts : LongInt; end; var Member: TMember F : file of TMember; begin AssignFile(F,'members.dat'); Reset(F); try while not Eof(F) do begin Read (F, Member); finally CloseFile(F);

Binary Dosyadan Arama {go back to the beginning - the first record} Seek(F, 0); {go to the 5-th record} Seek(F, 5); {Jump to the end - "after" the last record} Seek(F, FileSize(F)); procedure ChangeEMail (const RecN : integer; const NewEMail : string); var DummyMember : TMember; begin {assign, open, exception handling block} Seek(F, RecN); Read(F, DummyMember); DummyMember.Email := NewEMail; {read moves to the next record, we have to go back to the original record, then write} Write(F, DummyMember); {close file} end;

Binary Dosya Yazma- ornek2 type TCustomer = Record name : string[20]; age : Integer; male : Boolean; end; var myFile : File of TCustomer; // A file of customer records customer : TCustomer; // A customer record variable begin // Try to open the Test.cus binary file for writing to AssignFile(myFile, 'Test.cus'); ReWrite(myFile); // Write a couple of customer records to the file customer.name := 'Fred Bloggs'; customer.age := 21; customer.male := true; Write(myFile, customer); customer.name := 'Jane Turner'; customer.age := 45; customer.male := false; // Close the file CloseFile(myFile);

Binary Dosyadan Okuma- ornek2 FileMode := fmOpenRead; Reset(myFile); // Display the file contents while not Eof(myFile) do begin Read(myFile, customer); if customer.male then ShowMessage('Man with name '+customer.name+ ' is '+IntToStr(customer.age)) else ShowMessage('Lady with name '+customer.name+ ' is '+IntToStr(customer.age)); end; // Close the file for the last time CloseFile(myFile);

Stream’a Yazma type Scores = record name: string[50]; score: integer; end; var rank: array[1..3] of scores; procedure WriteScores(var Buf; Count: Integer); var Stream: TStream; begin Stream:= TFileStream.Create('test.dat', fmCreate); try Stream.WriteBuffer(Buf, SizeOf(Scores) * Count); finally Stream.Free;

Stream’den Okuma procedure ReadScore(var Buf; Index: Integer); var Stream: TStream; begin Stream:= TFileStream.Create('test.dat', fmOpenRead or fmShareDenyWrite); try Stream.Position:= Index * SizeOf(Scores); Stream.ReadBuffer(Buf, SizeOf(Scores)); finally Stream.Free; end;