Script
A script is a program, written in a high-level language, which is part of a report. As the report runs, the script runs as well. A script can handle data in ways that are not possible just using the normal operations of the FastReport core; for example, a script can hide redundant data depending on a predefined condition. A script can also be used for controlling the properties of dialogue forms which are part of a report.
A script is written in one of the languages supported by the script engine (FastScript). These are: PascalScript, C++Script, BasicScript, and JScript.
We will write all example in PascalScript. When a new report is created this language is selected by default.
The following features are supported by the FastScript engine:
- standard language set: variables, constants, procedures, functions (which may be nested and having variables, constants, default parameters), all standard operators (including case, try, finally, except, with), types (integral, fractional, logical, character, line, multi-dimensional arrays, variant), classes (with methods, events, properties, indexes and default properties)
- type compatibility checking
- access to any of the report’s objects
FastScript, however does not support the following:
- declarations of these types : records, classes
- pointers, sets (but the 'IN' operator can be used in expressions such as "a in ['a'..'c','d']")
- shortstring type
- unconditional jumps (GOTO)
Scripts can be created in the FastReport designer, which contains a script editor.
Shortcut Keys
List of the shortcut keys which can be used in the script editor:
Key
|
Meaning
|
Cursor arrows
|
move cursor
|
PageUp, PageDown
|
go to previous/next page
|
Ctrl+PageUp
|
go to beginning of the text
|
Ctrl+PageDown
|
go to end of the text
|
Home
|
go to beginning of the line
|
End
|
go to end of the line
|
Enter
|
go to next line
|
Delete
|
delete symbol at cursor position; delete selected text
|
Backspace
|
delete symbol to the left of the cursor
|
Ctrl+Y
|
delete current line
|
Ctrl+Z
|
undo last action (up to 32 events)
|
Shift+Cursor arrows
|
select a text block
|
Ctrl+A
|
select whole text
|
Ctrl+U
|
shift selected block by 2 symbols to the left
|
Ctrl+I
|
shift selected block by 2 symbols to the right
|
Ctrl+C, Ctrl+Insert
|
copy selected block to the clipboard
|
Ctrl+V, Shift+Insert
|
paste text from the clipboard
|
Ctrl+X, Shift+Delete
|
cut selected block to the clipboard
|
Ctrl+F
|
search a line
|
Ctrl+R
|
replace a line
|
F3
|
repeated search/replacement from the cursor position
|
F9
|
run the script (Run)
|
Ctrl + Space
|
show list of methods and properties of object
|
Ctrl+Shift+Delete
|
delete word to right of cursor
|
Ctrl+Shift+Backspace
|
delete word to left of cursor
|
Structure of a Script
var // the “variables” chapter can be placed anywhere
i, j: Integer;
const // “constants” chapter
pi = 3.14159;
procedure p1; // procedures and functions
var
i: Integer;
procedure p2; // nested procedure
begin
end;
begin
end;
begin // main procedure.
end.