Description |
The Program keyword defines the start of an application.
The Code is executed after running the initialisation sections of all the units referenced in the Uses section of the code block.
When the Code completes, the finalisation sections of the units are run in reverse order.
Parameters passed to the program are not defined in the Program statement - it is up to your code to handle them using such functions as ParamStr.
|
|
Related commands |
$AppType |
|
Determines the application type : GUI or Console |
CmdLine |
|
Holds the execution text used to start the current program |
ParamCount |
|
Gives the number of parameters passed to the current program |
ParamStr |
|
Returns one of the parameters used to run the current program |
Unit |
|
Defines the start of a unit file - a Delphi module |
Uses |
|
Declares a list of Units to be imported |
|
|
|
Example code : A 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 code : The project part of a GUI application |
Program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
|
|
|