If the EbsScript is evaluated at execution time, it would be rather slow. Therefore, a compiler is used that transforms your PASCAL script to machine code of the "Virtual Machine" (a software emulation of a real machine), which executes your script. The compiler is invoked automatically each time before an execution in the EbsScript Editorof the EbsScript Executor, if there is a change.
The EbsScript Compiler also especially strongly accelerates the display of the text fields, in which the EbsScripts are stored, because they do not have to be compiled again, each time the screen is refreshed.
In addition, you can start the compiler manually with the command menu "CompileràSyntactic analysis". This allows you to check the correctness of your syntax before you run your script.
The EbsScript compiler is a special PASCAL compiler, adapted to the requirements for using the PASCAL-compilers within Ebsilon. Therefore, there are several extensions for the language and several special functions, while the support for other rarely used constructs may be restricted.
The input for the EbsScript compiler is a script like this:
var
CoolantTemp : integer;
InletTemp : real;
OutletTemp : real;
deltaTemp : real;
counter : integer;
begin
counter := 0;
setParentProfileByName ("Variation_C");
for CoolantTemp := 60 to 85 step 5 do
begin
newSubProfile;
HeatConsumer_PrimaryCircuit.T2SET := CoolantTemp;
simulate;
InletTemp := last.CoolantInlet_Secondary.T;
OutletTemp := last.CoolantOutlet_Secondary.T;
deltaTemp := OutletTemp - InletTemp;
counter := counter + 1;
print ("Variation ", counter," :\n",
"The resulting power output ",
"with coolant inlet temperature of ",
last.CoolantInlet_Secondary.T, " \°C is: ",
last.GeneratorOutlet.Q, " kW. \n",
"Rise of coolant temperature is: ",
deltaTemp, " \°C.\n"
);
if CoolantTemp = 85.0 then
begin
print ("This is the end\n");
end;
end;
end.
If an error occurs at compilation time, an error message as shown below will appear and the script will not be executed.
This error message says that a ")" is missing in the line 19.
EbsScript options
All options have been collected under the menu point “Extras“
On the "Editor" tab you can make settings for outputting the EbsScript:
• Setting the font
• Displays with or without line numbers
Compiler Options can be adjusted with Extras àOptions..." in the tab "Syntax" (within).
This activates that the EbsScript Compiler generates an error message, if a program block is not ended with an "end" (PASCAL Standard). By default, the EbsScript Compiler accepts "end;" as well.
The option "Real number as result of integer divisions" regulates, whether a division of two integers returns an integer or a real number.
By default, the result of a division of two integers is an integer in PASCAL. Since this can easily lead to unexpected results, especially when using default fields, it is possible to set that the result of the division of two integers should be a real number.
This setting can also be done in General Settings\Sophisticated\EbsScript\. There, it is also possible to enable and disable warnings in case of an integer division. By default, the warnings are enabled.
Compiler directives
The settings of the EbsScript compiler that are selected under “Compiler“ --> “Options“-> Syntax can also be queried or changed for runtime. For this purpose there are the following compiler directives:
When this directive is set, the key word “result“ can be used as synonym for the function value, especially also on the right side of an allocation.
For these directives, the respective option is activated by the argument (+) and deactivated by the argument (-). By means of (show) you can query the current status (the output will then appear in the console window). By means of (push) and (pop), respectively, the current status is filed and restored, respectively. With empty (push) you can copy the current status.
For changing the context (e.g. for jumping to a macro context when compiling) there is the following directive:
Context-free compilation:
With the pragma
Note:
Real numbers as result of integer divisions
By default, the result of the division of two integers is an integer in PASCAL. Since this – especially when using the default fields – can easily lead to unexpected results, it is possible to set in the EbsScript-Editor under “Extras“à“Options”, “Syntax”, that the result of the division of two integers should be a real number.
This setting can also be done in the general settings under “Advanced”à “EbsScript”. Here, it is also possible to activate and deactivate the warnings in case of an integer division. By default, the warnings are activated.
The tab "Runtime" sets, whether a "Cancel" window is to be shown at run time, in order to be able to cancel the execution (whereby it is always possible to cancel with the ESC key, even when the "Cancel" window is not shown) and whether the profile set in the EbsScript (if it is changed at all) is to be retained when the EbsScript is ended, or whether the active profile is to be activated before the call.
Parsing digraphs
Digraphs are two characters in each case that are processed as a contiguous token.
Examples of this are ":=" (assignment) and "<=" (less than or equal to).
In earlier versions of Ebsilon, two matching characters were parsed as a digraph even if they were separated by so-called whitespaces (spaces, tabs, line breaks) or even comments.
This is not allowed in standard Pascal or Delphi, so the aim is to recognise digraphs in a future version of Ebsilon only if they are directly after each other.
To make the changeover easier, from Release 16 digraphs may only be separated from each other by whitespace (no more comments allowed in between). In addition, the digraph "::" MUST be written contiguously. This is necessary in order to be able to distinguish between the character strings "::˽:" and ":˽::".
Furthermore, in the EbsScript editor under "Extras->Options...->Syntax" there is the option to change the behaviour of the parser via the setting "Relaxed parsing of digraphs": If "Relaxed parsing of digraphs" is switched on, then whitespace may occur between the characters, otherwise not. The behaviour can also be changed via the ${RDP(+)} or ${RDP(-)} pragma in the source code.
Predefined Compiling Macros
Release 16 introduces compile-time macros. These are replaced by the respective constants during compilation, i.e. all values are determined at the time of compilation and do not change afterwards. The access syntax is:
$(Macroname)
The following predefined macros are available:
Macro |
Type |
Description |
$(file) |
string |
Name of the compiled file |
$(line) |
integer |
Current line number |
$(date) |
string |
Current date (for compilation!) |
$(time) |
string |
Current time(for compilation!) |
$(program) |
boolean |
Is the compiled code a main program? |
$(unit) |
boolean |
Is the compiled code a unit? |
$(subroutinename) |
string |
Name of the compiled function/procedure |
$(subroutinefullname) |
string |
Name of the compiled function/procedure with type description |
$(version) |
string |
Ebsilon Version (e.g. 16.1.0.30567) |
$(versionmajor) |
integer |
Ebsilon Release number (z.B. 16) |
$(versionpatch) |
integer |
Ebsilon Patch number (z.B. 1) |
$(versionhotfix) |
integer |
Ebsilon Hotfix number (z.B. 0) |
$(versionrevision) |
integer |
Ebsilon Revision number (z.B. 30567) |
$(counter) |
integer |
Counter: starts at 0 and increases by 1 with each call. Starts at 0 for each individual translation unit (program, unit) |