HP SunSoft Pascal 4.0 User Manual

Page 198

Advertising
background image

174

Pascal 4.0 User’s Guide

8

Example 1: Single-Dimension Array

Example 2: Array of Characters

The Pascal procedure,

IntCA.p

. Pascal passes the

bounds by value.

procedure intca_(var a: array [lb..ub: integer] of integer);

begin

a[1] := 1;

a[2] := 2

end; { intca_ }

The FORTRAN main program,

IntCAmain.f

integer k

integer s(0:2)

data s / 0, 0, 0 /

call IntCA ( s, %VAL(0), %VAL(2) )

do k = 0, 2

write( *, "(I1)" ) s(k)

end do

stop

end

The commands to compile and
execute

IntCA.p

and

IntCAmain.f

hostname% pc -c IntCA.p

hostname% f77 IntCA.o IntCAmain.f -lpfc -lpc

IntCAmain.f:

MAIN:

hostname% a.out

0

1

2

The Pascal procedure,

ChrCA.p

. Pascal passes the

bounds by value.

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

begin

a[0] := 'T';

a[13] := 'o'

end; { chrca_ }

Advertising