~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to docs/refex/ex80.pp

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Program example80;
2
 
 
3
 
{ Example to demonstrate the High and Low functions. }
4
 
 
5
 
Type TEnum = ( North, East, South, West );
6
 
     TRange = 14..55;
7
 
     TArray = Array [2..10] of Longint;
8
 
 
9
 
Function Average (Row : Array of Longint) : Real;
10
 
 
11
 
Var I : longint;
12
 
    Temp : Real;
13
 
 
14
 
 
15
 
begin
16
 
  Temp := Row[0];
17
 
  For I := 1 to High(Row) do
18
 
     Temp := Temp + Row[i];
19
 
  Average := Temp / (High(Row)+1);
20
 
end;
21
 
 
22
 
Var A : TEnum;
23
 
    B : TRange;
24
 
    C : TArray;
25
 
    I : longint;
26
 
 
27
 
begin
28
 
  Writeln ('TEnum  goes from : ',Ord(Low(TEnum)),' to ', Ord(high(TEnum)),'.');
29
 
  Writeln ('A      goes from : ',Ord(Low(A)),' to ', Ord(high(A)),'.');
30
 
  Writeln ('TRange goes from : ',Ord(Low(TRange)),' to ', Ord(high(TRange)),'.');
31
 
  Writeln ('B      goes from : ',Ord(Low(B)),' to ', Ord(high(B)),'.');
32
 
  Writeln ('TArray index goes from : ',Ord(Low(TArray)),' to ', Ord(high(TArray)),'.');
33
 
  Writeln ('C index      goes from : ',Low(C),' to ', high(C),'.');
34
 
  For I:=Low(C) to High(C) do
35
 
    C[i]:=I;
36
 
  Writeln ('Average :',Average(c));
37
 
  Write ('Type of return value is always same as type of argument:');
38
 
  Writeln(high(high(word)));
39
 
end.
40
 
 
 
 
b'\\ No newline at end of file'