× 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 21/01/2006, at 10:20 AM, Grizzly Malchow wrote:

StringVal = 'LINE 1                   ';
StringValW = %TrimR(StringVal) + CRLF;
Fd=write(RC2:%addr(stringvalW):%Len(%Trim(stringvalW)));

StringVal = 'LINE 2    ';
StringValW = %TrimR(StringVal) + CRLF;
Fd=write(RC2:%addr(stringvalW):%Len(%Trim(stringvalW)));

Take a really close look at what you are doing here:
        1) You are performing a concatenation using %TRIMR
        2) You are determining the resulting length using %TRIM

thus any line containing leading spaces will be truncated when the write() occurs.

If StringValW is not large enough for the trimmed content of StringVal + 2 bytes (for CRLF) then the result may be missing the CRLF which would also cause the effect you observe.

Your example code above will work because the sample data is left-aligned (and I presume StringValW is large enough) but real data may not be as forgiving.

Other points:
        a) The code seems confused over the use of RC2 and Fd.
I can't seem to figure out what I'm doing wrong. Any ideas? Would I be
better off using O_TEXTDATA in place of O_CODEPAGE if I was dealing with
a text file/HTML file?
b) These values aren't alternatives. There is a relationship between O_TEXTDATA and O_CODEPAGE. O_TEXTDATA says you are processing the data as TEXT rather than BINARY. In this case the OS will perform character conversion using the specified code page if O_CODEPAGE is also specified or the code page of the job otherwise. O_CODEPAGE is similar to the later flag O_CCSID except that O_CCSID is better because it provides a more complete set of conversions. Whether you specify O_TEXTDATA or not depends on the file content and how you want to process it. Given that you are using code page 819 then I presume the data is text in which case you probably do want to specify O_TEXTDATA.

Note:- If you are creating the file then you will probably need to open the file once without O_TEXTDATA to create it with the correct code page (or CCSID), close it, and open it again with O_TEXTDATA to get the OS to do the conversion. Without the double open the OS will expect you to provide the data in the specified code page (or CCSID). On later releases (520 and above) you can use the O_TEXT_CREAT flag to get the OS to do the data conversion in one step.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists

   http://www.flybynight.com.au/
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175                                   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.