× 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: Procedure Problem
  • From: "Carsten Flensburg" <novasol@xxxxxxxxxxxx>
  • Date: Sat, 25 Dec 1999 12:12:41 +0100

One way to go would be using a varying lengt field - the actual field length is sort of a "built-in" length parameter and is easily retrieved in the subprocedure:
 
     **-- Compilation spec:  -------------------------------------------------**
     **
     **   CrtRpgMod  Module( FNC031MR )
     **   CrtSrvPgm  Srvpgm( FNC031S )  Module( FNC031MR )  Export( *ALL )
     **
     **   CrtBndDir  BndDir( FNC031B )  Text( 'General Functions Directory' )
     **   AddBndDirE BndDir( FNC031B )  Obj(( FNC031S *SRVPGM ))
     **
     **-- Control spec:  -----------------------------------------------------**
     H NoMain Option( *SrcStmt )
     **-- Center (leftadjusted) string:  -------------------------------------**
     D Center          Pr           256a   Varying
     D  CntStr                      256a   Varying Value
     **-- Check Reverse:  ----------------------------------------------------**
     D CheckR          Pr             5u 0
     D  CrArg                         1a   Const
     D  CrString                    256a   Const
     **-- Center string:  ----------------------------------------------------**
     P Center          B                   Export
     D                 Pi           256a   Varying
     D  CntStr                      256a   Varying Value
     **
     D Blanks          s            128a
     **
     C                   Return    %SubSt( Blanks
     C                                   : 1
     C                                   : %Int(( %Len( CntStr ) -
     C                                     CheckR( ' ': CntStr )) / 2 )
     C                                   ) + CntStr
     **
     P Center          E
     **-- Check Reverse:  ----------------------------------------------------**
     P CheckR          B                   Export
     D                 Pi             5u 0
     D  CrArg                         1a   Const
     D  CrString                    256a   Const
     **
     D Pos             S              5u 0
     **-- Check Reverse:  ----------------------------------------------------**
     **
     C     CrArg         CheckR    CrString      Pos
     C                   If        Pos        =  *Zero
     C                   Return    1
     C                   Else
     C                   Return    Pos
     C                   EndIf
     **
     P CheckR          E

     **-- Compilation spec:  -------------------------------------------------**
     **
     **   CrtRpgMod Module( FNC032MR ) DbgView( *LIST )
     **   CrtPgm    Pgm( FNC032I )     Module( FNC032MR )  ActGrp( QILE )
     **
     **-- Control spec:  -----------------------------------------------------**
     H BndDir( 'FNC031B' )  Option( *SrcStmt )
     **-- Global variables:  -------------------------------------------------**
     D Field           S             64a   Inz('Mark Spitz' )
     D DspFld          S             32a
     D PrtFld          S            128a
     **-- Center (leftadjusted) string:  -------------------------------------**
     D Center          Pr           256a   Varying
     D  CntStr                      256a   Varying Value
     **
     **-- Sample:  -----------------------------------------------------------**
     **
     C                   Eval      Field      =  Center( Field )
     **
     C                   Eval      Field      =  %TrimL( Field )
     C                   Eval      DspFld     =  Center( %SubSt( Field
     C                                                         : 1
     C                                                         : %Size( DspFld )
     C                                                         ))
     **
     C                   Eval      PrtFld     =  %TrimL( Field )
     C                   Eval      PrtFld     =  Center( PrtFld )
     **
     C                   Return
     **
 
As you can see in the last example, it won't really solve the problem Jon mentioned about being able to set the length of the receiver variable, if that is bigger than the source variable; I have to copy the string to the receiver and use that as input to make it work.
 
Best regards,
Carsten Flensburg
 
----- Original Message -----
Sent: Friday, December 24, 1999 7:28 PM
Subject: RE: Procedure Problem

You put the data to be centered in a field and pass the field. It returns it centered. You shouldn't have to tell the procedure the length of the field, it can figure it out.

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.