Sorry, your browser doesn't suppor Java.


Screen shot of centered text program

Screen shot of centered text program
An RPG program to demonstrate a technique to center text


The RPG code:
      * ....................................................
      * :         This program shows a method for          :
      * :            centering text in a field             :
      * :                                                  :
      * :  4/98  Booth M.                                  :
      * :                                                  :
      * : (Note: this program uses the Opcode CHEKR.       :
      * :  Originally the program did a loop, starting at  :
      * :  the high number and decrementing column by      :
      * :  column until a blank was encountered. CHEKR     :
      * :  does this, as an Opcode. Many thanks to         :
      * :  Mark Westphal for pointing this out to me.)     :
      * :  < Mark Westfall   vtas400@together.net >        :
      * :                                                  :
      * ::::::::::::::::::::::::::::::::::::::::::::::::::::
     FCENTERFMCF  E                    WORKSTN
     E                    CF         30  1
     C*  ..................................................
     C           *INKC     DOUEQ*ON
     C                     EXFMTFMT01
     C                     MOVE *OFF      *IN41
     C           FIELD     IFNE *BLANKS
     C                     EXSR CHOOSE
     C                     ELSE
     C                     MOVE *ON       *IN41
     C                     END
     C                     END
     C                     MOVE *ON       *INLR
     C* ....................................................
     C* :           S U B   R O U T I N E S                :
     C* ::::::::::::::::::::::::::::::::::::::::::::::::::::
     C* Center the typed field.
     C           CHOOSE    BEGSR
     C                     MOVE *BLANKS   CF
     C* CHEKR reads a field character by character, right to left.
     C* Factor 1 is what is being compared too.
     C           ' '       CHEKRFIELD     I       20
     C* I equals the position in the FIELD of the last non-blank character.     
     C* The field's length (30) less I equals the number of empty columns.
     C* Dividing by 2 is the correct place to place the beginning of FIELD.         
     C           I         IFGE 29
     C                     Z-ADD1         I
     C                     ELSE
     C           30        SUB  I         I
     C           I         DIV  2         I
     C* Add one, to move over one space to start with.
     C                     ADD  1         I
     C                     END
     C                     MOVEAFIELD     CF,I
     C                     MOVE *BLANKS   FIELD
     C                     MOVEACF        FIELD
     C                     ENDSR
     C*-------------------------------------------------------------------




The DDS code:

     A*%%TS  SD  19980429  113105  BOOTH       REL-V3R7M0  5716-PW1
     A*%%EC
     A                                      DSPSIZ(24 80 *DS3)
     A                                      CHGINPDFT(HI UL LC)
     A                                      CSRINPONLY
     A*
     A          R FMT01
     A*%%TS  SD  19980429  113105  BOOTH       REL-V3R7M0  5716-PW1
     A                                      TEXT('CENTER TEXT')
     A                                      CA03(03 'EXIT')
     A                                      OVERLAY
     A                                      WINDOW(6 20 8 30)
     A                                      WDWTITLE((*TEXT ' Centering text i-    
     A                                      n a field '))
     A                                  3  1'Text to be centered:'
     A            FIELD         30A  B  4  1
     A                                  7  1'F3=exit'
     A                                      COLOR(BLU)
     A  41                              5  4'Can''t leave field blank'
     A                                      COLOR(RED)
     A          R DUMMY
     A                                      TEXT('PREVENTS PREVIOUS SCREEN FROM-
     A                                       BEING CLEEARED')
     A                                      ASSUME
     A                                  5  9' '


For comments or questions, leave e-mail
A series of code for FTP of AS/400 files.
A date verification/formatting program
Review a sample of my coding work
Return to my home page
Top of page