Sections

An output into multiple files will be generated from a single driver:

However, only a single (active) file into which the generating action is currently underway will be selected each time. Section separating commands use for switching between the files. These commands are not influenced by a conditional translation. Section generating is optional; the source file can define only certain sections. If the given file cannot access a section, the output will be generated implicitly into the implementation section.

The process is case-sensitive.

Commands defining given sections (the section to end either with a command for switching into another section or file end):

%INITIALIZATION Generates output in the initialization file.
%ENABLE Generates output in the initialization file permitting peripheral and component functions.
%INTERFACE Generates output in the file interface.
%IMPLEMENTATION Generates output in the implementation file.
%INTERFACE <eventname> Interface of the event selected.
%IMPLEMENTATION <eventname> Implementation of the event selected.
%DEBUG Generates output in a special file <project>\Project_Settings\Component_DEBUG\<component-name>.dbg for debug purposes only. This file is generated only if Component Development option is selected. (see Window > Preferences > Processor Expert > Component Debug Verbose Mode )
%FILE[?][+]["fldr"][<dir>]<filename> Generates output into an external file with a specified name (implicitly into the project directory); the optional "?" parameter will cause the command to be ignored if a conditional translation has been disabled; the optional "+" parameter will cause the generated content to be added to the end of the project file (if one exists); for fldr parameter - for description see %FILE! Command; <dir> - an absolute or relative path with regards to the project directory, in Eclipse it is not allowed to generate file outside Eclipse workspace; the command can only be used within the component/CPU drivers, not for main, event, shared modules etc.; the name of the file to be generated must be unique within the project (a file cannot be generated from multiple components), it is possible to use macros to specify the filename.
%FILE[?]![<dir>]<filename> Denotes the file specified as a part of the application; it is expected that the file exists in the project directory and will not be generated, file addition can be conditioned by a conditional translation; the optional ? parameter will cause the command to be ignored if the conditional translation has been disabled; <dir> - see previous command for description.
%FILE[?]!"srcdir[;fldr]" [<dir>]<filename> Same as previous command, but the file (if not exist in the project) is copied from the srcdir (no macro allowed in this parameter, should be an absolute or relative path with regards to PE system directory, source file must be a plain file on the disk, encoded or packed files are not supported), optional obsolete fldr parameter (no macro allowed in this parameter) will determine into which folder the file is to be filed within project CW Classic (not supported in Eclipse). In case the file is not more generated, PE binary compares source file and project file, if the files are same, the file is removed from project, otherwise user is asked to keep the file as user file or remove from project.
%FILE[?]!~srcdir[;fldr]~ [<dir>]<filename> Same as previous, but macro symbols are replaced inside ~~ characters.
%FILE[?]$"srcdir" [<dir>]<filename> {deprecated}, replaced by %synchronizeStaticFile(), same as previous, but additionally the following rules are used to update project file if srcdir is changed compare to previous code generation (for example, changes in the file content are not detected):
  • If previous source file does not exist, the user is asked if the project file should be updated (for example, replaced by new source file).
  • If both source files are same: no action.
  • If the project file is same as previous source file, the project file is updated automatically.
  • Else user is informed, that user changes were detected in the project file and is asked if it shall be updated.
%FILE#SAVE <filename> Immediately save the file generated as %FILE on the disc, <filename> must be the name of the file generated by the %FILE command.
%USER_MODULE[!["fldr"]]<filename> Generates output into the user module generated; the optional exclamation mark behind the module means that the module will be generated at all times, if not, it will be removed from the project automatically by PE (otherwise, it is only added or enabled within the project and never removed), the optional fldr parameter: see the %FILE! command description.

The file name is either an absolute path or relative with respect to the generated code directory in PE-Delphi, to the user code directory in PE-Eclipse, the file extension to be in agreement with the one of the code or header file.

The command can be used within the component driver or from main, but not from CPU.

The name of the file to be generated must be unique within the project (a file cannot be generated from multiple components).

If the module exists, it will not be changed similarly as with other user modules.
%USER_MODULE[!~fldr~]<filename> Same as previous, but macro symbols are replaced inside ~~ characters.
%SUBROUTINE <subroutine> [(param1,param2,...)] Defines a sub-program, all subsequent lines will be considered as a sub-program code if not processes (they will be not generated on the output), up to the %SUBROUTINE_END command; <subroutine> identifies the sub-program (identifier), params are optional sub-program parameters, a comma-separated list of identifiers; for use of the sub-program, see the %inclSUB command; the sub-program will be valid until all files have been processed; maximum number of parameters = 16; the %ifdef command must not be used for parameter symbols as the symbol parameter value is defined at all times, which may also include an empty string.
%SUBROUTINE_END See the %SUBROUTINE command description; the output will be positioned back into the original section.
%createFileLink(src,dst) Creates link do destination file in the Eclipse project; src is full file name of the source file; dst is relative path and file name to project directory.
%createFileLink(%'Dir_PE'lib\PDD\PDD.c,PDD\PDD_Static.c)
%createFileLink(%'Dir_PE'lib\PDD\PDD.h,PDD\PDD_Static.h)
%synchronizeStaticFile(src,dst,[options]) Synchronizes static file in the project, if the file does not exists it is created, if the file exists it is updated if the src file was changed, if the command is no more generated, the file is removed from project.

src is full file name of the source file or relative file to Processor Expert directory (either system directory or user components directory).

dst is relative path and file name to project directory.

options is comma separated list of the following options in square brackets:
  • confirmation - any modification of the file requires user confirmation.
  • autoCreateNew - this option can be used together with confirmation option and creation of the file is not confirmed by the user.
  • notCreateNew - the file is not created. It is only updated if exists.
%synchronizeStaticFile(Beans\Comp\PDD.c,PDD\PDD.c,[confirmation] ) 
%synchronizeStaticFile(%'Dir_PE'lib\PDD\PD.h,PDD\PD.h,[confirmation,au toCreateNew])
%synchronizeStaticFile(%'Dir_PE'lib\doc\x.pdf,doc\x.pdf,[notCreateNew] )
  The command may be applied for the same project file if the source file is same. The options are merged with the following rules:
Requirement #1 Requirement #2 Result
Confirmation USED confirmation NOT USED Confirmation USED
autoCreateNewUSED autoCreateNewNOTUSED autoCreateNewNOTUSED
notCreateNew USED notCreateNewNOTUSED notCreateNew NOTUSED
%saveCurrentSectionAs(filename) Saves the current section into selected file; filename is full path file-name including extension; file path are create if not exist.
WARNING!: This command works only in component development mode and is designed for development and debugging.
%saveCurrentSectionAs(c:\temp\temp.txt)

For more details, see Component translation sequence, generating initialization topic.