As for whether the directive affects the entire project, the whole block, one function and an area with a function that varies from directive to directive. You should read the documentation for each directive to find out what its scope is.
You ask if they should be placed right at the beginning of the device. You must consider the scope of this directive. Another piece of documentation talks about switch pointers:
Switch directives are global or local:
- Global directives affect the entire compilation and must be displayed before declaring a part of a program or a compiled device.
- Local directives affect only the compilation part, which extends from the directive to the next appearance of the same directive. They can appear anywhere.
However, consider the DENYPACKAGEUNIT directive (my attention):
The {$DENYPACKAGEUNIT ON} directive prevents the creation of a Delphi block from which it is placed in a package.
If this directive has a single scope, then it just needs to be present in the block in order to take effect.
Thus, it may matter where the directive is located. The bottom line is that for each directive you need to know its scope, and for this you must refer to the documentation for this directive.
Please note that you only need to set the directives in the code if you want to change the settings compared to the project settings. It is reasonable to set the parameters in the project parameters and not set them in the code.
What apparently happened in the code you submitted is that the author typed CTRL + O O , and the IDE inserted various parameters defined in the project parameters at this point in time.
source share