Board index » delphi » Answering a Question by Pressing the Enter Key
Tiziano Bianchi
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
Tiziano Bianchi
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Answering a Question by Pressing the Enter KeyAssuming that I have a declaration as follows in my program: and that somewhere else in the same program I have the following: If I answer to the above question by just pressing the Enter key (without entering anything else first), the program Is there a way to avoid having to press the Enter key twice? Thanks for your replies. Tiziano Bianchi |
Will
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Answering a Question by Pressing the Enter KeyQuoteTiziano Bianchi wrote: for the 'Y' or 'N' character and not the whole word (your variable _is_ just a char), just use the ReadKey function instead of ReadLn. To make the comparison easier, also use UpCase. ReadKey will pause and wait for exactly one keypress, at which time it will return with that key's value (extended keys actually return two 'keypresses'; a #0 followed by the extended key code). Here is how you should rewrite it: write("Enter "Y" for Yes, or "N" for No: '); Of course, it may be more conveniant to use a Case statement. You Will <lib...@ix.netcom.com> |
R. E. Donai
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Answering a Question by Pressing the Enter KeyQuoteIn article <4rifvb$...@news.utdallas.edu> Tiziano Bianchi wrote: But it's nothing I'll ever lose any sleep over, so I probably will never know the forces at work here. You might try using the ReadKey function in the CRT Unit. It has -- |
Ronn
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Answering a Question by Pressing the Enter KeyQuoteWill wrote: Write('Y or N '); Hope that helps. Scan codes are neat-o! |
paul
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Answering a Question by Pressing the Enter Key
> Assuming that I have a declaration as follows in my program: > and that somewhere else in the same program I have the following: > If I answer to the above question by just pressing the Enter key (without entering anything else first), the program > Is there a way to avoid having to press the Enter key twice? > Thanks for your replies. > Tiziano Bianchi
[
key.txt < 1K ] |
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Answering a Question by Pressing the Enter Key |
JWillard
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Answering a Question by Pressing the Enter KeyQuoteTiziano Bianchi <tizi...@utdallas.edu> writes: Char. When user responds by hitting the Enter key, the compiler will return a null string. |
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Answering a Question by Pressing the Enter Key |
Valt
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Answering a Question by Pressing the Enter KeyQuoteRonn <ronca...@netvoyage.net> wrote: generates a different scan code than y does.... |
Christiaan Heidem
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Answering a Question by Pressing the Enter KeyQuoteTiziano Bianchi <tizi...@utdallas.edu> wrote: Uses Crt; Var If Answer = 'Y' Then I hope this solution will help you, Christiaan Heidema |
The Fowler Fami
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Answering a Question by Pressing the Enter KeyIn article <4rjhgc$...@news-e2b.gnn.com>, R. E. Donais (RDon...@gnn.com) writes: Quote
you see in this sketch I actually enter a string and then do two checks. 1. For a nul string because only Enter has been pressed. Program prototype_readln_integer_entry_check; Uses crt; Var Label again; Begin If Length (entry_s) = 0 Then { 1. Test for no entry } Else Else WriteLn; Hope it helps. Albert L. Fowler. |
Osmo Ronkan
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Answering a Question by Pressing the Enter KeyIn article <4rifvb$...@news.utdallas.edu>, Quote>Assuming that I have a declaration as follows in my program: Osmo |
Osmo Ronkan
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Answering a Question by Pressing the Enter KeyQuoteIn article <31DD2638.1...@netvoyage.net>, Ronn <ronca...@netvoyage.net> wrote: It would be just the same as if you replaced #121 with 'y' and #110 with 'n'. The only difference is that your code is harder to read. If you want to make the code hard to read then why not go all the way and use goto :-) The readkey does not return scancodes for keys that have an ASCII Quote>Hope that helps. Scan codes are neat-o! |
1. Simulate tab Key when Enter Key Pressed
2. How can I kill a key press stone dead (Enter Key)
3. converting enter key press to a tab keypress
5. Why a Beep when Enter key is pressed?
6. Why doesn't pressing Enter key visibly depress button
7. Beep when press Enter key. HELP
8. Changing focus on pressing the enter key