Procedures in Delphi
A procedure reports one hive inspection, and the main block only calls it.
program ProceduresBasics;
// A procedure does work and answers nothing; call it as a statement.
procedure InspectHive(Number: Integer; const Queen: string);
begin
WriteLn('Hive ', Number, ': queen ', Queen);
end;
// One procedure may call another, so the main block stays short.
procedure InspectApiary;
begin
InspectHive(1, 'Hazel');
InspectHive(2, 'Juniper');
end;
begin
InspectApiary;
end.
How it works
procedure InspectHive(Number: Integer; const Queen: string);takes two parameters.- Its body is a single
WriteLn, and the procedure answers with nothing. InspectApiarycallsInspectHivetwice, so the main block is one statement.
Keywords and builtins used here
InspectApiaryInspectHiveIntegerWriteLnbeginconstendprocedureprogramstring
The run, in numbers
- Lines
- 18
- Characters to type
- 395
- Tokens
- 65
- Three-star pace
- 80 tpm
At the three-star pace of 80 tokens a minute, this run takes about 49 seconds.
Step 1 of 3 in Procedures & functions, step 10 of 27 in Language basics.