strange readln problem 
Author Message
 strange readln problem

I'm having problems with readln and i don't know what's causing it.

Basically, i have a menu, picking up the choices with readkey. When the
user presses the relevent key, it jumps to a procedure. Inside this
procuedure are many readln statements. First i output the text like
this;

Writeln('Please enter blah1 > ');
Writeln('Please enter blah2 > ');

Then i gotoxy to the end of each line and readln each one. But for some
reason, the first readln statement to pick the first user input up does
not work! It just jumps to the second readln for no reason, and nothing
is written into the blah1 space, it's just empty.

Any help is appriciated.

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 strange readln problem

Quote:

> I'm having problems with readln and i don't know what's causing it.

> Basically, i have a menu, picking up the choices with readkey. When
the
> user presses the relevent key, it jumps to a procedure. Inside this
> procuedure are many readln statements. First i output the text like
> this;

> Writeln('Please enter blah1 > ');
> Writeln('Please enter blah2 > ');

> Then i gotoxy to the end of each line and readln each one. But for
some
> reason, the first readln statement to pick the first user input up
does
> not work! It just jumps to the second readln for no reason, and
nothing
> is written into the blah1 space, it's just empty.

> Any help is appriciated.

It could be easier for us to help if you posted some more of your code.
I'm sure others will say this.

Quote:

> Sent via Deja.com http://www.deja.com/
> Before you buy.

--

Faculty Of Science, University Of Liverpool
http://www.liv.ac.uk

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 strange readln problem
|Basically, i have a menu, picking up the choices with readkey. When the
|user presses the relevent key, it jumps to a procedure. Inside this
|procuedure are many readln statements. First i output the text like
|this;

|Writeln('Please enter blah1 > ');
|Writeln('Please enter blah2 > ');

|Then i gotoxy to the end of each line and readln each one. But for some
|reason, the first readln statement to pick the first user input up does
|not work! It just jumps to the second readln for no reason, and nothing
|is written into the blah1 space, it's just empty.

Perhaps the user is pressing "enter" after the menu input, leaving a
"CR" in the input buffer.

In your procedure put the following before the first readln to clear
the buffer:

   while keypressed to readkey;

Phil



Wed, 18 Jun 1902 08:00:00 GMT  
 strange readln problem

Quote:
>I'm having problems with readln and i don't know what's causing it.

>Basically, i have a menu, picking up the choices with readkey. When
the
>user presses the relevent key, it jumps to a procedure. Inside this
>procuedure are many readln statements. First i output the text like
>this;

>Writeln('Please enter blah1 > ');
>Writeln('Please enter blah2 > ');

>Then i gotoxy to the end of each line and readln each one. But for
some
>reason, the first readln statement to pick the first user input up
does
>not work! It just jumps to the second readln for no reason, and
nothing
>is written into the blah1 space, it's just empty.

>Any help is appriciated.

The trouble lies somewhere between your menu and readln of blah1.  You
must have at least one Enter key stored in your keyboard buffer when
you enter the readln line.  Try emptying the buffer just prior the
readln.  But for real fix, check your code and try to understand where
the error really happens.

--
Raimo Suonio, Helsinki, Finland
http://www.dlc.fi/%7Eexp-1/suonio/
Oikeinkirjoitusohjeita news- ja web-kirjoittajille:
http://www.dlc.fi/%7Eexp-1/oikeinkirjoitus.html



Wed, 18 Jun 1902 08:00:00 GMT  
 strange readln problem
You have to ensure that no key are pressed before do any readkey or readln,
with something like this:

repeat c:=readkey until not(keypressed);

or

while keypressed do c:=readkey;

greetings

--
Jorge 8-)



Quote:
> I'm having problems with readln and i don't know what's causing it.

> Basically, i have a menu, picking up the choices with readkey. When the
> user presses the relevent key, it jumps to a procedure. Inside this
> procuedure are many readln statements. First i output the text like
> this;

> Writeln('Please enter blah1 > ');
> Writeln('Please enter blah2 > ');

> Then i gotoxy to the end of each line and readln each one. But for some
> reason, the first readln statement to pick the first user input up does
> not work! It just jumps to the second readln for no reason, and nothing
> is written into the blah1 space, it's just empty.

> Any help is appriciated.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 strange readln problem


Quote:
> But for real fix, check your code and try to understand where
> the error really happens.

I find the watch/step features of TP 5.5 very helpful for this kind of
debugging. I think it's the F7 key to step through line-by-line, and
Ctrl-F7 to add a watch to a variable.

Quote:

> --
> Raimo Suonio, Helsinki, Finland
> http://www.dlc.fi/%7Eexp-1/suonio/
> Oikeinkirjoitusohjeita news- ja web-kirjoittajille:
> http://www.dlc.fi/%7Eexp-1/oikeinkirjoitus.html

--

Faculty Of Science, University Of Liverpool
http://www.liv.ac.uk

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 strange readln problem

Quote:

>You have to ensure that no key are pressed before do any readkey or readln,
>with something like this:

>repeat c:=readkey until not(keypressed);

>or

>while keypressed do c:=readkey;

These are not the same thing. The first assumes that there is a
keystroke in the buffer.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. helpme with this readln problem!

2. about readln problem

3. Strange problem when running a report

4. Strange new problem

5. Strange RTE 103 problem

6. MS SQL Server Strange Problem

7. A strange problem.

8. Strange problem with TQuery !

9. Strange problem with QRCompositereport.

10. Strange problem with TQuery

11. Strange problem with cached updates

12. Strange RTE 103 problem

 

 
Powered by phpBB® Forum Software