Hi,
I have this task to convert a pascal code (from AS400) to C (ILE C). I haven't used Pascal for my programming so this would be the first hands on coding on Pascal that I would ever do. How can I convert the following declarations?
Code Set #1:
I have tried doing the following:
Is this correct? And as you can see, I have placed /*dp1 p11[3];*/ as a comment because I was not able to convert the line.
Code Set #2:
Kindly ignore the line numbers. I have used them as personal reference. How will i be able to convert tempsfdp@ and the statement using with? C has no with syntax. I apoligize for so many queries. Hope you can help me.
I have this task to convert a pascal code (from AS400) to C (ILE C). I haven't used Pascal for my programming so this would be the first hands on coding on Pascal that I would ever do. How can I convert the following declarations?
Code Set #1:
Code:
type
ddsrec = packed array(.1..92.) of char;
dp1 = @ddr;
ddr = packed record
case integer of
1 : (
p11 : array(.1..3.) of dp1;
srcseq : packed array(.1..6.) of char;
srcdat : packed array(.1..6.) of char;
seqno : packed array(.1..5.) of char;
ftype : char;
aoc : char;
cinds : packed array(.1..9.) of char;
ntype : char;
dummy : char;
name : packed array(.1..10.) of char;
reference : char;
dataln : packed array(.1..5.) of char;
data_type : char;
dec_pos : packed array(.1..2.) of char;
usage : char;
line : packed array(.1..3.) of char;
col : packed array(.1..3.) of char;
funct : packed array(.1..36.) of char
)
2 : (
p12 : array(.1..3.) of dp2;
dds : ddsrec;
)
end;
Code:
typedef struct {
union {
struct {
/*dp1 p11[3];*/
char srcseq[6];
char srcdat[6];
char seqno[5];
char ftype;
char aoc;
char cinds[9];
char ntype;
char dummy;
char name[10];
char reference;
char dataln[5];
char data_type;
char dec_pos[2];
char usage;
char line[3];
char col[3];
char funct[36];
} ddrua;
struct {
/*dp2 p12[3];*/
ddsrec dds;
} ddrub;
} ddru;
} ddr;
typedef ddr *dp1;
Is this correct? And as you can see, I have placed /*dp1 p11[3];*/ as a comment because I was not able to convert the line.
Code Set #2:
Code:
1100 type
1500 ddsrec = packed array(.1..92.) of char;
14600 sfdp = @sfd;
14700 sfd = packed record
14800 next : sfdp;
14900 name : string(10)
15000 first : ddscp;
15100 last : ddscp;
15200 win_row : integer;
15300 win_col : integer;
15400 win_width : integer;
15500 win_depth : integer;
15600 end;
16300 var
16600 sfchain,tempsfdp:sfdp;
17300 sfl1 : boolean;
18700 format : string(20)
26900 {Save subfile help details for later}
27000
27100 procedure save_sfhelp(d:ddsrec)
27200 begin
27300 if sfl1 then
27400 begin
27500 new(tempsfdp)
27600 with tempsfdp@ do
27700 begin
27800 next := sfchain;
27900 sfchain := tempsfdp;
28000 first := nil;
28100 last := nil;
28200 name := format;
28300 end;
28400 sfl1 := false;
28500 end;
30100 end;
Kindly ignore the line numbers. I have used them as personal reference. How will i be able to convert tempsfdp@ and the statement using with? C has no with syntax. I apoligize for so many queries. Hope you can help me.