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

Take a look at this little snip:

implementation {$R *.dfm} 

Am I putting my code above or below {$R *.dfm} ? Does it matter?
I can not find confirmation on this issue.
Is there an established standard by which to circumvent this, or is it just a designer?

+4
source share
2 answers

it doesn’t matter, but as a rule, I put my code below, this compiler actually switches the link to the pas file with the 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. 
+5
source

Irrelevant. The code and resources do not affect each other (unless you are trying to load a resource that does not exist, but this is a completely different problem). Having said that, I prefer to have all the options at the top.

+5
source

Source: https://habr.com/ru/post/1484331/


All Articles