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




I trying to create a list of objects in an IFS directory. This weekly job
will copy all the files to an archive directory and delete the original.

The DIR command created by Peter Connell has been utilized as the guts for
my basic framework. It works, but I don't understand reasoning for the
various functions it uses.


The readdir() uses the following prototype:

Dreaddir PR * EXTPROC('readdir')
D * VALUE

The final results of the readdir() end up in this data structure...
D DirEntry DS
D d_reserved1 16A
D d_fileno_genid 10U 0
D d_fileno 10U 0
D d_reclen 10U 0
D d_reserved3 10I 0
D d_reserved4 6A
D d_reserved5 2A
D d_ccsid 10I 0
D d_country_id 2A
D d_language_id 3A
D d_nls_reserved 3A
D d_namelen 10U 0
D d_name 640A

..... and these are the other pointers and structures needed....

D ReturnDir S *
D PtrToEntry S *
D RtnEntry S BASED(PtrToEntry)
D Like(DirEntry)

The data is retrieve through the following code and the object name ends up
in "EntryName"

C Eval PtrToEntry = readdir(ReturnDir)
C*
C If PtrToEntry <> *Null
C Eval DirEntry = RtnEntry
C*
C Eval EntryName = %str(%addr(d_name))

Everything works fine. My problem is I don't understand what
%str(%addr(d_name)) is doing and why it is needed.

Walking through the program in debug, I noticed that d_name has a value. I
changed the code to the "easier on the eyes" version which is simply taking
a 256 char field and truncating it in a 120 char field.

C Eval EntryName = d_name

Unfortunately, everything isn't working now. If the current object name is
smaller (fewer characters) than the previous object's name, the excess
characters are left in d_name and are transferred to EntryName.

For instance, if BIGBIGBIGFILENAME.xls is the first object and
"SMALLNAME.xls" is the next object, the value of d_name will be
"SMALLNAME.xls ME.xls" The last 6 characters of the previous name are
still in the field. In testing I've found that the value of d_name always
contains the actual object name plus two blank characters. If the previous
name was longer than that, it is still visible.

What I don't understand is why doesn't %str(%addr(d_name)) pick up the full
value (i see it in Debug), but a simple assignment does?

I've found a work around to be:

C Eval EntryName = %SubSt(d_name:1:d_namelen)

d_namelen is the actual length of the name field being passed back. So
assuming anything else is trash, it can be ignored. Only this doesn't
answer what %str & %addr is doing.

Thanks for any insights.

Paul Thieme.



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.