home *** CD-ROM | disk | FTP | other *** search
- PROGRAM FILEDEMO; {a demonstration of reading from the terminal,}
- {writing to a disk file, then reading the disk file to the screen.}
- VAR
- DISKFILE:TEXT;
- S1:STRING;
-
-
- BEGIN
- WRITELN('filedemo demonstration program');
- ASSIGN(DISKFILE,'file1'); {DISKFILE will have name 'file1'}
- REWRITE(DISKFILE); {set it up for writing}
- REPEAT
- WRITE('line:'); {prompt for user input}
- READLN(S1); {press F6 CR to enter an EOF}
- WRITELN(DISKFILE,S1); {write to disk file}
- UNTIL EOF(INPUT);
- WRITELN;
- RESET(DISKFILE); {now set up to read the disk file}
- WHILE NOT EOF(DISKFILE) DO
- BEGIN
- READLN(DISKFILE,S1);
- WRITELN(S1); {and copy it to the screen}
- END;
- WRITELN("that's all!");
- END.
-