Function return values, Simple types – HP SunSoft Pascal 4.0 User Manual

Page 225

Advertising
background image

The FORTRAN–Pascal Interface

201

8

Function Return Values

Function return values match types the same as with parameters, and they
pass in much the same way.

Simple Types

The simple types pass in a straightforward way, as in this example:

The commands to compile and
execute

PassPtr.f

and

PassPtrmain.p

hostname% f77 -c PassPtr.f

PassPtr.f:

passptr:

hostname% pc PassPtr.o PassPtrmain.p -lpfc -lF77

hostname% a.out

9 9.9

The FORTRAN function,

RetReal.f

double precision function retreal ( x )

retreal = x + 1.0

return

end

The Pascal main program,

RetRealmain.p

program retrealmain;

var

r, s: real;

function retreal(x: real): real; external fortran;

begin

r := 2.0;

s := retreal(r);

writeln(r: 4: 1, s: 4: 1)

end. { retrealmain }

Advertising