Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!brl-adm!adm!Slomcenski.WBST@Xerox.COM From: Slomcenski.WBST@Xerox.COM Newsgroups: comp.lang.pascal Subject: Re: TURBO Pascal READ Message-ID: <7085@brl-adm.ARPA> Date: Fri, 24-Apr-87 09:02:59 EST Article-I.D.: brl-adm.7085 Posted: Fri Apr 24 09:02:59 1987 Date-Received: Sat, 25-Apr-87 11:59:34 EST Sender: news@brl-adm.ARPA Lines: 41 > >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. The catch is that the format of a real may (or may not) contain the scientific notation 'E+xx' or 'E-xx' following the digits. In the first case, readln interprets '12.34' as the real (the number terminates when TURBO finds any char that is not part of the real format, in this case ' '). In the second case, readln sees the scientific notation '12.34E' and expects the next char to be a '+', '-', or the digits indicating an exponent. When it encounters the 'T' -- it generates the 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. ~Bob