home *** CD-ROM | disk | FTP | other *** search
/ Sams Cobol 24 Hours / Sams_Cobol_24_Hours.iso / source / ch22 / CHAPT22D.COB < prev    next >
Text File  |  1998-09-14  |  1KB  |  32 lines

  1. 000010 @OPTIONS MAIN,TEST
  2. 000020 Identification Division.
  3. 000030 Program-Id.  Chapt22d.
  4. 000031* Center A String
  5. 000040 Environment Division.
  6. 000050 Configuration Section.
  7. 000051 Source-Computer.  IBM-PC.
  8. 000055 Object-Computer.  IBM-PC.
  9. 000056 Data Division.
  10. 000057 Working-Storage Section.
  11. 000107 01  String-Length        Pic 9(6) Value Zeros.
  12. 000117 01  Counter              Pic 9(6) Value Zeros.
  13. 000127 01  String-To-Center     Pic X(60) Value
  14. 000137     "Teach Yourself COBOL in 24 Hours".
  15. 000147 01  Centered-String      Pic X(60) Value Spaces.
  16. 000148 Procedure Division.
  17. 000159 Chapt22d-Start.
  18. 000169     If String-To-Center > Spaces
  19. 000170        Compute String-Length =
  20. 000171                Function Length (String-To-Center)
  21. 000179        Perform Varying Counter From
  22. 000189           String-Length By -1 Until
  23. 000199           String-To-Center (Counter:1) > Spaces
  24. 000200           Continue
  25. 000209        End-Perform
  26. 000219        Compute Counter Rounded = (String-Length - Counter) / 2
  27. 000229        Move String-To-Center To
  28. 000239             Centered-String (Counter:)
  29. 000249     End-If
  30. 000259     Display "Centered-String=" Centered-String
  31. 000309     Stop Run.
  32. 000319     .