There are two different cases.
If your project is a console project (New-> Simple Program) then the source editor opens the project's .lpr file (project1.lpr). You see:
program project1;
begin
end.
You have considerable freedom about where and in what order you place global variables and functions, but a typical 'template' would look like this:
program project1;
function Sum(aNum1, aNum2: integer): int64;
begin
Result:=aNum1 + aNum2;
end;
var
n1, n2: integer; // global variables go here
begin
n1:=374;
n2:=56;
Writeln('Total of ',n1,' + ',n2,' is ', Sum(n1, n2));
end.
If you are developing a GUI project (New->Application) then you are not shown the project's .lpr file, but the code for the first form unit:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs;
type
TForm1 = class(TForm)
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1; // this is a global variable created by Lazarus. You can add others here...
implementation
{$R *.lfm}
end.
You add global variables at the point indicated above, and global function headers would go in that region as well. The implementation of such functions is placed lower in the source code after the "implementation" keyword.
Functions that you want to be methods of TForm1 would be placed where the source editor has put the comments {private declarations} and {public declarations}.