|
Scott, >> For a VARYING variable, it's the same, except you don't need to code %trimr(): Usually true, but not always. Consequently I always add %TRIMR() to varying fields since trailing blanks in a varying fields can and do occur frequently. -Bob Cozzi www.RPGxTools.com RPG xTools - Enjoy programming again. -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement Sent: Friday, November 11, 2005 11:25 AM To: RPG programming on the AS400 / iSeries Subject: RE: 3440:Operation not supported when trying to read an IFS file. > 2) When using the open API I pass the address of the variable containing the > file name + 2 because the variable is VARYING and the first 2 bytes contain > the length. If you don't use a VARYING field then remove the "+ 2" part, but > be aware that trailing blanks in a fixed-length field can be interpreted as > part of the file name - hence the common use of adding a trailing null to > terminate the string. This is both incorrect and unnecessary. For a fixed-length variable, the following code is all you need: fd = open(%trimr(filename): . . .) For a VARYING variable, it's the same, except you don't need to code %trimr(): fd = open(filename: . . .) Notes: -- You do not need to use %addr() or pass a pointer. In fact, if you _do_, you'll create problems, because the automatic x'00' will no longer be added. -- You do not need to add x'00' manually, options(*string) adds it for you as long as you're bright enough not to pass a pointer. -- You do not need to add 2 to the address. Since you're not passing a pointer, but are using the functionality of the RPG language, it KNOWS that your field is VARYING. It KNOWS that the intended result is a null-terminated string. It'll convert it for you. The really frustrating part is that I've already explained this to Emmanuel, and a day later you come and do it wrong, and convince him to do it wrong. It's enough to make you want to chew your own foot off!
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.