× 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.


  • Subject: Re: Formatting Data in RPG 4
  • From: "Peter Dow" <pcdow@xxxxxxxxx>
  • Date: Wed, 25 Apr 2001 22:44:25 -0700

Thanks Booth. I just read Justin's email noting that he only wants to eliminate trailing blanks. %trim would remove leading and trailing blanks.
 
Regards,
Peter Dow
Dow Software Services, Inc.
909 425-0194 voice
909 425-0196 fax
 
----- Original Message -----
Sent: Wednesday, April 25, 2001 8:47 PM
Subject: Re: Formatting Data in RPG 4


I'd do this I think:

  D LongField      S                   60
   * Cat the records (use TrimR as we wish to remove trailing blanks only):
  C             Eval   LongField = *Blanks
  C             Eval   LongField = %TrimR(Record1) +
  C                    %TrimR(Record2) +
  C                    %TrimR(Record3)
   * Substring at 20's:    
  C             Eval   Record1 = %Subst(Longfield:1:20)
  C             Eval   Record2 = %Subst(Longfield:21:20)
  C             Eval   Record3 = %Subst(Longfield:41:20)
 

 
_______________________
Booth Martin
Booth@MartinVT.com
http://www.MartinVT.com
_______________________



"Justin Kiteley" <justin@asiwms.com>
Sent by: owner-rpg400-l@midrange.com

04/25/2001 10:16 PM
Please respond to RPG400-L

       
        To:        <RPG400-L@midrange.com>
        cc:        
        Subject:        Re: Formatting Data in RPG 4

Peter,Jim and all,

Thanks for the ideas.  The problem I am having is that the input data is
anywhere from 1 to 80 char long, almost always varying in size with spaces
in the data that need to be retained.

Example:  lets say the max length was 20 and i was trying to wrap data to a
larger field, removing unwanted trailing spaces. cap X's represent necessary
spaces small x's unnecessary spaces.  Sorry if it's confusing, I couldn't
think of any other way to explaing it!

Before

record 1  - TestingX12xxxxxxxxxx
record 2  - TestX12XXTestXXXXTst
record 3  - TstX1X23xxxxxxxxxxxx

After (what I am having trouble achieving)

record 1 - TestingX12TestX12XXTestX
record 2 - XXXTstTstX1X23xxxxxxxxx

 I was just wondering if there was an easier (more efficient, less code)
way to do it.  Rather than the circuitous code I have right now.  I suppose
the only answer to the spaces problem is to use checkr to find farthest
right position of data in the field to be wrapped then parse out the data
character by character into the new 80 field using arrays, keeping track of
where you are by counters, and then reading the next record when 80 is
reached.  I'm going to try to adapt Peter's code first and try it out, but
I'm not sure how it will handle the spaces.  I also don't know how much data
will be in the file, so I guess I have to define the "largefield" as large
as possible?  If anybody else has ideas on this don't be shy.  I'll post my
code once I get it working properly if anybody wants to see it.    Again,
thanks for the input!


Justin Kiteley



+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.