× 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: Centering Text Within A Field
  • From: "M. Lazarus" <mlazarus@xxxxxxxx>
  • Date: Thu, 28 Jun 2001 17:26:04 -0400

Larry,

At 6/28/01 12:59 PM -0400, you wrote:
>Here's some code that should do it...I am sure there are several other 
>solutions as well
>
>         d length          s              2  0
>        * the next field contains the data to be centered
>
>         d data_in         s             40
>        * this field just has blanks
>         d add_blanks      s             40
>
>         c                   eval      length = %len(%trim(data_in))
>         c                   eval      length = (40 - length) / 2
>         c                   eval      data_in = 
> %subst(add_blanks:1:length) + data_in

  If I'm not mistaken, id data_in is blank this code will bomb on the last 
statement.  A simple IF data_in <> *Blank statement will avoid that.

  Also, the hardcoded "40" in the 2nd EVAL should be converted to %len( 
data_in ) for flexibility and the variable "length" s/b made larger and 
made into an integer or unsigned integer.

  -mark

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

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.