Posted by DelphiLand Team on August 14, 2004
In Reply to: Locating keypress posted by Joey p12386 on August 11, 2004 In a console application, Read(var) waits for the user typing a character on the keyboard. So you can code it as follows: var C: Char; .... begin ... // Program waits here until a key is pressed // the corresponding character is placed in C Read(C); // Do something depending on C : if C = 'a' then ... else if C = 'b' then ... else ... ... end; On the other hand, ReadLn(var) waits for the user typing a string and ending it with "ENTER", so for VAR you use a string variable. Example: var S: string; .... begin ... // Program waits here until ENTER key // is pressed ReadLn(S); // Do something with S : ... end; Regards, PS: From time to time, we process the forum messages and we replace the membership-id's with *DClub*, meaning "DelphiLand Club" :) Find related articles Suggested keywords: Related Articles and Replies
|
Compiling Console Applications Learn Pascal with simple Delphi Console Applications |