View previous topic :: View next topic
|
Author |
Message |
mercy Warnings : 1 New User
Joined: 25 Jun 2006 Posts: 10 Location: Bangalore
|
|
|
|
Hi,
I am preparing a report using cobol.Is there any function available to justify the text at the center of the line.The printed text is of variable length.
Thanq |
|
Back to top |
|
|
parikshit123
Active User
Joined: 01 Jul 2005 Posts: 269 Location: India
|
|
|
|
Hi ,
I don't think we have either an inbuilt function to do that or a "justify center" clause. You have to do it manually.
thanks,
Parikshit. |
|
Back to top |
|
|
mercy Warnings : 1 New User
Joined: 25 Jun 2006 Posts: 10 Location: Bangalore
|
|
|
|
Hi Thanq for ur reply. can you let me know how can it b done manually? |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
H Mercy,
You can try something like this:
Determine the length of the string. I'll call it STR-LEN
Subtract the length of the string from the length of the receiving variable.
Divide that by 2 and add 1.
Use the result as the position of the starting point of the sending string in the receiving field. I'll call it STR-POS
Move the string to the receiving variable using:
MOVE SPACES TO RECV-VAR
MOVE SEND-VAR(:STR-LEN) TO RECV-VAR(STR-POS:)
For ex:
String len = 10
String pos = 16
Var len = 40
The move stmt will move the 10 byte string to pos 16 of the receiving field (leaving 15 leading spaces) and it will occupy pos 16 thru 25 there, leaving 15 trailing spaces. |
|
Back to top |
|
|
|