Highlighted
Absent Member.
Absent Member.
1471 views

[archive] Conversion of ACU C$JUSTIFY in MF Cobol

[Migrated content. Thread originally posted on 18 June 2008]

Does anybody know how I could convert
Acucobol C$JUSTIFY in MF Cobol as there is no equivalent routine?
0 Likes
4 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Conversion of ACU C$JUSTIFY in MF Cobol

Indeed you can.

We still use these routines even though we're now using acucobol and not MF.
Too much hassle to change, and not worth the effort for something that works as we need to.

                MOVE SPACES               TO WS-IN-STRING
                                                       WS-OUT-STRING.
                MOVE LINKAGE-TXT-LEN TO WS-STRING-LEN.
                MOVE LINKAGE-TXT-STR TO WS-IN-STRING.
                MOVE LINKAGE-TXT-RTC TO WS-TXT-TYPE.
                EVALUATE TRUE
                   WHEN WS-TXT-CENTRE
                        PERFORM CENTRE-ROUTINE
                   WHEN WS-TXT-LEFT
                        PERFORM LEFT-ROUTINE
                   WHEN WS-TXT-RIGHT
                        PERFORM RIGHT-ROUTINE

etc etc




      *
      *********************************************************************
      * Centre a string of text in an output field of up to 132 chars    **
      *********************************************************************
      *
       CENTRE-ROUTINE.
      *
           IF WS-IN-STRING = SPACES
           OR WS-STRING-LEN   = ZEROS
           OR WS-STRING-LEN   > 132
              MOVE WS-IN-STRING TO WS-OUT-STRING
           ELSE
              PERFORM LEFT-ROUTINE
              MOVE WS-OUT-STRING TO WS-IN-STRING
              MOVE SPACES TO WS-OUT-STRING
              PERFORM VARYING MOD4 FROM WS-STRING-LEN BY -1
                      UNTIL WS-IN-STRING(MOD4:1) NOT EQUAL SPACES
                CONTINUE
              END-PERFORM
              COMPUTE MOD2 = (WS-STRING-LEN - MOD4) / 2
              PERFORM VARYING MOD1 FROM 1 BY 1
                      UNTIL MOD1 > MOD4
              ADD 1 TO MOD2
              MOVE WS-IN-STRING(MOD1:1) TO WS-OUT-STRING(MOD2:1)
              END-PERFORM
           END-IF.
      *
      *********************************************************************
      * Left Justify Routine.                                             *
      *********************************************************************
      *
       LEFT-ROUTINE.
      *
            IF WS-IN-STRING = SPACES
            OR WS-IN-STRING(1:1) NOT = SPACES
               MOVE WS-IN-STRING TO WS-OUT-STRING
            ELSE
               MOVE SPACES TO WS-OUT-STRING
               PERFORM VARYING MOD1 FROM 1 BY 1
                       UNTIL WS-IN-STRING(MOD1:1) NOT = SPACE
                       CONTINUE
               END-PERFORM
               PERFORM VARYING MOD2 FROM 1 BY 1
                       UNTIL MOD1 > WS-STRING-LEN
                       MOVE WS-IN-STRING(MOD1:1)
                            TO WS-OUT-STRING(MOD2:1)
                       ADD 1 TO MOD1
               END-PERFORM
            END-IF.
      *
      *********************************************************************
      * Right Justify Routine.                                            *
      *********************************************************************
      *
       RIGHT-ROUTINE.
      *
            IF WS-IN-STRING = SPACES
            OR WS-IN-STRING(WS-STRING-LEN:1) NOT = SPACES
            OR WS-STRING-LEN > 132
            OR WS-STRING-LEN
               MOVE WS-IN-STRING TO WS-OUT-STRING
            ELSE
               MOVE SPACES     TO WS-OUT-STRING
               MOVE ZEROS TO MOD3
               MOVE WS-STRING-LEN TO MOD2
               PERFORM VARYING MOD1 FROM WS-STRING-LEN BY -1
                       UNTIL MOD1
                  IF MOD3 = ZEROS
                     IF WS-IN-STRING(MOD1:1) NOT = SPACES
                        MOVE WS-IN-STRING(MOD1:1)
                             TO WS-OUT-STRING(MOD2:1)
                        MOVE 1 TO MOD3
                        SUBTRACT 1 FROM MOD2
                     END-IF
                 ELSE
                   MOVE WS-IN-STRING(MOD1:1)
                        TO WS-OUT-STRING(MOD2:1)
                   SUBTRACT 1 FROM MOD2
                 END-IF
               END-PERFORM
            END-IF.


We call this routine like so.


           MOVE LINK-COMP-NAME  TO LINKAGE-TXT-STR   
           MOVE "JR"                     TO LINKAGE-TXT-RTC
           MOVE 40                      TO LINKAGE-TXT-LEN
           CALL "utxtxt" USING LINKAGE-TXT-RECORD


Hopfully this will help you.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Conversion of ACU C$JUSTIFY in MF Cobol

many thanks for your help Sean, this is great!

Your code snippet was not showing the definition of Linkage-txt-record but
I guess it must look like this.
01 linkage-txt-record.
03 linkage-txt-str pic x(132).
03 linkage-txt-len pic 9(3).
03 linkage-txt-rtc pic x(2).

I also assume that the possible values for linkage-txt-rtc must be "JR", JL" and "JC".

Daniel
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Conversion of ACU C$JUSTIFY in MF Cobol

Its like this Daniel


           03 LINKAGE-TXT-RECORD.
               05 LINKAGE-TXT-LEN            PIC 9(003).
               05 LINKAGE-TXT-STR            PIC X(132).
               05 LINKAGE-TXT-RTC            PIC X(002).


There are lots of other possible values, but I just posted the left, right and centre bits.

       77  WS-TXT-TYPE         PIC X(02) VALUE "NO".
           88 WS-TXT-INVALID             VALUE "NO".
           88 WS-TXT-CENTRE              VALUE "CT".
           88 WS-TXT-LEFT                VALUE "JL".
           88 WS-TXT-RIGHT               VALUE "JR".
           88 WS-TXT-UPPER-CASE          VALUE "UC".
           88 WS-TXT-LOWER-CASE          VALUE "LC".
           88 WS-TXT-MIX-CASE            VALUE "MC".
           88 WS-TXT-COUNT-STR           VALUE "CS".
           88 WS-TXT-YES-NO              VALUE "YN".
           88 WS-TXT-1-2                 VALUE "12".
           88 WS-TXT-NEGATIVE            VALUE "NG".
           88 WS-TXT-A-N                 VALUE "AN".
           88 WS-TXT-N-A                 VALUE "NA".


Shaun
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Conversion of ACU C$JUSTIFY in MF Cobol

Many thanks again Shaun. Sorry I got your name wrong. I need some coffee!
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.