On Fri, 4 Jan 2002, James Rich wrote: > > Wow, that looks like a lot of code. Almost all of it is D specs defining > variables and functions. That stuff is #include'd in my C version, which > I think makes the C code more readable. Are there C include file > equivalents for RPG? I know you can use /INCLUDE and /COPY, but that's > not what I'm referring to. I mean system supplied header files that make > all the D spec stuff unnecessary. So you could just do something like: > > D/INCLUDE types.h > D/INCLUDE dirent.h Unfortunately, IBM has not seen fit to create system-supplied header files for RPG. I generally create my own. Once I've done that, I can code them in RPG just as easily as I could in C... Unfortunately, when I'm talking to someone on a mailing list, I can't assume that they have my header files... so I copy the relevant portions into the D-specs. > > For the original question asked by the poster, I wonder if it would be > easier to code the IFS stuff in C and then make it a bound procedure for > the RPG program? You could make your own function called > 'change_directory' that would be a C function to do the chdir() API > and another function to list the files. That would be pretty easy I > think. No. Calling a C program is not easier. If I did that, not only would I need a separate source member for the C source code itself, but I'd also need a header file with the prototypes and any necessary constants & structures that I'd use when I call the C program.... So, no... it's less work to just call the API directly. Plus, it's one less thing that can go wrong. And it performs better. > > Of course I guess it would be nice if RPG supported typedef, too (maybe it > does?). > Not per-se. What RPG does have, that can sometimes be used to perform similar things, is the "like()" feature. Thus, I could define a variable like this in my header file: D socket_t S 10I 0 And then use LIKE in my programs: D client S like(socket_t) Then, IBM has added some new enhancements in V5R1 that let me do similar things with data structures. Unfortunately, I don't have V5R1 on my machine yet, so I haven't played with that. What really irks me, is that MOST RPG programmers are unwilling to even upgrade RPG IV so that they can use the things that I'm describing above! >From your perspective, RPG IV seems limited since you're comparing it to C. But from the average RPG programmers' perspective, RPG IV has too many new features that they "don't need", and they don't want to complicate things by using them... I've lost count of how many times people have said to me: "Stop trying to make RPG be like C! Why don't you just use C?" Sigh... I just wanted RPG to catch up with every other language out there.
As an Amazon Associate we earn from qualifying purchases.
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.