Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!ptsfa!ihnp4!inuxc!iuvax!bobmon From: bobmon@iuvax.UUCP (Che' Flamingo) Newsgroups: comp.lang.pascal Subject: Re: TURBO Pascal READ Message-ID: <4062@iuvax.UUCP> Date: Sat, 25-Apr-87 20:33:23 EDT Article-I.D.: iuvax.4062 Posted: Sat Apr 25 20:33:23 1987 Date-Received: Sun, 26-Apr-87 22:34:03 EDT References: <7085@brl-adm.ARPA> Reply-To: bobmon@iuvax.UUCP (Che' Flamingo) Organization: Camo Flamingo Liberation Affront Lines: 43 Keywords: number formats read Summary: you must handle the separating blank explicitly Slomcenski.WBST@Xerox.COM writes: >> >>readln(r,a,b); >>writeln(r:8:3,a,b); > >>The input line contains a real number and two characters: >>12.34 ET >>The output is: >> 12.340 E >> >>an input of: >>12.34ET >>brings up an I/O error 10. > [...] > >>So I think there must be always a blank after a read of a number. >> > >Input of a number DOES NOT have to be followed by a ' '!! In fact, in the >first case, the blank is interpreted as the value for the char variable a. >The second case would have worked fine except that the char after the >digits happened to be 'E' which is STILL part of a real number representation. According to my v3.0 manual (p.109), With a numeric variable (Integer or Real), Read expects a string of characters which complies with the format of a numeric constant of the relevant type as defined on page 43. [ e.g., exponents -- RAM] Any blanks, TABs, CRs, or LFs preceding the string are skipped. The string must be no longer than 30 characters, **and it must be followed by a blank, a TAB, a CR, or a Ctrl-Z. If the string does not conform to the expected format, an I/O error occurs.** [emphasis is mine -- RAM] As far as I can see, you must either use a dummy variable to absorb the blank, or (if you know how long the number is and it's REALLY important) read the number as a character string and parse it yourself. Or terminate the number with a carriage-return. ~-~-~-~-~ RAMontante bobmon@iuvax.cs.indiana.edu -OR- {?}!iuvax!bobmon Computer Science Indiana University "Have you hugged ME today?"