-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlightpi.lpr
More file actions
39 lines (27 loc) · 820 Bytes
/
lightpi.lpr
File metadata and controls
39 lines (27 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
program lightpi;
// this is the main "dummy" project to test development, the interpreter code is inside ulpi.pas
{$mode objfpc}{$H+}
uses SysUtils, ulpi;
var lpi: TLightPascalInterpreter;
begin
// see uconstants.pas for options, true enables debug output
lpi := TLightPascalInterpreter.Create(true);
lpi.Load(
'for i := 1 to 5 do ' +
'begin ' +
' b := b + a;' +
' if (b > 5) then' +
' writeln(i, '') b ('', b, '') is above 5!'')' +
' else' +
' writeln(i, '') b ('', b, '') is small.'');' +
'end;'
);
// inject a value
lpi.SetVariable('a', 2);
if not lpi.Execute then WriteLn('Errors occured!');
lpi.PrintMessages;
// access to results
writeln('b: ', lpi.GetVariable('b'));
readln;
FreeAndNil(lpi);
end.