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 ;
Содержание SunSoft Pascal 4.0
Страница 14: ...xiv Pascal 4 0 User s Guide ...
Страница 16: ...xvi Pascal 4 0 User s Guide ...
Страница 30: ...6 Pascal 4 0 User s Guide 1 ...
Страница 160: ...136 Pascal 4 0 User s Guide 6 ...
Страница 268: ...244 Pascal 4 0 User s Guide 11 ...
Страница 320: ...296 Pascal 4 0 User s Guide B ...
Страница 331: ...Index 307 ...
Страница 333: ......