Computer Science Fundamentals (CS153 2003S)
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[EC]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Lab Writeups]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Experiments in Java]
[Scheme Reference]
[Scheme Report]
[CS153 2002S (Walker)]
[CS151 2003S (Rebelsky)]
[CS152 2000F (Rebelsky)]
[SamR]
Back to Program Input. On to Getting Started with Object-Oriented Programming.
Held: Friday, 7 March 2003
Summary: Today we consider how to make Scheme read values and characters from files and write values to other files.
Related Pages:
Due
Assignments:
Notes:
Overview:
anythingyou can do on the computer.
(open-input-file file-name).
(open-output-file file-name).
(read port)
(newline port)
(write value port)
(display value port)
(close-input-port port)
(close-output-port port)
(let* (; Prepare to read from a file
(source (open-input-file "data"))
; Read one value
(value (read source)))
; We're done, so clean up.
(close-input-port source)
; Return the value read
value)
read do when there's nothing left in the file?
It returns a special value (which DrScheme displays as
#<eof>).
eof-object?
(read-char port).
read procedure.
(peek-char port)
read-char encounters the end of the file, it returns
the same special value as read
Back to Program Input. On to Getting Started with Object-Oriented Programming.
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[EC]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Lab Writeups]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Experiments in Java]
[Scheme Reference]
[Scheme Report]
[CS153 2002S (Walker)]
[CS151 2003S (Rebelsky)]
[CS152 2000F (Rebelsky)]
[SamR]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Tue May 6 09:20:44 2003.
The source to the document was last modified on Thu Jan 16 15:16:13 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS153/2003S/Outlines/outline.28.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby