Pointers – HP SunSoft Pascal 4.0 User Manual

Page 207

Advertising
background image

The FORTRAN–Pascal Interface

183

8

Pointers

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

Pascal procedure,

ChrCAx.p

procedure chrca_ ( a: array [lb..ub:integer] of char) ;

begin

a[0] := 'T' ;

a[13] := 'o' ;

end; { chrca_ }

The FORTRAN main program,

ChrCAmain.f

character s*16

data s / "this is a string" /

call ChrCA( s, %VAL(0), %VAL(15) )

write( *, "(A)" ) s

stop

end

The commands to compile and
execute

ChrCAx.p

and

ChrCAmain.f

hostname% pc -c ChrCAx.p

hostname% f77 ChrCAx.o ChrCAmain.f -lpfc -lpc

ChrCAmain.f:

MAIN:

hostname% a.out

This is a string

The Pascal procedure,

PassPtr.p

. In the Pascal

procedure statement, the name
must be all in lowercase, with a
trailing underscore (_).

type

PtrInt = ^integer ;

PtrReal = ^real ;

procedure passptr_ ( var iPtr: PtrInt ;

var dPtr: PtrReal ) ;

begin

iPtr^ := 9 ;

dPtr^ := 9.9 ;

end ;

Advertising