Mega Code Archive

 
Categories / Delphi / Compiler Directives
 

$apptype - determines the application type gui or console

1 {$AppType GUI} 2 {$AppType CONSOLE} Description The $AppType compiler directive sets the application type. The default is for Graphical applications. When you create a Console application in Delphi, it automatically inserts a {$AppType CONSOLE} statement near the start, with no forms or other such clutter. A console application allows you to write/read to/from the console Input and Output files using Read, ReadLn, Write and WriteLn statements without the need to perform AssignFile, Reset or ReWrite operations. Nor do you have to specify the file names - as show in the example code. A GUI application does not need an $AppType statement - GUI is the default. Related commands ReadLn Read a complete line of data from a text file WriteLn Write a complete line of data to a text file Example code : A simple console application program Project1; {$AppType CONSOLE} uses SysUtils; var name : string; begin WriteLn('Please enter your name'); ReadLn(name); WriteLn('Your name is '+name); WriteLn(''); WriteLn('Press enter to exit'); ReadLn(name); end. Example console output : Please enter your name Joe Bloggs Your name is Joe Bloggs Press enter to exit