DelphiBasics
Program
Keyword
Defines the start of an application System unit
 keyword Program(Program Name;
  ... Code ...
 end.
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
$AppTypeDetermines the application type : GUI or Console
CmdLineHolds the execution text used to start the current program
ParamCountGives the number of parameters passed to the current program
ParamStrReturns one of the parameters used to run the current program
UnitDefines the start of a unit file - a Delphi module
UsesDeclares a list of Units to be imported
 Download this web site as a Windows program.




 
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.
  
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page