source: branches/xpascal/Examples/Example.pas

Last change on this file was 236, checked in by chronos, 17 months ago
  • Fixed: Var function parameters processed correctly for both user defined and internal functions.
File size: 1.3 KB
Line 
1// Line comment
2program Test;
3var
4 A: string;
5 B: string;
6 X: string;
7 I: Integer;
8const
9 C: Integer = 1;
10
11function IsZero(A: Integer): Boolean;
12begin
13 Result := A = 0;
14end;
15
16procedure Print(Text: string);
17begin
18 WriteLn(Text);
19end;
20
21procedure SetText(var Text: string, NewText: string);
22begin
23 Text := NewText;
24end;
25
26begin
27 Print('Test');
28
29 WriteLn('10 * 3 = ' + IntToStr((1 + 2) * (3 + 4)));
30
31 X := 'A' + 'B';
32 WriteLn(X);
33 A := IntToStr(2);
34 B := IntToStr(C);
35 A := B;
36
37 // If-Then-Else
38 if A = '2' then begin
39 WriteLn('DoThen');
40 end else WriteLn('DoElse');
41
42 if IsZero(1) then begin
43 WriteLn('Is really zero');
44 end;
45 WriteLn(BoolToStr(IsZero(0)));
46 WriteLn(BoolToStr(IsZero(1)));
47
48 // While-Do
49 WriteLn('WhileDo');
50 I := 5;
51 while I <> 0 do begin
52 WriteLn(IntToStr(I));
53 I := I - 1;
54 end;
55
56 // Repeat-Until
57 I := 5;
58 WriteLn('RepeatUntil');
59 repeat
60 WriteLn(IntToStr(I));
61 I := I - 1;
62 until I = 0;
63
64 // For-To-Do
65 WriteLn('ForToDo');
66 for I := 0 to 5 do begin
67 WriteLn(IntToStr(I));
68 end;
69
70 // Begin-End
71 begin
72 WriteLn('Hello World!');
73 WriteLn('Can''t believe this.');
74 end;
75 WriteLn('');
76 WriteLn('Test');
77 WriteLn(A);
78
79 SetText(A, 'New text');
80 WriteLn('New text: ' + A);
81
82 WriteLn('What is your name?');
83 ReadLn(A);
84 WriteLn('Your name: ' + A);
85end.
Note: See TracBrowser for help on using the repository browser.