× 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.




C* Open directory
C                   eval      returnDir = opendir(%addr(FullName))

This code is incorrect. You shouldn't be specifying %addr() here. Change this to %trim(FullName).



C* Terminate if error occurred when opening directory
C                   if        ReturnDir = *Null
C                   eval      *inlr = *on
C                   return
C                   endif

Here you're not doing proper error handling. You should be retrieving an error message if opening the directory fails -- not simply ending the program and telling the user nothing!


C                   dou       PtrToEntry = *null
C* Read next directory entry
C                   eval      PtrToEntry = readdir(ReturnDir)
C* error?
C                   if        PtrToEntry = *null
c                   callp     EscErrno(errno)
c                   endif

Here you ARE doing error handling, but there's still a problem! readdir() returns *NULL when it hits the end of the directory, so your program will crash with an *ESCAPE message, in spite of the fact that nothing is wrong.

readdir() returns *NULL, but doesn't change errno, when it hits the end of a directory.

readdir() returns *NULL and does change errno when an error occurs.


C* Determine object type of entry
C                   eval      EntryPath = %trim(DirName) + '/'
C                             + %trimr(EntryName) + Null
C                   eval      ReturnInt = lstat(%addr(EntryPath)
C                                            : %addr(StatDS))

Again, you should not be using %addr() here for the EntryPath. The only reason you'd use %addr() is if you needed your code to be compatible with V3R2 which was the ONLY release of ILE RPG where you needed to use %addr().

Your prototype should have options(*string), and instead of using %addr() and manually adding a null to the end, you should simply be passing a trimmed variable.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.