A routine snippet, defines exactly one Pascal procedure or function. Methods are not permitted.
Each routine snippet begins with either the function or procedure keyword followed by a valid Pascal routine prototype (see below). No source code or comments may not preceed the function or procedure keywords. The following directives may be included in the prototype.
After the routine prototype there must be at least one space or newline before the routine's implementation. Private functions, procedures, type definitions, variables and constants are permitted.
A routine must be fully implemented in Pascal – it can't be simply a DLL import. Therefore the external and varargs directives are not supported.
Here's an example of a valid routine snippet:
function MyFunc(const Param1, Param2: string): string; stdcall; begin Result := Param1 + ' - ' + Param2; end;
Routine snippets may refer to other routines, simple type definitions, class & advanced record definitions or constants, providing they are defined in Delphi units or elsewhere in the database. The snippet's units and dependency references should indicate where to find referenced types, constants and routines. Routine snippets may not reference freeform or unit snippets.
It is important that the routine prototype is recognisable by CodeSnip because it must be able to extract the prototype for inclusion in a generated unit's interface section, amongst other things.
You may use overloaded routines by creating a separate routine snippet for each overloaded version of the routine. The overload directive must be used. While the name of the routines used in the source code must be the same for each overloaded routine, each snippet must be given a unique name for use by the database.