Object pascal subset
HelpNDoc's scripting system is a subset of the Object Pascal language. In addition to usual object Pascal code, HelpNDoc provides an extensive set of API methods which can be used to automate multiple tasks from project creation to control how documentation is generated.
A typical script includes:
1. Variable and constant definitions
const
constant1 = 'Hello';
var
variable1, variable2: string;
var
variable3: integer;
2. Procedure and function definitions
procedure test1();
begin
variable1 := constant1 + ' World';
end;
function test2(): string;
begin
Result := constant1 + ' Universe';
end;
3. Main program code
begin
test1();
Print(variable1);
Print(test2());
end.
Learn more about HelpNDoc's script engine:
- Basic syntax and language elements : This section introduces the fundamental elements of the HelpNDoc scripting language
- Base types : Base types available in the HelpNDoc Object Pascal subset script engine
- Object type system : Object pascal's object-oriented programming features
- Built-in functions : Built-in functions of the HelpNDoc Object Pascal subset script engine
- HelpNDoc API methods : List of API methods available from the HelpNDoc Object Pascal subset script engine
Template specific code structure
Template script files usually include a mix of text (e.g. HTML) and Pascal code. To simplify this process and avoid having to use multiple print statements, template script files uses a convention similar to ASP.net or PHP code: everything not surrounded by <% and %> is treated as raw content and exported as-is. As an example:
<html>
<head>
<title><% print('Hello World');%></title>
</head>
<body>
<% for var i := 0 to 10 do begin %>
Hello <%= i %>
<% end; %>
</body>
</html>
Will output:
<html>
<head>
<title>Hello World</title>
</head>
<body>
Hello 0
Hello 1
Hello 2
Hello 3
Hello 4
Hello 5
Hello 6
Hello 7
Hello 8
Hello 9
Hello 10
</body>
</html>
Note: <%= 'Hello World' %> is the same as <% print('Hello World'); %>