|
On Fri, 29 Aug 2003 rob@xxxxxxxxx wrote: > Why does %Trimr put *blanks on the end? It doesn't. If the variable is fixed-length, EVAL needs to set the entire contents of the variable -- so it sets the remainder to blanks. But, it's EVAL, not %trimr() that does this. If you're using a fixed-length variable, you need to put SOMETHING in those spaces, right? RPG has always used blanks. > Or, better yet, is there a better way to make sure that the field ends > in trailing nulls? You could do this: D MyVar s 30a D MyString s 30a inz('test') D Nulls s 30A inz(*ALLx'00') /free MyVar = %trimr(myString) + Nulls; But, I'm at a bit of a loss... why do you want to fill it with nulls? > (As I finished typing up this last sentence I banged off a Sametime to > the developer suggesting a variable length field instead. I think it is > a new file that he will be using for CPYTOSTMF or CPYTOIMPF for FTP EDI > purposes thus he "should" be open minded... If he's writing it to a stream file, filling it with nulls isn't any better than filling it with blanks... the write() API will write as many chars as your length is set to, it does not pay attention to nulls. Instead, he should just code: write(fd: %addr(MyString): %len(%trimr(MyString)); and skip the whole idea of translating blanks to nulls. Or better yet, use a varying field: D MyString s 30a varying inz('test') /free write(fd: %addr(MyString)+2: %len(MyString)); At the very least, this will run much faster than the business with %trim will. Especially if you ever change MyString to be a larger variable.
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.