× 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: justifying a character variable
  • From: bmorris@xxxxxxxxxx
  • Date: Mon, 15 Jan 2001 17:31:48 -0500
  • Importance: Normal


>Date: Mon, 15 Jan 2001 15:38:03 -0500
>From: "Lynette Chronister" <lchronis@MasonicHomesPA.org>
>
>what is the easiest way to right justify a character variable.
>example
>
>char1 = 'NAMEbbbbb' (b = blanks)
> i want 'bbbbbNAME'
>
>i can get this done, im just thinking there HAS to be an easier way.
>TIA
>oh, p.s. im writing in 400 not ILE.

Lynette,

Here's a way to do this in RPG/400: use CHEKR to find the
length of the data, subtract that length from the full
length to get the number of blanks, and then use CAT,
specifying that number of blanks (where 50 is the length
of CHAR1)

C           ' '       CHEKRCHAR1     LEN     50
C           100       SUB  LEN       BLK     50
C           ' '       CAT  CHAR1:BLK CHAR1

You didn't say how you were already doing it; maybe this isn't
any easier.

If you want to avoid hard-coding the 100:

C           *LIKE     DEFN CHAR1     LENCH1
C                     MOVE 'Z'       LENCH1
C           ' '       CHEKRLENCH1    TOTLEN  50
C           ' '       CHEKRCHAR1     LEN     50
C           TOTLEN    SUB  LEN       BLK     50
C           ' '       CAT  CHAR1:BLK CHAR1

Barbara Morris


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