Page 1 of 1

display vertically using cobol.

Posted: Mon Oct 23, 2023 8:16 pm
by Leena
Hi guys.

Can any one plz explain .
how to display "Indian army" vertically using cobol. if Indian army declared as a variable in pgm.

Re: display vertically using cobol.

Posted: Mon Oct 23, 2023 9:20 pm
by zum13
Hello.

There's not a simple one-statement solution for this that I'm aware of, so it would have to be something along these lines:

Code: Select all

       01  WA-MESSAGE                  PIC X(11)  VALUE 'Indian Army'.
       01  WA-SUB                      PIC S9(4)  COMP.
.
.
           PERFORM VARYING WA-SUB FROM 1 BY 1 
                   UNTIL WA-SUB > 11
              DISPLAY WA-MESSAGE (WA-SUB:1) 
           END-PERFORM 
The "(WA-SUB:1)" bit is a substring that goes to the character indicated by WA-SUB and returns the characters for length of 1.

If you are doing this on a report, you reserve a space in the output line for a single character, then use the substring to move in the next character before you print the next line.

Re: display vertically using cobol.

Posted: Fri Oct 27, 2023 9:44 pm
by Leena
Thanks for the guidance. This is helpful.