DataMuseum.dk

Presents historical artifacts from the history of:

CP/M

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about CP/M

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download

⟦c0d2077ca⟧ TextFile

    Length: 1040 (0x410)
    Types: TextFile
    Names: »PROCVAR.PAS«

Derivation

└─⟦505fbc898⟧ Bits:30002732 Turbo Pascal 5.0 for C-DOS Partner
    └─⟦this⟧ »DEMOS\PROCVAR.PAS« 

TextFile


æ Copyright (c) 1988 by Borland International, Inc. å

æ$F+å
program ProcVar;
æ For an extensive discussion of procedural types, variables and
  parameters, refer to Chapter 8 in the Turbo Pascal 5.0 Reference
  Guide (or Chapter 7 in the Turbo Pascal 5.0 Update manual).
å

type
  IntFuncType = function (x, y : integer) : integer; æ No func. identifier å

var
  IntFuncVar : IntFuncType;

procedure DoSomething(Func : IntFuncType; x, y : integer);
begin
  Writeln(Func(x, y):5);      æ call the function parameter å
end;

function AddEm(x, y : integer) : integer;
begin
  AddEm := x + y;
end;

function SubEm(x, y : integer) : integer;
begin
  SubEm := x - y;
end;

begin
  æ Directly: å
  DoSomething(AddEm, 1, 2);
  DoSomething(SubEm, 1, 2);

  æ Indirectly: å
  IntFuncVar := AddEm;              æ an assignment, not a call å
  DoSomething(IntFuncVar, 3, 4);    æ a call å
  IntFuncVar := SubEm;              æ an assignment, not a call å
  DoSomething(IntFuncVar, 3, 4);    æ a call å
end.
«eof»