After reading Scott Klements tutorial entitled Working with the IFS in RPG IV. I decided to try a little programming myself. Below is the code. I didn't include the definitions for the flags and mode for the sake of space but I copied and pasted them straight out of Scott's web page, During debugging, put a break point right before the line in red and the value of rddata is always a bunch of, illegible characters, looking nothing like what is in the Vendor.csv file itself. I don't know if the character set id which is 437 is the problem or what. Maybe someone can shed some light.
Code:
D open PR 10I 0 extproc('open') D path * value options(*string) D oflag 10I 0 value D mode 10U 0 value options(*nopass) D codepage 10U 0 value options(*nopass) * ** READ api D read PR 10I 0 extproc('read') D fildes 10I 0 value D buf * value D nbyte 10U 0 value D @__errno PR * ExtProc('__errno') D strerror PR * ExtProc('strerror') D errnum 10I 0 value /free PATH = '/home/mystuf/Vendor.csv'; flags = O_RDWR; mode = S_IRUSR + S_IWUSR + S_IXUSR ; fd = open(%trimr(path):flags: mode); if fd < 0; Msg = %str(strerror(errno)); endif; len = read(fd: %addr(rddata):%size(rddata)); Dow fd >=0; [COLOR="#FF0000"]msg = rddata; [/COLOR] len = read(fd: %addr(rddata):%size(rddata)); enddo; *INLR = *ON; /end-free
Comment