× 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: $Center procedure (was Procedure Problem)
  • From: "Wayne Achenbaum" <wache@xxxxxxxxxxx>
  • Date: Sat, 1 Jan 2000 10:47:20 -0500


Barbara, Thanks a lot for your help. As it turns out The only cahnge I made
was to Field_In was the Const Type. I trie changing Field_out to varying,
but that caused an error when on the Line that tried to substring text into
the center of  Field_out  (I'm on V4R4). When I leave Field_out as a
non-varying alpha field it works fine. Thanks again  to you and all who
responded.
>
> Wayne,
>
> Your procedure will work fine if you change the parameter to be
> "varying const" or "varying value".  You should also make your
> returned value "field_out" to be a varying field, and set its
> length according to the length of "field_in".  With VARYING CONST
> parameters, your callers don't have to do anything special about
> the varying fields.
>
> To others who are recommending OPTIONS(*VARSIZE) and CEEDOD.
> That works too, but if you can use varying fields, as Wayne can,
> it's much easier to code, and runs faster too.
>
> Barbara Morris
>

Below is the Procedure that works with the following call:
d Ctrfld              s             50a
d Entfld              s             50a
c                                  eval      Ctrfld = $Center(EntFld)

 *--------------------------------------------------------------------*
 * Prototype for $Center procedure
*
 *--------------------------------------------------------------------*
d $Center         PR           256a   varying
d InputData                      256a   Varying Const Options(*Varsize)

 *--------------------------------------------------------------------*
 * $Center procedure
*
 *--------------------------------------------------------------------*
p $Center         B                    Export
 *
d $Center         PI           256a   Varying
d Field_In                      256a   Varying Const Options(*Varsize)
 *
d Half                s              3s 0
d Len                 s              3s 0
d Size_In           s              3s 0
d Start                s              3s 0
d Field_Out       s           256a
 *
c     ' '           Checkr(E) Field_In      Len
c                   Eval      Size_In = %Len(Field_In)
 *
c                   If        %Found
c                   Eval      Half = %Div(Len:2)
c                   Eval      Start = (((Size_In) /2)
c                                      +1) - Half
c                   eval      %Subst(Field_Out : Start : Len) =
c                             %subst(Field_In : 1 : Len)
c                   Return    Field_Out
 *
c                   Else
 *
c                   Return    Field_In
c                   EndIf
 *
p $Center         E

+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-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.