Path: utzoo!mnetor!uunet!mcvax!botter!klipper!victor From: victor@cs.vu.nl (L. Victor Allis) Newsgroups: comp.lang.pascal Subject: Re: Sun Pascal bug? Message-ID: <996@klipper.cs.vu.nl> Date: 29 Feb 88 15:17:01 GMT References: <14411@oddjob.UChicago.EDU> Reply-To: victor@cs.vu.nl (Victor Allis) Organization: VU Informatica, Amsterdam Lines: 38 In article <14411@oddjob.UChicago.EDU> vinson@oddjob.uchicago.edu (Michael Vinson) writes: >The problem is as simple as it is absurd: when I try to >compile a program that read a string (i.e. a packed array of char) from >a text (yes text) file, the compiler tells me "Can't read strings from >a text file"!!! This is crazy. > >This is a pain in the *ss! Does anyone have any ideas/solutions/remedies? > >Michael Vinson In ISO-Pascal, reading a string is not possible. This is one of ISO-Pascal's bad sides (another one is the impossibility to work with random access files). Most commercial Pascal implementations I've seen provided extra string functions, but you must know that these are only extra's. So you better find yourself a Pascal implementation you like more, or you write a nice procedure ReadString, which does the thing you want, like: --------------- procedure ReadString(var f : text; var String : packed array[Low .. Up: integer] of char); var i : integer; begin for i := Low to Up do if not eoln(f) then read(f, String[i]) end; --------------- I did not test this (just wrote it as example). It should work on a Level 1 implementation of Pascal. Victor Allis. Vrije Universiteit van Amsterdam. The Netherlands.