The univ arrays – HP SunSoft Pascal 4.0 User Manual
Page 124

100
Pascal 4.0 User’s Guide
6
The
univ
Arrays
You can pass any size array to a Pascal procedure expecting a
univ
array,
although there is no special gain in doing so, because 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 Pascal procedure,
UniVec.p
, which defines a 10-
element array
type
TVec = array [0..9] of integer;
procedure UniVec(
var V: univ TVec;
in Last: integer;
var Sum: integer);
var
i: integer;
begin
Sum := 0;
for i := 0 to Last do
Sum := Sum + V[i];
end; { UniVec }
The C main program,
UniVecMain.c
, which passes
a 3-element array to the Pascal
procedure written to do a 10-
element array
#include <stdio.h>
extern void UniVec(int *, int, int *);
int main(void)
{
int Sum;
static int a[] = {7, 8, 9};
UniVec(a, 2, &Sum);
printf(" %d \n", Sum);
}