![](/images/backgrounds/286549/hp-sunsoft-pascal-4-0-users-manual-549395124x1.png)
6
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
The C main program, UniVecMain.c, which passes a
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 }
#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);
}
100 | Pascal 4.0 User’s Guide |