%STR has a single argument passed to it - a pointer. It returns the data
pointed to by that pointer up to (but not including) the first 'null
character' (x'00').

So when you say that d_name is "SMALLNAME.xls ME.xls", in fact, the first
character after "SMALLNAME.xls" is actually x'00'. If you're in debug and
from the debugger command line do "eval d_name:x", you will see this. The
reaminign stuff (including the ME.xls' is just leftover stuff from a
previous invocation, and must be ignored.

As you have found out, you can use d_namelen instead, since d_namelen is set
by the system to be the length of d_name up to the first x'00'. Frankly, I'd
use d_namelen rather than %STR, but that's just a personal preference -
since the system provides you with a data-length value, you may as well use

FYI, the use of x'00' as a string-delimiter is a C thing.



On Wed, Aug 13, 2008 at 8:15 AM, <Paul.Thieme@xxxxxxxxxxxxxxxxx> wrote:

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.

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.

This thread ...


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

This mailing list archive is Copyright 1997-2020 by 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].