8

Pointers

Pointers are easy to pass, as shown in the following example:

The FORTRAN subroutine, PassPtr.f. In the FORTRAN subroutine, the name is converted to lowercase. Uppsercase is ignored.

The Pascal main program, PassPtrmain.p. In the Pascal program, where it calls the FORTRAN subroutine, the name must be in lowercase.

subroutine PassPtr ( iPtr, dPtr )

integer i double precision d

pointer ( iPtr, i ), ( dPtr, d )

i= 9

d = 9.9 return end

program PassPtrmain;

type

PtrInt = ^ integer; PtrReal = ^ real;

var

i:integer := 0;

r:real := 0.0; iP: PtrInt; rP: PtrReal;

procedure passptr(var xiP: PtrInt; var xrP: PtrReal); external fortran;

begin

iP := addr(i); rP := addr(r); passptr(iP, rP); writeln(i: 2, r: 4: 1)

end. { PassPtrmain }

200

Pascal 4.0 User’s Guide