Add record type example, and remove cruft from the first example
This commit is contained in:
parent
b394bbe7dd
commit
36bc2ceed9
39
simple_examples/countries.pas
Normal file
39
simple_examples/countries.pas
Normal file
@ -0,0 +1,39 @@
|
||||
program countries;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses strutils;
|
||||
|
||||
type
|
||||
TCountry = record
|
||||
Name: string;
|
||||
Area: LongInt;
|
||||
end;
|
||||
|
||||
const
|
||||
Belgium: TCountry = (Name: 'Belgium'; Area: 30513);
|
||||
Austria: TCountry = (Name: 'Austria'; Area: 83851);
|
||||
finland: TCountry = (Name: 'Finland'; Area: 337032);
|
||||
Germany: TCountry = (Name: 'Germany'; Area: 356734);
|
||||
|
||||
procedure DisplayInfo(aCountry: TCountry);
|
||||
var barLength: integer;
|
||||
begin
|
||||
with aCountry do
|
||||
begin
|
||||
barLength := Area div 30000;
|
||||
WriteLn(Name:8, Area:7, ' ', DupeString('*', barLength));
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
WriteLn(' Country Area Relative area');
|
||||
WriteLn(' ------- ------ -------------');
|
||||
DisplayInfo(Belgium);
|
||||
DisplayInfo(Austria);
|
||||
DisplayInfo(finland);
|
||||
DisplayInfo(Germany);
|
||||
{$IFDEF WINDOWS}
|
||||
ReadLn;
|
||||
{$ENDIF}
|
||||
end.
|
@ -2,13 +2,6 @@ program firstproject;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Classes
|
||||
{ you can add units after this };
|
||||
|
||||
begin
|
||||
writeln('A Free Pascal progam');
|
||||
{$IFDEF WINDOWS}
|
||||
|
Loading…
Reference in New Issue
Block a user