Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 12th, 2005, 9:48 PM   #1
joan400
Newbie
 
Join Date: Apr 2005
Posts: 2
Rep Power: 0 joan400 is on a distinguished road
Question Need help badly: Pascal conversion to C

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:
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;
I have tried doing the following:
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:
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.

--joan400
joan400 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:59 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC