HPlogo HP C/HP-UX Programmer's Guide: Workstations and Servers > Chapter 3 Calling Other Languages

Comparing Structured Data Type Declarations

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

This section shows how to declare a nested structure in HP C, HP Pascal, and HP FORTRAN 77.

HP C Nested Structure

struct x {
char y [3];
short z;
char w [5];
};

struct q {
char n;
struct x v [2];
double u;
char t;
} a;

struct u{
union {
int x;
char y[4];
} uval;
};

HP Pascal Nested Structure

TYPE
x = RECORD
y : PACKED ARRAY [1 .. 3] OF CHAR;
z : SHORTINT;
w : PACKED ARRAY [1 .. 5] OF CHAR;
END;

q = RECORD
n : CHAR;
v : PACKED ARRAY [1 .. 2] OF x;
u : LONGREAL;
t : CHAR;
END;

u = RECORD
CASE
Boolean OF
TRUE : (x : INTEGER);
FALSE: (y : ARRAY[1..4] of CHAR);
END;
VAR a:q;

HP FORTRAN 77 Nested Structure

program main
structure /x/
character*3 y
integer*2 z
character*5 w
end structure

structure /q/
character n
record /x/ v(2)
real*8 u
character t
end structure


structure /u/
union
map
integer*4 x
end map
map
character*4 y
end map
end union
end structure
© Hewlett-Packard Development Company, L.P.