× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



hey all,

here is a very simple program, stripped down to just the basics:

H DFTACTGRP(*NO) ACTGRP(*NEW)
H BNDDIR('QC2LE')
H OPTION(*SRCSTMT: *NODEBUGIO: *SHOWCPY)

D waFileName      S            100A
D count           S             10i 0
D mode            S              5a
D errmsg          S            256A
D wiHandle        S               *

D Buffer          DS
D   saBuffer                   512A

D fOpen           PR              *   ExtProc('_C_IFS_fopen')
D  fileName                       *   Value Options(*STRING)
D  fmode                          *   Value Options(*STRING)

D fgets           PR              *   ExtProc('_C_IFS_fgets')
D  text                           *   Value options(*string)
D  length                       10I 0 Value
D  fd                             *   Const

D geterror        PR            10I 0
D   peErrMsg                   256A   options(*nopass)

c                   eval      waFileName =
c                             '/http/aloha/pmix/PMIX2003060401.txt'

c                   eval      mode = 'r' + x'00'
C                   eval      wiHandle = fOpen(%trim(waFileName):
c                                             %addr(mode))

C                   callp     geterror(errmsg)

C                   dow       fgets(%addr(buffer):%size(buffer):
C                                    wihandle)   <>  *null
c                   eval      count = count + 1
C                   enddo

C                   callp     geterror(errmsg)

c                   eval      *inlr = *on
C                   return

P geterror        B

D geterror        PI            10I 0
D   peErrMsg                   256A   options(*nopass)

D geterrno        PR              *   extproc('__errno')
D strerror        PR              *   extproc('strerror')
D   errno                       10I 0 value

D p_error         S               *   INZ(*NULL)
D wwError         S             10I 0 based(p_Error)
D p_errmsg        S               *
D wwErrMsg        S            256A   based(p_errmsg)
D wwLen           S             10I 0

C                   eval      p_error = geterrno
c                   if        %parms >= 1
c                   eval      p_errmsg = strerror(wwError)
c     x'00'         scan      wwErrMsg      wwLen
c                   eval      peErrMsg = %subst(wwErrMsg:1:wwLen)
c                   endif
c                   return    wwError

p                 E

This will compile in v5r1

after the open, I have a valid pointer in wiHandle, and the geterrno
returns "there is no error".

I do the fgets(), and it returns *null, and the following geterrno returns:
"Invalid Descriptor"

I've looked and looked, I've tried a hundred different things, but I can't
seem to get this one figured out.

Thanks,

Rick






As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.