Validate a Street Address
When technology complements business   COBOL parses a Street Address
Copyright © 1987-2008  SimoTime Enterprises, LLC  All Rights Reserved  http://www.simotime.com

 
Introduction Version 04.03.12
  Sample Input and Output
  Application Flowchart
  Call Interface
  The CMD Members
 
  CMD, Run the Demonstration Program
  CMD, Create the Input File
  The JCL Members
 
  JCL, Run the Demonstration Program
  JCL, Create the Input File
  The COBOL Demonstration Program
  The COBOL Edit Routine for Street Address
  The COBOL Parsing Routine
  Copy File for the Pass Area
  Summary
 
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Comments or Suggestions
  About SimoTime

Introduction
(Next) (Previous) (Table-of-Contents)

The objective of this suite of programs is to examine a data string containing a street address and produce a new data string with an edited version of the street address.

1. Convert to an upper and lower case format.
2. Compress leading and repetitive space characters.
3. Identify Post Office Box addresses
4. Provide option to standardize words (i.e. change "bl" to "Blvd").
5. Calculate the length of the text strings within the address fields.

The parsing routine uses reference modification to identify the position of the first significant character after a delimiter character. This approach compensates for multiple leading or embedded delimiter characters. For example, if the delimiter character is a space then leading spaces will be ignored and multiple, embedded spaces will be treated as a single space.

This suite of programs provides a demonstration program and a callable program to parse a field or data string. The DISPLAY function of COBOL is used by the demonstration program to display the results of the parsing routine. Both COBOL programs were written and tested using the COBOL/2 dialect. Also, both COBOL programs will work with COBOL for MVS and COBOL/370. A JCL member is provided to run the job as an MVS (or OS/390) batch job on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) running on a PC with Windows (refer to http://www.microfocus.com ).

In the world of programming there are many ways to solve a problem. This suite of programs is provided as a COBOL example of one of the possible solutions to the problem of parsing a data field.

Note: The source code for this example is available from the SimoTime Library under Download Directory at   www.simotime.com

Sample Input and Output
(Next) (Previous) (Table-of-Contents)

The following table shows examples of the editing and formatting capabilities of this suite of programs.

Control Street Address Conversion Description
INP    15 CARNOUSTIE DRIVE    
MOD 15 Carnoustie Drive Do a simple case conversion.
INP POST OFFICE BOX 9144    
POB P.O. Box 9144 Identify and format a Post Office Box.
INP    23 Post Street  
AOK 23 Post Street Input is OK, no conversion required.
INP   710 HOLLYWOOD BL.  
MOD 710 Hollywood Blvd Do case conversion and word substitution.
INP    P   O  box 32447  
POB P.O. Box 32447 Identify and format for a Post Office Box. Also, remove leading and multiple embedded spaces.
INP THE CORNER OF HOLLYWOOD AND VINE    
MOD The Corner of Hollywood and Vine Do case conversion and word substitution.
INP POB 27  
POB P.O. Box 27 Identify and format a Post Office Box.

Application Flowchart
(Next) (Previous) (Table-of-Contents)

The following is a flowchart of the demonstration for processing a street address to reformat and identify Post Office Box addresses. The BLUE boxes are unique to the mainframe and Micro Focus Mainframe Express. The RED boxes are unique to the PC with Windows and Micro Focus Net Express. The GREEN boxes are platform independent and will execute on the mainframe or a PC with Windows. Also, the GREEN boxes may be ported to a UNIX platform that is supported by Micro Focus COBOL.

               
Entry Point
OS390 or MFE
     
Entry Point
Net Express
  Entry Points  
 
     
 
     
CBLSTRJ1
jcl
     
CBLSTRE1
cmd
  Start the street address processing example  
 
     
 
     
IEFBR14
cmd
     
If Exist
stmt
  Delete previously created street address output file  
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
SIMOADR1
qsam
     
     
     
CBLSTRC1
cobol
     
     
     
SIMOADR2
qsam
  Read the input file (SIMOADR1) containing street addresses and create a new file (SIMOADR2) containing edited street addresses.  
   
 
     
     
     
SIMOROAD
cobol
  Case conversion, Word-substitution, Remove leading and multiple embedded spaces and identify PO Box addresses.  
   
 
 
 
     
   
 
 
SIMOPARS
cobol
  Parse the words within the address field  
   
EOJ
      End-of-Job  
               

Call Interface
(Next) (Previous) (Table-of-Contents)

The callable interface is as follows. The following data structure needs to be defined in Working Storage. A copy file (PASSROAD.CPY) is provided with this suite of sample programs.

      *****************************************************************
      *           Data Structure used for calling SIMOROAD.           *
      *****************************************************************
      *         Copyright (C) 1987-2006 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  ROAD-PASS-AREA.
           05  RDPA-REQUEST    PIC X(8).
           05  RDPA-RESULT     PIC S9(9)   COMP.
           05  RDPA-ADR1-CNTL  PIC X(4).
           05  RDPA-ADR1-DATA  PIC X(128).
           05  RDPA-ADR1-SIZE  PIC 9(5).
           05  RDPA-ADR2-CNTL  PIC X(4).
           05  RDPA-ADR2-DATA  PIC X(256).
           05  RDPA-ADR2-SIZE  PIC 9(5).

To call the routine (SIMOROAD) the fields for the pass area need to be initialized. The following shows an example of initializing the pass area fields and making the call.

      *>           Prepare linkage section and call SimoROAD...
                   move 'UNK ' to SYSADR2-CNTL-01
                   move 'SIMOROAD'      to RDPA-REQUEST
                   move SYSADR1-CNTL-01 to RDPA-ADR1-CNTL
                   move SYSADR1-DATA-01 to RDPA-ADR1-DATA
                   call 'SIMOROAD' using ROAD-PASS-AREA

The following is a brief description of each of the fields used within the pass area (ROAD-PASS-AREA).

Field Name Description
RDPA-REQUEST  Type of request, must be "SIMOROAD" for parsing. This item is provided by the calling program and is not modified by the parse and edit routine.
RDPA-RESULT This is an indicator as to the success or failure of the request. A value of zero (0000) indicates the routine was successful. A non-zero value indicates a failure.
RDPA-ADR1-CNTL This is a four byte string that is used to specify input data. This string should contain "INP ". This item is provided by the calling program and is not modified by the parse and edit routine.
RDPA-ADR1-DATA This string must contain the street address to be parsed and edited. This string is not modified by the parse and edit routine.
RDPA-ADR1-SIZE This is the size of the actual text within the RDPA-ADR1-DATA string. This item is created by the parse and edit routine.
RDPA-ADR2-CNTL  This is a four byte string that is used to specify the result of the parse and edit routine for the input street address. This item is created by the parse and edit routine.
RDPA-ADR2-DATA This string will contain the street address that is created by the parse and edit routine.
RDPA-ADR2-SIZE This is the size of the actual text within the RDPA-ADR2-DATA string. This item is created by the parse and edit routine.

The CMD Members
(Next) (Previous) (Table-of-Contents)

Two CMD members are provided. This first CMD member CBLSTRE1.CMD will run the demonstration program. The second CMD member CBLSTRE2.CMD is used to create the input data file that is used by the first CMD member.

CMD Member, Run the Demonstration Program
(Next) (Previous) (Table-of-Contents)

The following is the Windows CMD member (CBLSTRE1.CMD) required to run the mainline program. The SET statement will need to be modified for unique PC requirements.

@echo OFF
rem  * *******************************************************************
rem  *                   This program is provided by:                    *
rem  *                    SimoTime Enterprises, LLC                      *
rem  *           (C) Copyright 1987-2006 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Read a file of  Street Address, create edited file.
rem  * Author - SimoTime Enterprises
rem  * Date   - January 24, 1996
rem  *
rem  * The job will read an 80-byte file that contains street address
rem  * record. The job will then edit the street address and identify
rem  * PO Boxes. A new file if edited street addresses will be created.
rem  *
rem  * This set of programs will run on a Personal Computer with Windows
rem  * and Micro Focus Net Express.
rem  *
rem  *    ************
rem  *    * CblStrE1 *
rem  *    ********cmd*
rem  *         *
rem  *    ************
rem  *    * If Exist *
rem  *    *******stmt*
rem  *         *
rem  *    ************     ************     ************
rem  *    * SimoEXEC ******* SIMOLOGS ******* CONSOLE  *
rem  *    ********cbl*  *  ********cbl*  *  ************
rem  *         *        *                *
rem  *         *        *                *  ************
rem  *         *        *                ****  SYSLOG  *
rem  *         *        *                   ********txt*
rem  *         *        *
rem  *         *        **************************
rem  *         *                                 *
rem  *         *           ************     ************     ************
rem  *         *           * SIMOADR1 ******* CblStrC1 ******* SIMOADR2 *
rem  *         *           ********txt*     ********cbl*     ********csv*
rem  *         *                                 *
rem  *         *                            ************
rem  *         *                            * SIMOROAD *
rem  *         *                            ********cbl*
rem  *         *                                 *
rem  *         *                            ************
rem  *         *                            * SIMOPARS *
rem  *         *                            ********cbl*
rem  *         *
rem  *         *
rem  *    ************
rem  *    *   EOJ    *
rem  *    ************
rem  *
rem  *
rem  * *******************************************************************
rem  * Step   1   Delete any previously created file...
rem  *
     set syslog=d:\simoNXE4\AN01\datawrk1\SYSLOGT1.TXT
rem  *
     SimoEXEC NOTE *******************************************************CblStrE1
     SimoEXEC NOTE Starting JobName CblStrE1
:DeleteQSAM
     SimoEXEC NOTE Identify JobStep DeleteQSAM
     set SIMOADR1=d:\SimoNXE4\AN01\DataAsc1\SIMOADR1.TXT
     set SIMOADR2=d:\SimoNXE4\AN01\DataWrk1\SIMOADR2.TXT
     if exist %SIMOADR2% del %SIMOADR2%
rem  *
rem  * *******************************************************************
rem  * Step   2   Edit input, create a new output file...
rem  *
:ExecuteStreetAddressEditRoutine
     SimoEXEC NOTE Identify JobStep ExecuteStreetAddressEditRoutine
     SimoEXEC EXEC CBLSTRC1
     if exist %SIMOADR2% SimoEXEC NOTE Produced %SIMOADR2%
     SimoEXEC NOTE Finished JobName CblStrE1
     if not "%1" == "nopause" pause

CMD Member, Create the Input File
(Next) (Previous) (Table-of-Contents)

The following is the Windows CMD member(CBLSTRE2.CMD) that creates the input data file.. The SET statement will need to be modified for unique PC requirements.

@echo OFF
rem  * *******************************************************************
rem  *                   This program is provided by:                    *
rem  *                    SimoTime Enterprises, LLC                      *
rem  *           (C) Copyright 1987-2006 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Create a Sequential Data Set on disk using ECHO function.
rem  * Author - SimoTime Enterprises
rem  * Date   = January 24, 1996
rem  *
rem  * The first job step (DeleteQSAM) will delete any previously created
rem  * file. The second job step (CreateQSAM) will create a new file.
rem  *
rem  * This set of programs will run on a Personal Computer with Windows
rem  * and Micro Focus Net Express.
rem  *
     SimoEXEC NOTE  *******************************************************CblStrE2
     SimoEXEC NOTE  Starting JobName CblStrE2
     set syslog=d:\simoNXE4\AN01\datawrk1\SYSLOGT1.TXT
rem  *
rem  * *******************************************************************
rem  * Step   1 of 2  Delete previously created QSAM file...
rem  *
:DeleteQSAM
     SimoEXEC NOTE  Identify JobStep DeleteQSAM
     set SIMOADR1=d:\SimoNXE4\AN01\DataAsc1\SIMOADR1.TXT
     if exist %SIMOADR1% del %SIMOADR1%
rem  *
rem  * *******************************************************************
rem  * Step   2 of 2  Create and populate a new QSAM file...
rem  *
:CreateQSAM
     SimoEXEC NOTE  Identify JobStep CreateQSAM
rem  *....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
echo INP   15  CARNOUSTIE DRIVE >>%SIMOADR1%
echo INP POST OFFICE BOX 9144   >>%SIMOADR1%
echo INP 123 MAIN STREET        >>%SIMOADR1%
echo INP POB 27                 >>%SIMOADR1%
echo INP 1317 ST. CHARLES AVE.  >>%SIMOADR1%
echo INP 23 Post Street         >>%SIMOADR1%
echo INP PO BOX 21637           >>%SIMOADR1%
echo INP 710 HOLLYWOOD BL.      >>%SIMOADR1%
echo INP 1271 MACDOUGAL LANE    >>%SIMOADR1%
echo INP 14 VAN NESS AVENUE     >>%SIMOADR1%
echo INP 77 SUNSET BL           >>%SIMOADR1%
echo INP P.O. BOX 1665          >>%SIMOADR1%
echo INP PO 94949-5849          >>%SIMOADR1%
echo INP 777 Seventh Avenue     >>%SIMOADR1%
echo INP PO   BOX 12638         >>%SIMOADR1%
echo INP    P   O   box 32447                             >>%SIMOADR1%
echo INP 1564 Alameda de la Loma                          >>%SIMOADR1%
echo INP THE CORNER OF HOLLYWOOD AND VINE                 >>%SIMOADR1%
echo INP 16 LARKSPUR LANDING CIRCLE, SUITE 116            >>%SIMOADR1%
echo INP pO 0123456789 CAN you FiX tHiS AnD THAT TEst bL. >>%SIMOADR1%
echo INP 17 LINCOLN WAY, APT 101D                         >>%SIMOADR1%
echo INP 1454 Po Way                                      >>%SIMOADR1%
echo INP 1656 SOUTH EVANS AVE                             >>%SIMOADR1%
     if exist %SIMOADR1% SimoEXEC NOTE Produced %SIMOADR1%
     SimoEXEC NOTE  Finished JobName CblStrE2
     if not "%1" == "nopause" pause

The JCL Members
(Next) (Previous) (Table-of-Contents)

Two JCL members are provided. This first JCL member CBLSTRJ1.JCL will run the demonstration program. The second JCL member CBLSTRJ2.JCL is used to create the input data file that is used by the first JCL member.

JCL Member, Run the Demonstration Program
(Next) (Previous) (Table-of-Contents)

The following is the mainframe JCL (CBLSTRJ1.JCL) required to run the mainline program. The JOB and DD statements will need to be modified for unique mainframe requirements.

//CBLSTRJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2006 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Read a file containing street addresses, write output.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* The job will read an 80-byte file that contains street address
//* information. The job will also write a file containing the results
//* of the street address parse and edit functions..
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//*                     ************
//*                     * CBLSTRJ1 *
//*                     ********jcl*
//*                          *
//*                     ************
//*                     * IEFBR14  *
//*                     ********utl*
//*                          *
//*    ************     ************     ************
//*    * SIMOADR1 *-----* CBLSTRC1 *-----* SIMOADR2 *
//*    ********dat*     ********cbl*     ********dat*
//*                          *   *
//*                          *   *       ************
//*                          *   ***CALL** SIMOROAD *
//*                          *           ********cbl*
//*                          *             *
//*                          *             *       ************
//*                          *             ***CALL** SIMOPARS *
//*                          *                     ********cbl*
//*                     ************
//*                     *   EOJ    *
//*                     ************
//*
//* *******************************************************************
//* Step   1 of 2  Delete any previously created file...
//*
//QSAMDELT EXEC PGM=IEFBR14
//SIMOADR2  DD  DSN=SIMOTIME.DATA.SIMOADR2,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=256,BLKSIZE=2560,DSORG=PS)
//*
//* *******************************************************************
//* Step   2 of 2  Edit input, create a new output file...
//*
//EXECDAT1 EXEC PGM=CBLSTRC1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//SIMOADR1 DD  DSN=SIMOTIME.DATA.SIMOADR1,DISP=SHR
//SIMOADR2 DD  DSN=SIMOTIME.DATA.SIMOADR2,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=256,BLKSIZE=2560,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//

JCL Member, Create the Input File
(Next) (Previous) (Table-of-Contents)

The following is the mainframe JCL member(CBLSTRJ2.JCL) that creates the input data file.. The JOB and DD statements will need to be modified for unique mainframe requirements.

//CBLSTRJ2 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2006 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create a Sequential Data Set on disk using IEBGENER.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* The first job step (DELTQSAM) will delete any previously created
//* file. The second job step (CRTQNAME) will create a new file.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//* *******************************************************************
//* Step   1 of 2  Delete any previously created file...
//*
//QSAMDELT EXEC PGM=IEFBR14
//SIMOADR1 DD  DSN=SIMOTIME.DATA.SIMOADR1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   2 of 2  Create and populate a new QSAM file...
//*
//QCRTDIN1 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
INP   15  CARNOUSTIE DRIVE
INP POST OFFICE BOX 9144
INP 123 MAIN STREET
INP POB 27
INP 1317 ST. CHARLES AVE.
INP 23 Post Street
INP PO BOX 21637
INP 710 HOLLYWOOD BL.
INP 1271 MACDOUGAL LANE
INP 14 VAN NESS AVENUE
INP 77 SUNSET BL
INP P.O. BOX 1665
INP PO 94949-5849
INP 777 Seventh Avenue
INP PO   BOX 12638
INP    P   O   box 32447
INP 1564 Alameda de la Loma
INP THE CORNER OF HOLLYWOOD AND VINE
INP 16 LARKSPUR LANDING CIRCLE, SUITE 116
INP pO 0123456789 CAN you FiX tHiS AnD THAT TEst bL.
INP 17 LINCOLN WAY, APT 101D
INP 1454 Po Way
INP 1656 SOUTH EVANS AVE
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.SIMOADR1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//

The COBOL Demonstration Program
(Next) (Previous) (Table-of-Contents)

This program (CBLSTRC1.CBL) was written to test and demonstrate the calling of a COBOL program (SIMOROAD.CBL) that does the editing of a field or data string containing the street address. SIMOROAD calls SIMOPARS.CBL to do the parsing of the street address information into words.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLSTRC1.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2006 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: CBLSTRC1.CBL
      * Copy Files:    PASSROAD.CPY
      * Calls to:      SIMOROAD
      *                Copy Files:    PASSPARS.CPY
      *                Calls to:      SIMOPARS
      *****************************************************************
      *
      *                     ************
      *                     * CBLSTRJ1 *
      *                     ********jcl*
      *                          *
      *                     ************
      *                     * IEFBR14  *
      *                     ********utl*
      *                          *
      *    ************     ************     ************
      *    * SIMOADR1 *-----* CBLSTRC1 *-----* SIMOADR2 *
      *    ********dat*     ********cbl*     ********dat*
      *                          *   *
      *                          *   *       ************
      *                          *   ***call** SIMOROAD *
      *                          *           ********cbl*
      *                          *                *
      *                          *                *       ************
      *                          *                ***call** SIMOPARS *
      *                          *                        ********cbl*
      *                     ************
      *                     *   EOJ    *
      *                     ************
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT SIMOADR1-FILE  ASSIGN to      SIMOADR1
                  ORGANIZATION is SEQUENTIAL
                  ACCESS MODE  is SEQUENTIAL
                  FILE STATUS  is SIMOADR1-STATUS.
           SELECT SIMOADR2-FILE  ASSIGN to      SIMOADR2
                  ORGANIZATION is SEQUENTIAL
                  ACCESS MODE  is SEQUENTIAL
                  FILE STATUS  is SIMOADR2-STATUS.

      *****************************************************************
       DATA DIVISION.
       FILE SECTION.
       FD  SIMOADR1-FILE
           DATA RECORD    is SIMOADR1-RECORD
           .
       01  SIMOADR1-RECORD.
           05  SIMOADR1-CNTL-01 pic X(4).
           05  SIMOADR1-DATA-01 pic X(76).

       FD  SIMOADR2-FILE
           DATA RECORD    is SIMOADR2-RECORD
           .
       01  SIMOADR2-RECORD.
           05  SIMOADR2-CNTL-01 pic X(4)       value SPACES.
           05  SIMOADR2-SIZE-01 pic 9(5)       value 0.
           05  SIMOADR2-BLANK   pic X          value SPACE.
           05  SIMOADR2-DATA-01 pic X(246)     value SPACES.

       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CBLSTRC1 '.
           05  T2 pic X(32) value 'Processing a Street Address     '.
           05  T3 pic X(10) value ' v04.03.11'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLSTRC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2006 '.
           05  C3 pic X(28) value '  SimoTime Enterprises, LLC '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* CBLSTRC1 '.
           05  C2 pic X(32) value 'Thank you for using this sample '.
           05  C3 pic X(32) value 'by SimoTime Enterprises, LLC    '.
           05  C4 pic X(04) value '    '.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* CBLSTRC1 '.
           05  C2 pic X(32) value 'Please send comments or suggesti'.
           05  C3 pic X(32) value 'ons to helpdesk@simotime.com    '.
           05  C4 pic X(04) value '    '.

       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CBLSTRC1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

       01  SIMOADR1-STATUS.
           05  SIMOADR1-STATUS-L   pic X.
           05  SIMOADR1-STATUS-R   pic X.
       01  SIMOADR1-EOF            pic X       value 'N'.
       01  SIMOADR1-OPEN-FLAG      pic X       value 'C'.

       01  SIMOADR2-STATUS.
           05  SIMOADR2-STATUS-L   pic X.
           05  SIMOADR2-STATUS-R   pic X.
       01  SIMOADR2-EOF            pic X       value 'N'.
       01  SIMOADR2-OPEN-FLAG      pic X       value 'C'.

       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.

       01  TWO-BYTES.
           05  TWO-BYTES-LEFT      pic X.
           05  TWO-BYTES-RIGHT     pic X.
       01  TWO-BYTES-BINARY        redefines   TWO-BYTES pic 9(4) comp.

       01  APPL-RESULT             pic S9(9)   comp.
           88  APPL-AOK            value 0.
           88  APPL-EOF            value 16.

       01  SIMOADR1-TOTAL.
           05  filler       pic X(23)  value 'SIMOADR1 line count is '.
           05  SIMOADR1-LOC pic 9(7)    value 0.

       01  SUB-AOK         pic 9(7)    value 0.
       01  SUB-MOD         pic 9(7)    value 0.
       01  SUB-POB         pic 9(7)    value 0.
       01  SUB-POX         pic 9(7)    value 0.
       01  SUB-OTH         pic 9(7)    value 0.
       01  SUB-TOT         pic 9(7)    value 0.

      *****************************************************************
      * The following copy file of the pass area for calling SIMODATE,
      * the date editing routine.
      *****************************************************************
       COPY PASSROAD.

      *****************************************************************
       PROCEDURE DIVISION.
           perform Z-POST-COPYRIGHT
           perform SIMOADR1-OPEN
           perform SIMOADR2-OPEN
           initialize SIMOADR2-RECORD

           perform until SIMOADR1-STATUS not = '00'
               perform SIMOADR1-READ
               if  SIMOADR1-STATUS = '00'
                   add 1 to SIMOADR1-LOC
      *>           Prepare linkage section and call SimoROAD...
                   move 'UNK ' to SIMOADR2-CNTL-01
                   move 'SIMOROAD'      to RDPA-REQUEST
                   move SIMOADR1-CNTL-01 to RDPA-ADR1-CNTL
                   move SIMOADR1-DATA-01 to RDPA-ADR1-DATA
                   call 'SIMOROAD' using ROAD-PASS-AREA

                   if  RDPA-RESULT = 0
      *>               The following two statements are for
      *>               demonstration purposes.
      *>               Write Input record to output file.
                       initialize SIMOADR2-RECORD
                       move SIMOADR1-CNTL-01 to SIMOADR2-CNTL-01
                       add RDPA-ADR1-SIZE   to ZERO
                                        giving SIMOADR2-SIZE-01
                       move SIMOADR1-DATA-01 to SIMOADR2-DATA-01
                       perform SIMOADR2-WRITE
                       initialize SIMOADR2-RECORD
                       move RDPA-ADR2-CNTL to SIMOADR2-CNTL-01
                       add RDPA-ADR2-SIZE  to ZERO
                                       giving SIMOADR2-SIZE-01
                       move RDPA-ADR2-DATA to SIMOADR2-DATA-01
                       perform SIMOADR2-WRITE
                       perform CALCULATE-SUB-TOTALS
                   else
                       move RDPA-ADR2-CNTL to SIMOADR2-CNTL-01
                       move RDPA-ADR2-DATA to SIMOADR2-DATA-01
                       move SIMOADR2-RECORD to MESSAGE-TEXT
                       perform Z-DISPLAY-CONSOLE-MESSAGE
                       perform SIMOADR2-WRITE
                       move SIMOADR1-DATA-01 to SIMOADR2-DATA-01
                       perform SIMOADR2-WRITE
                   end-if
               end-if
           end-perform

           perform DISPLAY-SUB-TOTALS
           perform Z-THANK-YOU

           GOBACK.

      *****************************************************************
      * The following routines are in alphabetical sequence..         *
      *****************************************************************

      *****************************************************************
       CALCULATE-SUB-TOTALS.
           evaluate RDPA-ADR2-CNTL
               when 'AOK ' add 1 to SUB-AOK
               when 'MOD ' add 1 to SUB-MOD
               when 'POB ' add 1 to SUB-POB
               when 'PO? ' add 1 to SUB-POX
               when OTHER  add 1 to SUB-OTH
           end-evaluate
           exit.

      *****************************************************************
       DISPLAY-SUB-TOTALS.
           add SUB-AOK SUB-MOD SUB-POB SUB-POX SUB-OTH to SUB-TOT
           move 'AOK .... ' to MESSAGE-TEXT
           move SUB-AOK     to MESSAGE-TEXT(10:7)
           perform Z-DISPLAY-CONSOLE-MESSAGE
           move 'MOD .... ' to MESSAGE-TEXT
           move SUB-MOD     to MESSAGE-TEXT(10:7)
           perform Z-DISPLAY-CONSOLE-MESSAGE
           move 'POB .... ' to MESSAGE-TEXT
           move SUB-POB     to MESSAGE-TEXT(10:7)
           perform Z-DISPLAY-CONSOLE-MESSAGE
           move 'PO? .... ' to MESSAGE-TEXT
           move SUB-POX     to MESSAGE-TEXT(10:7)
           perform Z-DISPLAY-CONSOLE-MESSAGE
           move 'Other .. ' to MESSAGE-TEXT
           move SUB-OTH     to MESSAGE-TEXT(10:7)
           move 'TOTAL .. ' to MESSAGE-TEXT
           move SUB-TOT     to MESSAGE-TEXT(10:7)
           perform Z-DISPLAY-CONSOLE-MESSAGE
           exit.

      *****************************************************************
      * I/O ROUTINES FOR SIMOADR1...                                  *
      *****************************************************************
       SIMOADR1-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close SIMOADR1-FILE
           if  SIMOADR1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'SIMOADR1-Failure-CLOSE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move SIMOADR1-STATUS to IO-STATUS
               perform Z-DISPLAY-CONSOLE-MESSAGE
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       SIMOADR1-READ.
           read SIMOADR1-FILE
           if  SIMOADR1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  SIMOADR1-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to SIMOADR1-EOF
               else
                   move 'SIMOADR1-Failure-GET...' to MESSAGE-TEXT
                   perform Z-DISPLAY-CONSOLE-MESSAGE
                   move SIMOADR1-STATUS to IO-STATUS
                   perform Z-DISPLAY-CONSOLE-MESSAGE
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       SIMOADR1-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open input SIMOADR1-FILE
           if  SIMOADR1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to SIMOADR1-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'SIMOADR1-Failure-OPEN...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move SIMOADR1-STATUS to IO-STATUS
               perform Z-DISPLAY-CONSOLE-MESSAGE
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * I/O ROUTINES FOR SIMOADR2...                                  *
      *****************************************************************
       SIMOADR2-WRITE.
           if  SIMOADR2-OPEN-FLAG = 'C'
               perform SIMOADR2-OPEN
           end-if
           write SIMOADR2-RECORD
           if  SIMOADR2-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  SIMOADR2-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if.
           if  APPL-AOK
               CONTINUE
           else
               move 'SIMOADR2-Failure-WRITE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move SIMOADR2-STATUS to IO-STATUS
               perform Z-DISPLAY-CONSOLE-MESSAGE
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       SIMOADR2-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open output SIMOADR2-FILE
           if  SIMOADR2-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to SIMOADR2-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'SIMOADR2-Failure-OPEN...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move SIMOADR2-STATUS to IO-STATUS
               perform Z-DISPLAY-CONSOLE-MESSAGE
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       SIMOADR2-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close SIMOADR2-FILE
           if  SIMOADR2-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'C' to SIMOADR2-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'SIMOADR2-Failure-CLOSE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move SIMOADR2-STATUS to IO-STATUS
               perform Z-DISPLAY-CONSOLE-MESSAGE
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative tasks         *
      * for this program.                                             *
      *****************************************************************
      *
      *****************************************************************
      * ABEND the program, post a message to the console and issue    *
      * a STOP RUN.                                                   *
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  MESSAGE-TEXT not = SPACES
               perform Z-DISPLAY-CONSOLE-MESSAGE
           end-if
           move 'PROGRAM-IS-ABENDING...'  to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE
           add 12 to ZERO giving RETURN-CODE
           STOP RUN
           exit.

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-CONSOLE-MESSAGE.
           if MESSAGE-TEXT-2 = SPACES
               display MESSAGE-BUFFER(1:79) upon console
           else
               display MESSAGE-BUFFER upon console
           end-if
           move all SPACES to MESSAGE-TEXT
           exit.

      ****************************************************************
      * Display the file status bytes. This routine will display as   *
      * two digits if the full two byte file status is numeric. If    *
      * second byte is non-numeric then it will be treated as a       *
      * binary number.                                                *
      *****************************************************************
       Z-DISPLAY-IO-STATUS.
           if  IO-STATUS not NUMERIC
           or  IO-STAT1    = '9'
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               display '* CBLSTRC1 File-Status-' IO-STAT1 '/'
                       TWO-BYTES-BINARY upon console
           else
               display '* CBLSTRC1 File-Status-' IO-STATUS upon console
           end-if
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE     upon console
           display SIM-COPYRIGHT upon console
           exit.

      *****************************************************************
       Z-THANK-YOU.
           display SIM-THANKS-01 upon console
           display SIM-THANKS-02 upon console
           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 COBOL Edit Routine for Street Address
(Next) (Previous) (Table-of-Contents)

This program does the editing of the street address. It does the case conversion, word substitution, identifies Post Office Box addresses and calculates the length of the text strings within the fields..

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    SIMOROAD.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2006 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: SIMOROAD.CBL
      * Copy Files:    PASSPARS.CPY
      * Calls to:      SIMOPARS
      *****************************************************************
      * MAINTENANCE
      * -----------
      * 1994/02/27 Simmons, Created program.
      * 1994/03/17 Simmons, Fixed bug to correct recalculation of the
      *            size of the edited street address.
      *
      *****************************************************************
       DATA DIVISION.
       WORKING-STORAGE SECTION.

       01  SIM-TITLE.
           05  T1 pic X(11) value '* SIMOROAD '.
           05  T2 pic X(32) value 'Processing a Street Address     '.
           05  T3 pic X(10) value ' v03.11.24'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* SIMOROAD '.
           05  C2 pic X(20) value 'Copyright 1987-2006 '.
           05  C3 pic X(28) value '  SimoTime Enterprises, LLC '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* SIMOROAD '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

       01  WORD-14                 pic X(14)   value SPACES.
       01  WORD-12                 pic X(12)   value SPACES.
       01  WORD-SIZE               pic 9(5)    value 0.

       01  X1                      pic 9(5)    value 0.
       01  X2                      pic 9(5)    value 0.
       01  X3                      pic 9(5)    value 0.

       01  LOWER-CASE  pic X(26)   value 'abcdefghijklmnopqrstuvwxyz'.
       01  UPPER-CASE  pic X(26)   value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

      *****************************************************************
      * The following copy file is the pass area for calling SIMOPARS,
      * the field parsing routine.
      *****************************************************************
       COPY PASSPARS.

      *****************************************************************
       LINKAGE SECTION.
       COPY PASSROAD.

      *****************************************************************
       PROCEDURE DIVISION using ROAD-PASS-AREA.
      *    perform Z-POST-COPYRIGHT
           move 'UNK ' to RDPA-ADR2-CNTL
           move SPACES to RDPA-ADR2-DATA
           add 16 to ZERO giving RDPA-RESULT

           evaluate RDPA-ADR1-CNTL
               when 'INP ' perform PROCESS-STREET-ADDRESS
               when OTHER  perform Z-ABEND-INVALID-REQUEST
           end-evaluate

           GOBACK.

      *****************************************************************
      * The following routines are in alphabetical sequence..         *
      *****************************************************************
      *
      *****************************************************************
      * This routine is used for debugging purposes,
      *****************************************************************
       ADDR-FUNCTION-DISPLAY-WORDS.
      *    Display the contents of the parsing tables.
           add 1 to ZERO giving X1
           perform until PRS-SIZE(X1) = 0
                      or PRS-POSITION(X1) = 0
                      or X1       > PRS-TABLE-MAX
                      or X1       > PRS-NUMBER-OF-ITEMS
               move X1 to MESSAGE-TEXT(6:5)
               move PRS-POSITION(X1) to MESSAGE-TEXT(19:4)
               move PRS-SIZE(X1) to MESSAGE-TEXT(32:4)
               if  PRS-SIZE(X1) < 20
                   move PRS-BUFFER(PRS-POSITION(X1):PRS-SIZE(X1))
                     to MESSAGE-TEXT(50:PRS-SIZE(X1))
               else
                   move PRS-BUFFER(PRS-POSITION(X1):19)
                     to MESSAGE-TEXT(50:19)
               end-if
               perform Z-DISPLAY-CONSOLE-MESSAGE
               add 1 to X1
           end-perform
           exit.

      *****************************************************************
      * Call the SIMOPARS routine to parse the Street Addres
      *****************************************************************
       ADDR-FUNCTION-PARSE.
      *>   Prepare control items for parsing.
           move '0' to PRS-REQUEST
           add 9 to ZERO giving PRS-STATUS
           move ' ' to PRS-DELIMITER
           move 'N' to PRS-TERMINATOR
           move ' ' to PRS-TERMINATOR-BYTE
           add 32 to ZERO giving PRS-TABLE-MAX
           add 128 to ZERO giving PRS-BUFFER-SIZE
      *>   Move the data string to the parsing buffer and call
      *>   the parsing routine.
           move RDPA-ADR1-DATA to PRS-BUFFER
           call 'SIMOPARS'   using PRS-PARAMETERS
           exit.

      *****************************************************************
       BUILD-NEW-STREET-ADDRESS.
           move SPACES to RDPA-ADR2-DATA
           inspect PRS-BUFFER(1:PRS-BUFFER-SIZE)
                   converting UPPER-CASE to LOWER-CASE
           add 1 to ZERO giving X1
           add 1 to ZERO giving X2
           perform until PRS-SIZE(X1) = 0
                      or PRS-POSITION(X1) = 0
                      or X1       > PRS-TABLE-MAX
                      or X1       > PRS-NUMBER-OF-ITEMS
               if  PRS-BUFFER(PRS-POSITION(X1):1) is NUMERIC
                   move PRS-BUFFER(PRS-POSITION(X1):PRS-SIZE(X1))
                     to RDPA-ADR2-DATA(X2:PRS-SIZE(X1))
                   inspect
                       RDPA-ADR2-DATA(X2:PRS-SIZE(X1))
                       converting LOWER-CASE to UPPER-CASE
                   add PRS-SIZE(X1) to X2
                   add 1              to X2
               else
                   perform BUILD-NEW-STREET-ADDRESS-100
               end-if
               add 1 to X1
           end-perform
           exit.

      *---------------------------------------------------------------*
       BUILD-NEW-STREET-ADDRESS-100.
           if  PRS-BUFFER(PRS-POSITION(X1):1) = 'p'
           and PRS-SIZE(X1)               < 5
               move SPACES to WORD-14
               move PRS-BUFFER(PRS-POSITION(X1):PRS-SIZE(X1))
                 to WORD-14
               perform BUILD-NEW-STREET-POSSIBLE-POB
           else
               perform BUILD-NEW-STREET-NORMAL-WORD
           end-if
           exit.

      *---------------------------------------------------------------*
       BUILD-NEW-STREET-POSSIBLE-POB.
           evaluate WORD-14
               when 'pob       ' perform BUILD-NEW-STREET-POSSIBLE-PO-1
               when 'pobox     ' perform BUILD-NEW-STREET-POSSIBLE-PO-1
               when 'p.o.box   ' perform BUILD-NEW-STREET-POSSIBLE-PO-1
               when 'pob.      ' perform BUILD-NEW-STREET-POSSIBLE-PO-1
               when 'po        ' perform BUILD-NEW-STREET-POSSIBLE-PO-2
               when 'p.o.      ' perform BUILD-NEW-STREET-POSSIBLE-PO-2
               when 'p.        ' perform BUILD-NEW-STREET-POSSIBLE-PO-3
               when 'p         ' perform BUILD-NEW-STREET-POSSIBLE-PO-3
               when 'post      ' perform BUILD-NEW-STREET-POSSIBLE-PO-3
               when OTHER        perform BUILD-NEW-STREET-NORMAL-WORD
           end-evaluate
           exit.

      *---------------------------------------------------------------*
       BUILD-NEW-STREET-POSSIBLE-PO-1.
           move 'POB ' to RDPA-ADR2-CNTL
           move 'P.O. Box '  to RDPA-ADR2-DATA(X2:9)
           add 9 to X2
           subtract RDPA-RESULT from RDPA-RESULT
           exit.

      *---------------------------------------------------------------*
       BUILD-NEW-STREET-POSSIBLE-PO-2.
           add X1 to 1 giving X3
           if  PRS-POSITION(X3) > 0
           and PRS-SIZE(X3) > 0
               if  PRS-BUFFER(PRS-POSITION(X3):4) = 'box '
                   move 'POB ' to RDPA-ADR2-CNTL
                   move 'P.O. Box '  to RDPA-ADR2-DATA(X2:9)
                   add 1 to X1
                   add 9 to X2
                   subtract RDPA-RESULT from RDPA-RESULT
               else
                   if  PRS-BUFFER(PRS-POSITION(X3):1) is NUMERIC
                       move 'POB ' to RDPA-ADR2-CNTL
                       move 'P.O. Box '  to RDPA-ADR2-DATA(X2:9)
                       add 9 to X2
                       subtract RDPA-RESULT from RDPA-RESULT
                   else
                       move 'PO? ' to RDPA-ADR2-CNTL
                       perform BUILD-NEW-STREET-NORMAL-WORD
                       subtract RDPA-RESULT from RDPA-RESULT
                   end-if
               end-if
           end-if
           exit.

      *---------------------------------------------------------------*
       BUILD-NEW-STREET-POSSIBLE-PO-3.
           add X1 to 1 giving X3
           if  PRS-POSITION(X3) > 0
           and PRS-SIZE(X3) > 0
               if  PRS-BUFFER(PRS-POSITION(X3):2) = 'o '
               or  PRS-BUFFER(PRS-POSITION(X3):3) = 'o. '
               or  PRS-BUFFER(PRS-POSITION(X3):7) = 'office '
                   add 1 to X3
                   if  PRS-BUFFER(PRS-POSITION(X3):4) = 'box '
                   and PRS-POSITION(X3) > 0
                   and PRS-SIZE(X3) > 0
                       move 'POB ' to RDPA-ADR2-CNTL
                       move 'P.O. Box '  to RDPA-ADR2-DATA(X2:9)
                       add 2 to X1
                       add 9 to X2
                       subtract RDPA-RESULT from RDPA-RESULT
                   else
                       if  PRS-BUFFER(PRS-POSITION(X3):1) is NUMERIC
                           move 'POB ' to RDPA-ADR2-CNTL
                           move 'P.O. Box '  to RDPA-ADR2-DATA(X2:9)
                           add 9 to X2
                           subtract RDPA-RESULT from RDPA-RESULT
                       else
                           move 'PO? ' to RDPA-ADR2-CNTL
                           perform BUILD-NEW-STREET-NORMAL-WORD
                           subtract RDPA-RESULT from RDPA-RESULT
                       end-if
                   end-if
               else
                   perform BUILD-NEW-STREET-NORMAL-WORD
               end-if
           end-if
           exit.

      *---------------------------------------------------------------*
       BUILD-NEW-STREET-NORMAL-WORD.
      *>   Test for possible word substitution...
           move SPACES to WORD-12
           if  PRS-SIZE(X1) < 13
               move PRS-BUFFER(PRS-POSITION(X1):PRS-SIZE(X1))
                 to WORD-12
               perform BUILD-NEW-STREET-SUB-WORD-ALL
           end-if

           if  WORD-12 = SPACES
               move PRS-BUFFER(PRS-POSITION(X1):PRS-SIZE(X1))
                 to RDPA-ADR2-DATA(X2:PRS-SIZE(X1))
               inspect RDPA-ADR2-DATA(X2:1)
                   converting LOWER-CASE to UPPER-CASE
               add PRS-SIZE(X1) to X2
               add 1              to X2
               subtract RDPA-RESULT from RDPA-RESULT
           else
               move WORD-12(1:WORD-SIZE)
                 to RDPA-ADR2-DATA(X2:WORD-SIZE)
               if  PRS-POSITION(X1) = 1
                   inspect RDPA-ADR2-DATA(X2:1)
                       converting LOWER-CASE to UPPER-CASE
               end-if
               add WORD-SIZE to X2
               add 1         to X2
               subtract RDPA-RESULT from RDPA-RESULT
           end-if
           exit.

      *---------------------------------------------------------------*
       BUILD-NEW-STREET-SUB-WORD-ALL.
           evaluate WORD-12
             when 'ave         ' move 'Avenue    '   to WORD-12
                                 add  6  to ZERO giving WORD-SIZE
             when 'ave.        ' move 'Avenue    '   to WORD-12
                                 add  6  to ZERO giving WORD-SIZE
             when 'bl          ' move 'Blvd      '   to WORD-12
                                 add  4  to ZERO giving WORD-SIZE
             when 'bl.         ' move 'Blvd      '   to WORD-12
                                 add  4  to ZERO giving WORD-SIZE
             when 'de          ' move 'de        '   to WORD-12
                                 add  2  to ZERO giving WORD-SIZE
             when 'la          ' move 'la        '   to WORD-12
                                 add  2  to ZERO giving WORD-SIZE
             when 'of          ' move 'of        '   to WORD-12
                                 add  2  to ZERO giving WORD-SIZE
             when 'and         ' move 'and       '   to WORD-12
                                 add  3  to ZERO giving WORD-SIZE
             when 'the         ' move 'the       '   to WORD-12
                                 add  3  to ZERO giving WORD-SIZE
             when 'macdougal   ' move 'MacDougal'    to WORD-12
                                 add  9  to ZERO giving WORD-SIZE
             when OTHER          move SPACES to WORD-12
           end-evaluate
           exit.

      *****************************************************************
       CALCULATE-BUFFER-SIZE-01.
           add PRS-NUMBER-OF-ITEMS to ZERO giving X1
           add PRS-POSITION(X1) to PRS-SIZE(X1) giving RDPA-ADR1-SIZE
           subtract 1 from RDPA-ADR1-SIZE
           exit.

      *****************************************************************
       CALCULATE-BUFFER-SIZE-02.
           if  RDPA-ADR2-DATA = SPACES
               move ZERO to RDPA-ADR2-SIZE
           else
               add length of RDPA-ADR2-DATA to ZERO giving X1
               add length of RDPA-ADR2-DATA to ZERO giving X3
               perform  until X1 not = X3
                           or X1     < 4
                 divide X3 by 2 giving X1
                 if  X1 > 0
                     if  RDPA-ADR2-DATA(X1 + 1:X3 - X1) = SPACES
                         add X1 to ZERO giving X3
                     end-if
                 end-if
               end-perform
               add 1 to ZERO giving RDPA-ADR2-SIZE
               move ZERO to X2
               perform until X2 = X3
                 add 1 to X2
                 if  RDPA-ADR2-DATA(X2:1) not = SPACE
                     add X2 to ZERO giving RDPA-ADR2-SIZE
                 end-if
               end-perform
           end-if
           exit.

      *****************************************************************
       COMPRESS-MULTIPLE-SPACES.
           move SPACES to RDPA-ADR2-DATA
           add 1 to ZERO giving X1
           add 1 to ZERO giving X2
           perform until PRS-SIZE(X1) = 0
                      or PRS-POSITION(X1) = 0
                      or X1       > PRS-TABLE-MAX
                      or X1       > PRS-NUMBER-OF-ITEMS
               move PRS-BUFFER(PRS-POSITION(X1):PRS-SIZE(X1))
                 to RDPA-ADR2-DATA(X2:PRS-SIZE(X1))
               add X2 to ZERO giving PRS-POSITION(X1)
               add PRS-SIZE(X1) to X2
               add 1 to X2
               add 1 to X1
           end-perform
           move SPACES to PRS-BUFFER
           move RDPA-ADR2-DATA to PRS-BUFFER
           move SPACES to RDPA-ADR2-DATA
           exit.

      *---------------------------------------------------------------*
       POST-TABLE-ITEM.
           move 'Item-nnnn, Offset-nnnn, Length-nnnn, Parameter - '
             to MESSAGE-TEXT(1:49)
           move X1 to MESSAGE-TEXT(6:4)
           move PRS-POSITION(X1) to MESSAGE-TEXT(19:4)
           move PRS-SIZE(X1) to MESSAGE-TEXT(32:4)
           if  PRS-SIZE(X1) < 20
               move PRS-BUFFER(PRS-POSITION(X1):PRS-SIZE(X1))
                 to MESSAGE-TEXT(50:PRS-SIZE(X1))
           else
               move PRS-BUFFER(PRS-POSITION(X1):19)
                 to MESSAGE-TEXT(50:19)
           end-if
           perform Z-DISPLAY-CONSOLE-MESSAGE
           exit.

      *****************************************************************
       PROCESS-STREET-ADDRESS.
           if  RDPA-ADR1-DATA = SPACES
           or  RDPA-ADR1-DATA = LOW-VALUES
               perform Z-ABEND-INVALID-INPUT
           else
               perform ADDR-FUNCTION-PARSE
               perform CALCULATE-BUFFER-SIZE-01

               if  PRS-STATUS = 0
      *            perform ADDR-FUNCTION-DISPLAY-WORDS
                   perform COMPRESS-MULTIPLE-SPACES
                   perform PROCESS-STREET-ADDRESS-100
                   perform CALCULATE-BUFFER-SIZE-02
               else
                   move 'Parsing Error' to RDPA-ADR2-DATA
                   move RDPA-ADR2-DATA to MESSAGE-TEXT
                   perform Z-DISPLAY-CONSOLE-MESSAGE
               end-if

           end-if.
           exit.

      *---------------------------------------------------------------*
       PROCESS-STREET-ADDRESS-100.
           perform BUILD-NEW-STREET-ADDRESS
           if  RDPA-ADR2-CNTL = 'UNK '
           and RDPA-ADR2-DATA not = SPACES
               if  RDPA-ADR1-DATA = RDPA-ADR2-DATA
                   move 'AOK ' to RDPA-ADR2-CNTL
                   subtract RDPA-RESULT from RDPA-RESULT
               else
                   move 'MOD ' to RDPA-ADR2-CNTL
                   subtract RDPA-RESULT from RDPA-RESULT
               end-if
               subtract RDPA-RESULT from RDPA-RESULT
           end-if
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative functions     *
      * for this program.                                             *
      *****************************************************************
      * ABEND the program, post a message to the console and issue    *
      * a STOP RUN.                                                   *
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  MESSAGE-TEXT not = SPACES
               perform Z-DISPLAY-CONSOLE-MESSAGE
           end-if
           move 'PROGRAM-IS-ABENDING...'  to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE
           add 12 to ZERO giving RETURN-CODE
           STOP RUN
           exit.

      *---------------------------------------------------------------*
       Z-ABEND-INVALID-REQUEST.
           add 18 to ZERO giving RDPA-RESULT
           move 'ERR ' to RDPA-ADR2-CNTL
           move 'Call to SimoROAD with invalid request'
             to RDPA-ADR2-DATA
           exit.

      *---------------------------------------------------------------*
       Z-ABEND-INVALID-INPUT.
           add 20 to ZERO giving RDPA-RESULT
           move 'ERR ' to RDPA-ADR2-CNTL
           move 'Call to SimoROAD with blank input address'
             to RDPA-ADR2-DATA
           exit.

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-CONSOLE-MESSAGE.
           if MESSAGE-TEXT-2 = SPACES
               display MESSAGE-BUFFER(1:79) upon console
           else
               display MESSAGE-BUFFER upon console
           end-if
           move all SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE     upon console
           display SIM-COPYRIGHT upon console
           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 COBOL Parsing Routine
(Next ) (Previous) (Table-of-Contents)

This program (SIMOPARS.CBL) was written to provide parsing capability of a data string. It uses "Reference Modification" to scan the data string.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    SIMOPARS.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2006 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: SIMOPARS.CBL
      * Copy Files     PASSPARS.CPY
      *****************************************************************
      *
      * SIMOPARS - Parse Buffer defined in pass area.
      *
      * CALLING PROTOCOL
      * ----------------
      * call 'SIMOPARS' using PRS-PARAMETERS
      *
      *    01  PRS-PARAMETERS.
      *        05  PRS-REQUEST          PIC X       VALUE '0'.
      *        05  PRS-STATUS           PIC 9(4).
      *        05  PRS-DELIMITER        PIC X       VALUE SPACE.
      *        05  PRS-KEEP-NULL-FIELDS PIC X       VALUE 'N'.
      *        05  PRS-SUSPEND          PIC X       VALUE 'N'.
      *        05  PRS-SUSPEND-BYTE     PIC X       VALUE SPACE.
      *        05  PRS-TERMINATOR       PIC X       VALUE 'N'.
      *        05  PRS-TERMINATOR-BYTE  PIC X       VALUE SPACE.
      *        05  PRS-BUFFER-SIZE      PIC 9(4)    VALUE 1024.
      *        05  PRS-BUFFER           PIC X(1024).
      *        05  PRS-TABLE-MAX        PIC 9(4)    VALUE 64.
      *        05  PRS-NUMBER-OF-ITEMS  PIC 9(4)    VALUE 0.
      *        05  PRS-LAST-SIG-BYTE    PIC 9(4)    VALUE 0.
      *        05  PRS-POSITION         OCCURS 64 TIMES
      *                                 PIC 9(4)    VALUE 0.
      *        05  PRS-SIZE             OCCURS 64 TIMES
      *
      * This routine uses reference modification to identify the
      * position of the first significant character after the
      * delimiter character. This approach compensates for multiple
      * leading or embedded delimiter characters. The string function
      * of COBOL does not handle leading spaces.
      *
      * For example, if the delimiter character is a space then
      * leading spaces will be ignored and multiple, embedded spaces
      * will be treated as a single space.
      *
      * MAINTENANCE
      * -----------
      * 1998/01/02 Simmons, CREATED PROGRAM.
      * 1998/01/02 Simmons, No changes to date...
      *
      ********************************