8

See the following example:

The Pascal procedure, SimVal.p. t, f, c, i, r, and s are value parameters.

procedure simval_(t, f: boolean; c: char; i: integer;

r: real; s: integer16; var reply: integer);

begin

reply := 0;

{If nth arg is ok, set nth octal digit to one. } if t then

reply := reply + 1; if not f then

reply := reply + 8; if c = 'z' then

reply := reply + 64; if i = 9 then

reply := reply + 512; if r = 9.9 then

reply := reply + 4096; if s = 9 then

reply := reply + 32768

end; { simval_ }

The FORTRAN main program,

SimValmain.f

 

logical*1

t, f

 

 

character

c

 

 

integer*4

i

 

 

double

precision d

 

 

integer*2

s

 

 

integer*4

args

 

 

data t

/ .true. /, f / .false. /,

c / 'z' /

&

i

/ 9 /,

d / 9.9 /,

s / 9 /

 

call SimVal( %VAL(t), %VAL(f), %VAL(c),

&

 

 

%VAL(i), %VAL(d), %VAL(s), args )

 

write(

*, 1 )

args

 

1format('args=', o6, '(If nth digit=1, arg n OK)') stop

end

The FORTRAN–Pascal Interface

181