×
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.
On Wed, 29 Dec 2004 Igor.Beslic@xxxxxxxxxxxx wrote:
I checked some more examples on opening files and I found next:
%Str(path@:100)=%subst(XMLfile:1:%scan(' ':XMLfile:1)-1);
If I evaluate path this way, openFile procedure opens file!!
If that's the case, you've got some major bugs in your code. Most likely,
you're viewing memory that does not belong to the variable where the
pathname is stored.
I wonder now what is difference between:
%subst(XMLfile:1:%scan(' ':XMLfile:1)-1)
AND
%trim(XMLfile)
The difference is that %scan() finds the first space in a string, and
%trim() finds the last non-space in a string.
Take the following IFS pathname for example:
path = '/group files/it department/equipment policy.txt '
If you perform the expression path = %subst(path: 1: %scan(path:' ':1)-1)
on this path, you'll get the following:
path = '/group'
If you perform the other expression, path = %trim(path), on it, you'll
get the following:
path = '/group files/it department/equipment policy.txt'
You see the difference? %trim() removed the spaces at the end of the
pathname, whereas the %scan() and %subst() method trims everything after
(and including) the *first* space in the pathname.
My guess is that you're getting garbage characters in the pathname. Since
these characters might be unprintable, it's possible that they wouldn't
show up if you use the debugger to display the string. (Unless you viewed
the string in hex, of course.)
Remember, you can't pass a 100A parameter from the command line!!!!!!!
When you pass a parm from the command line, it's 32A. If you want to make
it longer than that, you have to either pass a variable from another
program, or you need to make a command interface for your program. (Or,
one of the various other workarounds...)
For more info on the 32A parameter issue, see the Midrange.com FAQ at the
following link:
http://faq.midrange.com/data/cache/70.html
I would like to point out that this problem is not related to the IFS in
any way.
a) The need to use %trim() on a fixed-length string is true any time you
work with a string in RPG. The fact that this string happens to be passed
to the open() API is coincidence.
b) No OS/400 program (written in ANY language) will work properly with a
character field larger than 32A when passed as a literal from CL, the
QCMDEXC API, the command line or SBMJOB. It doesn't matter what you intend
to do with that parameter. Instead of an IFS pathname, it could've been a
message on the screen or a report heading.... you'd have the same problem.
As an Amazon Associate we earn from qualifying purchases.
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.