Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does it matter where in a unit I put the $R directive to include a resource?

Tags:

delphi

Take a look at this little snip:

implementation
{$R *.dfm}

Do I put my code above {$R *.dfm} or below it? Does it matter?
I can't find any confirmation on this question.
Is there a set standard on which to go about this or is it just up the designer?

like image 283
Sheep Avatar asked Dec 26 '22 02:12

Sheep


1 Answers

it does not matter but as a rule I put my code below, that compile switch actually links that pas file with a dfm file (pas+dfm = form!), here are some tips.

unit Unit1;

interface

uses
  ....

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
    local_var: String;
    function myFormFunction:String;
  end;

var
  Form1: TForm1;
  // global vars
  superVar: integer;

const
  // global constants
  MY_CONST = 'TEXT!!!';

implementation

{$R *.dfm}

{ TForm1 }
// YOUR CODE!
procedure aCoolFunction;
Begin
// your code
    inc(superVar);
End;

function TForm1.myFormFunction: String;
begin
// your code
  local_var := 'some '+ MY_CONST;
  inc(superVar);
end;

end.
like image 166
Givius Avatar answered May 19 '23 19:05

Givius