Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Help it keeps skipping readln's

Help it keeps skipping readln's

Help it keeps skipping readln's

hello im writing a program and some of the time i have to put a second read or readln cause it skips the first one this is usually after i have wrote something with a writeln or write can anyone help me?

RE: Help it keeps skipping readln's

     The behavior you describe makes no sense.  Why don't you post an example of what's going on?

RE: Help it keeps skipping readln's

There is one (very obscure and unlikely) possibility that occurs to me. Writeln accepts a variable amount of parameters in its list of things to write, which are passed on the stack. If you in any way mess up the stack (usually by inline assembly or calling procedures via pointers when the procedures aren't what the compiler was expecting) then writeln will occasionally handle the newly-mangled stack with less than its usual correctness. That can lead to problems with readln, though usually the problem is that a subsequent readln produces a "file not open for reading" error even though you were trying to read from the keyboard.
Maybe someone else knows more about the details of this.

RE: Help it keeps skipping readln's

The read procedure is not intended to read from the console (screen), you should use readln in stead.
If you do something like the following, it goes wrong:

write('Enter your first name: ');
writeln('Your first name is: "',s,'"');
write('Enter your last name: ');
read(s); {This read is "skipped"}
writeln('Your last name is: "',s,'"');

The reason: readln waits until the return key is pressed before reading the console. Read on the other hand, doesn't wait and when there's nothing in the buffer, it returns an empty string.

Bert Vingerhoets
Don't worry what people think about you. They're too busy wondering what you think about them.

RE: Help it keeps skipping readln's

yes, everything I wrote applies only to readln. I have never used read.

RE: Help it keeps skipping readln's

thx guys i just replaced read with readlns and it works a treat now. Thx again

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close