The univ arrays – HP SunSoft Pascal 4.0 User Manual

Page 196

Advertising
background image

172

Pascal 4.0 User’s Guide

8

The

univ

Arrays

You can pass any size array to a Pascal procedure expecting a

univ

array, but

there is no advantage in doing so, since there is no type or size checking for
separate compilations. However, if you want to use an existing Pascal
procedure that has a

univ

array, you can do so. All

univ

arrays that are

in

,

out

,

in out,

or

var

parameters pass by reference.

The commands to compile and
execute

FixVec.p

and

FixVecmain.f

hostname% pc -c FixVec.p

hostname% f77 FixVec.o FixVecmain.f -lpfc -lpc

hostname% a.out

FixVecmain.f:

MAIN:

45

The Pascal procedure,

UniVec.p

, which defines a 10-

element array

type

VecTyp = array [0..9] of integer;

procedure univec_(in V:univ VecTyp; var Last: integer;

var Total: integer);

var

i: integer;

begin

Total := 0;

for i := 0 to Last do

Total := Total + V[i]

end; { univec_ }

The FORTRAN main program,

UniVecmain.f

, which passes

a 3-element array to the Pascal
procedure written to do a 10-
element array

integer Sum

integer a(0:2)

data a / 7, 8, 9 /

call UniVec ( a, 2, Sum )

write( *, "( I3 )") Sum

stop

end

Advertising