Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Misc > Re: read shows ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 11 of 23 Topic 717 of 810
Post > Topic >>

Re: read shows surprising results

by CBFalconer <cbfalconer@[EMAIL PROTECTED] > Feb 16, 2007 at 10:52 AM

Dirk Weber wrote:
> 
> I do not really understand where the mistake is: In my understanding
> of the read statement or in the book I use for self studying Pascal.
> 
> Here the program listing
> ..........
> 
> program selbsttest_s_25;
> uses crt;
> 
> var
> z1,z2:char;
> n1,n2:integer;
> 
> const
> cz1='z1';
> cz2='z2';
> cn1='n1';
> cn2='n2';
> 
> BEGIN
> clrscr;
> 
> writeln('Cooper/Clancy, Pascal, Braunschweig 1991, p. 25, Selbsttest');
> 
> z1:=' ';
> z2:=' ';
> n1:=0;
> n2:=0;
> 
> writeln('Please enter 123 a45b');
> read(n1,z1,z2,n2);
> writeln(z1:5,z2:5,n1:5,n2:5);
> writeln;
> END.
> ................
> 
> My problem
> 
> According to Cooper/Clancy the variables should have the following
> contents:
> 
> z1: A blank
> z2: 'A'
> n1: 123
> n2: 45
> 
> I cmpiled the program with fpc, option was default, i. e. FreePascal
> dialect.
> 
> Running the program resulted in a runtime error.
> 
> The error message was:
> 
> Runtime error 106 at $08048199
>   $08048199 main , line 46 of selbsttest_s_25.pas
>   $0804809F
> 
> :-(
> 
> My system environment:
> 
> OpenSuSE 10.2
> 
> The program was compiled with help of the fp ide.
> 
> Now, why is there a runtime error?
> 
> If I understood right, what Cooper/Clancy wrote, the following should
have
> happened:
> 
> n1 reads 123, the integer is ended with the blank.
> z1 reads 'A'
> z2 reads '4'
> n2 reads 5, the integer is ended with the non numeric 'B'.

This sounds as if FPC has copied the (faulty) action of TPs read
function, as I mentioned earlier.  Once more, see my txtfiles
unit.  I don't know if it works under FP, because it depends on the
precise format of file control blocks and error exits in TP.

Your book is correct, at least in this matter.

-- 
 <http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
 <http://www.securityfocus.com/columnists/423>
 
 "A man who is right every time is not likely to do very much."
                           -- Francis Crick, co-discover of DNA
 "There is nothing more amazing than stupidity in action."
                                             -- Thomas Matthews
 




 23 Posts in Topic:
read shows surprising results
Dirk Weber <dirk-weber  2007-02-16 08:34:29 
Re: read shows surprising results
Wolf Behrenhoff <NoSpa  2007-02-16 12:20:28 
Re: read shows surprising results
Marco van de Voort <ma  2007-02-16 12:05:55 
Re: read shows surprising results
"Richard Engebretson  2007-02-16 05:55:58 
Re: read shows surprising results
dirk-weber@[EMAIL PROTECT  2007-02-17 07:12:00 
Re: read shows surprising results
Marco van de Voort <ma  2007-02-17 12:35:24 
Re: read shows surprising results
"Richard Engebretson  2007-02-17 05:00:23 
Re: read shows surprising results
CBFalconer <cbfalconer  2007-02-17 08:18:02 
Re: read shows surprising results
CBFalconer <cbfalconer  2007-02-17 09:26:48 
Re: read shows surprising results
dirk-weber@[EMAIL PROTECT  2007-02-18 11:00:00 
Re: read shows surprising results
CBFalconer <cbfalconer  2007-02-16 10:52:46 
Re: read shows surprising results
John Reagan <john.reag  2007-02-16 18:54:37 
Re: read shows surprising results
dirk-weber@[EMAIL PROTECT  2007-02-17 07:19:00 
Re: read shows surprising results
"Richard Engebretson  2007-02-16 13:10:03 
Re: read shows surprising results
"Richard Engebretson  2007-02-16 13:42:11 
Re: read shows surprising results
Waldek Hebisch <hebisc  2007-02-16 23:19:19 
Re: read shows surprising results
dirk-weber@[EMAIL PROTECT  2007-02-17 07:25:00 
Re: read shows surprising results
dirk-weber@[EMAIL PROTECT  2007-02-17 07:22:00 
Re: read shows surprising results
Marco van de Voort <ma  2007-02-17 12:29:16 
Re: read shows surprising results
dirk-weber@[EMAIL PROTECT  2007-02-17 07:04:00 
Re: read shows surprising results
dirk-weber@[EMAIL PROTECT  2007-02-17 07:17:00 
Re: read shows surprising results
dirk-weber@[EMAIL PROTECT  2007-02-18 11:02:00 
Re: read shows surprising results
CBFalconer <cbfalconer  2007-02-18 10:06:11 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 23 16:19:37 CDT 2008.