![]() |
Right, Left or Center Justification SimoJUST - The COBOL Source Code http://www.simotime.com |
| When technology complements business | Copyright © 1987-2010 SimoTime Enterprises All Rights Reserved |
This document provides a listing of the COBOL source code for viewing. Additional information about this program may be obtained by sending an e-mail to: helpdesk@simotime.com
The SimoJUST routine (or callable program) will justify (center, left or right) a text string within a field and insert the appropriate leading and/or trailing space characters. If the requirement is to right-adjust, zero-fill a numeric field that will contain all digits and be properly aligned to the units position then refer to the right-adjust, zero-fill routine (or simora12.htm).
The following is the syntax for calling the right-adjust routine (SIMOJUST.CBL).
call 'SIMOJUST' using JUST-PASS-AREA
The callable justify routine will accept a string of text up to forty-eight (48) characters. A Working Storage data structure for calling the SIMOJUST routine is required. A copy file (PASSJUST.CPY) is provided with the following fields defined.
*****************************************************************
* Data Structure or Pass Area used for calling SIMOJUST. *
*****************************************************************
* Copyright (C) 1987-2004 SimoTime Enterprises *
* All Rights Reserved *
*****************************************************************
* Provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
01 JUST-PASS-AREA.
05 JUST-REQUEST PIC X(8).
05 JUST-RESPOND PIC 9(4).
05 JUST-SOURCE PIC X(60).
05 JUST-TARGET PIC X(60).
*! PASSJUST - End-of-Copy File...
The following table is an overview of the data strings used in the pass area.
| Parameter | Description | ||||||
| JUST-REQUEST | This is an eight character data string and should contain the
following in upper case.
|
||||||
| JUST-RESPOND | This is a four byte binary data string and is used by the conversion routine to pass a return code. If the conversion request is successful the value in this data string will be zero. | ||||||
| JUST-SOURCE | This is the sixty (60) byte input for the SimoJUST routine. It is not modified by the justify routine. | ||||||
| JUST-TARGET | This is the sixty (60) byte output for the SimoJUST routine. The requested text string is copied to this field in a format that is centered, right-adjusted of left-adjusted based on the JUST-REQUEST. |
The following is the COBOL Source Code.
IDENTIFICATION DIVISION.
PROGRAM-ID. SIMOJUST.
AUTHOR. SIMOTIME ENTERPRISES.
*****************************************************************
* Copyright (C) 1987-2009 SimoTime Enterprises, LLC. *
* *
* All rights reserved. Unpublished, all rights reserved under *
* copyright law and international treaty. Use of a copyright *
* notice is precautionary only and does not imply publication *
* or disclosure. *
* *
* Permission to use, copy, modify and distribute this software *
* for any non-commercial purpose and without fee is hereby *
* granted, provided the SimoTime copyright notice appear on all *
* copies of the software. The SimoTime name or Logo may not be *
* used in any advertising or publicity pertaining to the use *
* of the software without the written permission of SimoTime *
* Enterprises. *
* *
* Permission to use, copy, modify and distribute this software *
* for any commercial purpose requires a fee to be paid to *
* SimoTime Enterprises. Once the fee is received by SimoTime *
* the latest version of the software will be delivered and a *
* license will be granted for use within an enterprise, *
* provided the SimoTime copyright notice appear on all copies *
* of the software. The SimoTime name or Logo may not be used *
* in any advertising or publicity pertaining to the use of the *
* software without the written permission of SimoTime *
* Enterprises. *
* *
* SimoTime Enterprises makes no warranty or representations *
* about the suitability of the software for any purpose. It is *
* provided "AS IS" without any express or implied warranty, *
* including the implied warranties of merchantability, fitness *
* for a particular purpose and non-infringement. SimoTime *
* Enterprises shall not be liable for any direct, indirect, *
* special or consequential damages resulting from the loss of *
* use, data or projects, whether in an action of contract or *
* tort, arising out of or in connection with the use or *
* performance of this software *
* *
* SimoTime Enterprises *
* 15 Carnoustie Drive *
* Novato, CA 94949-5849 *
* 415.883.6565 *
* *
* RESTRICTED RIGHTS LEGEND *
* Use, duplication, or disclosure by the Government is subject *
* to restrictions as set forth in subparagraph (c)(1)(ii) of *
* the Rights in Technical Data and Computer Software clause at *
* DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of *
* Commercial Computer Software - Restricted Rights at 48 *
* CFR 52.227-19, as applicable. Contact SimoTime Enterprises, *
* 15 Carnoustie Drive, Novato, CA 94949-5849. *
* *
*****************************************************************
* This program is provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* *
*****************************************************************
*
*****************************************************************
* Source Member: SIMOJUST.CBL
* Copy Files: PASSJUST.CPY
*****************************************************************
*
* SIMOJUST - Justify (or position) a text string within a field
* based on the caller's request to center, left or right justify.
*
* EXECUTION or CALLING PROTOCOL
* -----------------------------
* CALL 'SIMOJUST' USING JUST-PASS-AREA.
*
*****************************************************************
*
* MAINTENANCE
* -----------
* 1988/02/27 Simmons, Created program.
* 1988/02/27 Simmons, No changes to date.
*
*****************************************************************
*
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Z-PTR-1 pic 9(3) value 0.
01 Z-PTR-2 pic 9(3) value 0.
01 Z-MAX-1 pic 9(3) value 0.
01 Z-MAX-2 pic 9(3) value 0.
01 FIRST-BYTE pic 9(3) value 0.
01 FINAL-BYTE pic 9(3) value 0.
01 LENGTH-OF-STRING pic 9(3) value 0.
*****************************************************************
LINKAGE SECTION.
COPY PASSJUST.
*****************************************************************
PROCEDURE DIVISION using JUST-PASS-AREA.
perform INITIALIZE-FIELDS
perform until Z-PTR-1 > Z-MAX-1
if JUST-SOURCE(Z-PTR-1:1) not = SPACE
if FIRST-BYTE = 0
add Z-PTR-1 to ZERO giving FIRST-BYTE
end-if
add Z-PTR-1 to ZERO giving FINAL-BYTE
end-if
add 1 to Z-PTR-1
end-perform
compute LENGTH-OF-STRING = FINAL-BYTE - FIRST-BYTE + 1
evaluate JUST-REQUEST
when 'CENTER ' perform REQUEST-CENTER
when 'LEFT ' perform REQUEST-LEFT
when 'RIGHT ' perform REQUEST-RIGHT
when other add 8 to ZERO giving JUST-RESPOND
end-evaluate
GOBACK.
*****************************************************************
INITIALIZE-FIELDS.
add 16 to ZERO giving JUST-RESPOND
move ZERO to Z-PTR-1
move ZERO to Z-PTR-2
move ZERO to FIRST-BYTE
move ZERO to FINAL-BYTE
move ZERO to LENGTH-OF-STRING
move SPACES to JUST-TARGET
add length of JUST-SOURCE to ZERO giving Z-MAX-1
add length of JUST-TARGET to ZERO giving Z-MAX-2
exit.
*****************************************************************
REQUEST-CENTER.
compute Z-PTR-2 = (Z-MAX-2 - LENGTH-OF-STRING) / 2 + 1
move JUST-SOURCE(FIRST-BYTE:LENGTH-OF-STRING)
to JUST-TARGET(Z-PTR-2:LENGTH-OF-STRING)
move ZERO to JUST-RESPOND
exit.
*****************************************************************
REQUEST-LEFT.
add 1 to ZERO giving Z-PTR-2
move JUST-SOURCE(FIRST-BYTE:LENGTH-OF-STRING)
to JUST-TARGET(Z-PTR-2:LENGTH-OF-STRING)
move ZERO to JUST-RESPOND
exit.
*****************************************************************
REQUEST-RIGHT.
compute Z-PTR-2 = (Z-MAX-2 - LENGTH-OF-STRING) + 1
move JUST-SOURCE(FIRST-BYTE:LENGTH-OF-STRING)
to JUST-TARGET( Z-PTR-2:LENGTH-OF-STRING)
move ZERO to JUST-RESPOND
exit.
*****************************************************************
* This example is provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
The purpose of this document is to provide a COBOL Source member for viewing.
Permission to use, copy, modify and distribute this software for any commercial purpose requires a fee to be paid to Simotime Enterprises. Once the fee is received by SimoTime the latest version of the software will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.
Permission to use, copy, modify and distribute this software for a non-commercial purpose and without fee is hereby granted, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.
SimoTime Enterprises makes no warranty or representations about the suitability of the software for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software.
You may view the complete list of SimoTime callable Modules or Driver Programs at http://www.simotime.com/simomods.htm.
This item will provide a link to a suite of sample programs that use the SimoJUST routine.
Check out The SimoTime Library for a wide range of topics for Programmers, Project Managers and Software Developers.
To review all the information available on this site start at The SimoTime Home Page .
Check out The SimoTime Glossary for a list of terms and definitions used in the documents provided by SimoTime.
If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com
We appreciate your comments and feedback.
Founded in 1987, SimoTime Enterprises is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com
| Return-to-Top |
| Copyright © 1987-2010 SimoTime Enterprises All Rights Reserved |
| When technology complements business |
| http://www.simotime.com |