HP C Programmer's Guide (92434-90009)

Chapter 3 51
Calling Other Languages
Comparing HP C and HP Pascal
ret_val := 0;
for i := 1 to len - 1 do
begin
if ( a[i] <> ’a’ ) then
ret_val := 1;
a[i] := ’z’;
if ( b[i] <> ’b’ ) then
ret_val := 256;
b[i] := ’y’;
end;
for i := 1 to strlen (c) do
begin
if ( c[i] <> ’c’ ) then
ret_val := 65536;
c[i] := ’x’;
end;
for i := 1 to strlen (d) do
begin
if ( d[i] <> ’d’ ) then
ret_val := maxint;
d[i] := ’w’;
end;
pass_char_arrays := ret_val;
end;
function pass_a_string (var a: string) : integer;
var
i : integer;
ret_val : integer;
begin
ret_val := 0;
for i := 1 to strlen (a) do
begin
if (a[i] <> ’x’ ) then
ret_val := maxint;
a[i] := ’q’;
end;
pass_a_string := ret_val;
end;
begin
end.
The following HP C main program calls the HP Pascal procedure:
#include <stdio.h>
#include <string.h>
static struct string_10 {
int cur_len;
char chars[10];
};