pascal programming l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Pascal Programming PowerPoint Presentation
Download Presentation
Pascal Programming

Loading in 2 Seconds...

play fullscreen
1 / 7
filia

Pascal Programming - PowerPoint PPT Presentation

162 Views
Download Presentation
Pascal Programming
An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Pascal Programming Files and Text (an intro)

  2. Pascal Programming • Files . . . • Data files need to be retained in secondary memory. • The machine memory is random access (RAM) and volatile—it is erased by turning off the machine. • Secondary memory could be the hard disk drive, a removable disk or a R/W CD ROM.

  3. Pascal Programming • Thus, file can be defined as a collection of data, named and stored. • In DOS, the file naming convention is 8/3 or XXXXXXXX.XXX. • File being processed by Pascal have a name for storage and a file variable name. • A file variable must be declared.

  4. Pascal Programming • File variables . . . • . . .cannot be used in assignment statements. • . . .have predefined procedures for processing. • . . .have predefined syntax. • assign – the predefined procedure, calls the file. • Assign (File, ‘data.txt’) • This is the first step in working with a saved file.

  5. Pascal Programming • To read or write to a file, it must be opened. • assign (File, ‘data.txt’); • rewrite (File); • Write and writeln statements write to the file. • writeln (File, ‘new data’) • Remember, File is a file variable name and not a variable to be written out. • After use, files must be closed. • close (File) • To add to a file, append. • append (File)

  6. Pascal Programming • Printing . . . • Turbo Pascal writes to the printer like it writes to a file. • e g: • assign (File, ‘PRN’); • rewrite (file); • writeln (File, ‘data.txt’); • close (File);

  7. Pascal Programming • reset opens a file for reading. • assign (File, ‘data.txt’); • reset (File); • read and readln will read the content of the file. • The eof (end of file) function will allow a read statement to proceed to the end of the file. • eof (File)