× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks for all your help with figuring out how to Range Canadian Zip Codes.
A few of you mentioned using a file containing all possible zip codes.
That method appealed to me more than others, so that is the one I used.
Below is the RPG program and some of the input and output of the
program.(Dan, now I'm laughing at the 32,000+ line program)

Frank

      *****************************************************************
      *
      *  PROGRAM      -  ZP47R004
      *  Description  -  Range Canadian Zip Codes
      *  Date         -  October 21, 2004
      *  Programmer   -  Frank Kany
      *
      *****************************************************************
      *
      * Zip Code file Containing City, State, Service Days, etc...
     FZP47P001  IF   E             DISK    PREFIX(X)
      *
      * Contains all Possible Canadian Zip Codes
     FCANADAZIP1IF   E           K DISK
      *
      * Output File that will contain all the ranged zips
     FZP47P002  UF A E           K DISK
      *
     D IN_SEQUENCE     S              1
      *
     D COUNTER         S                   LIKE(XS19)
      *
     D STARTRANGE      S                   LIKE(XN14)
     D ENDRANGE        S                   LIKE(XP16)
      *
     D SV_CITY         S                   LIKE(XCITY)
     D SV_STATE        S                   LIKE(XSTATE)
     D SV_SZIP         S                   LIKE(XN14)
     D SV_SVCCTR       S                   LIKE(XSVCCTR)
     D SV_DIRECTION    S                   LIKE(XDIRECTION)
     D SV_ADDSVC       S                   LIKE(XADDSVCDAY)
      *
      * ---------------------
      * Start Main Processing
      * ---------------------
     C                   EXSR      MAINPRCS
      *
      * -------------------
      * End Main Processing
      * -------------------
     C                   EVAL      *INLR = *ON
     C                   RETURN
      *
      **********************************************************************
      * Main Processing Subroutine
      **********************************************************************
     C     MAINPRCS      BEGSR
      *
      * Reset Record Counter
     C                   EVAL      COUNTER = *ZEROS
      *
      * ----------------------------------------
      * DO Loop to Read all Records in ZP47P001:
      * ----------------------------------------
     C                   DOU       %EOF(ZP47P001)
     C                   READ      ZP47P001
      *
      * End of File(EOF):
      *     Leave this routine
     C                   IF        %EOF(ZP47P001)
     C                   LEAVE
     C                   ENDIF
      *
      * Another Record Found:
      *         Increase Record Counter
     C                   EVAL      COUNTER = COUNTER + 1
      *
      * (IF) routine Only processes the first record in the file
     C                   IF        COUNTER  = 1
     C                   EVAL      SV_CITY      = XCITY
     C                   EVAL      SV_STATE     = XSTATE
     C                   EVAL      SV_SZIP      = XN14
     C                   EVAL      STARTRANGE   = XN14
     C                   EVAL      SV_SVCCTR    = XSVCCTR
     C                   EVAL      SV_DIRECTION = XDIRECTION
     C                   EVAL      SV_ADDSVC    = XADDSVCDAY
     C                   ITER
     C                   ENDIF
      *
      * Check Sequence of Zip Codes
     C                   EXSR      CHECK_SEQ
      *
      * Zip Codes are In-Sequence:
      *     Set End Range
      *     Get Next Record
     C                   IF        IN_SEQUENCE = 'Y'
     C                   EVAL      ENDRANGE = XN14
     C                   EXSR      SAVE_PREVIOUS
     C                   ITER
     C                   ENDIF
      *
      * Zip Codes are NOT In Sequence:
      *     Write current range
      *     Save Incoming Zip Code Information
      *     Get Next Record
     C                   IF        IN_SEQUENCE = 'N'
     C                   EXSR      WRITE_RECORD
     C                   EXSR      SAVE_NEWINFO
     C                   ITER
     C                   ENDIF
      *
     C                   ENDDO
      * DOU %EOF(ZP47P001)
      *
     C                   ENDSR
      *
      **********************************************************************
      * WRITE_RECORD - S/R to Fill File Fields and Zip Code Range Record
      **********************************************************************
     C     WRITE_RECORD  BEGSR
      *
     C                   EVAL      N14       = STARTRANGE
     C                   EVAL      P16       = ENDRANGE
     C                   EVAL      CITY      = SV_CITY
     C                   EVAL      STATE     = SV_STATE
     C                   EVAL      SVCCTR    = SV_SVCCTR
     C                   EVAL      DIRECTION = SV_DIRECTION
     C                   EVAL      ADDSVCDAY = SV_ADDSVC
     C                   WRITE     ZP47REC2
     C                   CLEAR                   ENDRANGE
      *
     C                   ENDSR
      *
      **********************************************************************
      * SAVE_NEWINFO - S/R to Save New Record Information
      **********************************************************************
     C     SAVE_NEWINFO  BEGSR
      *
     C                   EVAL      SV_CITY      = XCITY
     C                   EVAL      SV_STATE     = XSTATE
     C                   EVAL      SV_SZIP      = XN14
     C                   EVAL      STARTRANGE   = XN14
     C                   EVAL      SV_SVCCTR    = XSVCCTR
     C                   EVAL      SV_DIRECTION = XDIRECTION
     C                   EVAL      SV_ADDSVC    = XADDSVCDAY
      *
     C                   ENDSR
      *
      **********************************************************************
      * SAVE_PREVIOUS - S/R to Save Previously Read Record Information
      **********************************************************************
     C     SAVE_PREVIOUS BEGSR
      *
     C                   EVAL      SV_CITY      = XCITY
     C                   EVAL      SV_STATE     = XSTATE
     C                   EVAL      SV_SZIP      = XN14
     C                   EVAL      SV_SVCCTR    = XSVCCTR
     C                   EVAL      SV_DIRECTION = XDIRECTION
     C                   EVAL      SV_ADDSVC    = XADDSVCDAY
      *
     C                   ENDSR
      *
      **********************************************************************
      * CHECK_SEQ - S/R to Check Sequence of Incoming Zip to Previous
      *             Zip
      **********************************************************************
     C     CHECK_SEQ     BEGSR
      *
      * Set In Sequence Flag
     C                   EVAL      IN_SEQUENCE = 'N'
      *
      * Position Canadian Zip Code File to Incoming Zip Code Record:
      *          Read Previous Record in Canadian Zip Code File
     C     XN14          SETLL     CANADAZIP1
     C                   READP     CANADAZIP1
      *
      * Previous Record is Equal to Saved Zip Code
     C                   IF        CZIP = SV_SZIP
     C                   EVAL      IN_SEQUENCE = 'Y'
     C                   ENDIF
      *
     C                   ENDSR

Input File:
T0B0Z0
T0A0A0
T0A0C0
T0L0X0
T0J0A0
T0J0A0
T0E2N0
T0M0A0
T0H1R0
T0K0A0
T0K1Y0
T0J2N0
T0G1E0
T4A1A1
T4A1A2
T4A1A3
T4A1A4
T4A1A5
T4A1A6
T4A1A7
T4A1A8
T4A1A9
T4A1B0
T4A1B1
T4A1B2
T4A1B3
T4A1B4
T4A1B5
T4A1B6
T4A1B7
T4A1B8
T4A1B9
T4A1C0
T4A1C1
T4A1C2
T4A1C3
T4A1C4
T4A1C5
T4A1C6
T4A1C7
T4A1C8
T4A1C9
T4A1E0
T4A1E1
T4A1E2

Output File:(ignore middle column)
T0B0Z0           0000000
T0A0A0           0000000
T0A0C0           0000000
T0L0X0           0000000
T0J0A0           0000000
T0J0A0           0000000
T0E2N0           0000000
T0M0A0           0000000
T0H1R0           0000000
T0K0A0           0000000
T0K1Y0           0000000
T0J2N0           0000000
T0G1E0           0000000
T0B0Z0           0000000
T0A0A0           0000000
T0A0C0           0000000
T0L0X0           0000000
T0J0A0           0000000
T0J0A0           0000000
T0E2N0           0000000
T0M0A0           0000000
T0H1R0           0000000
T0K0A0           0000000
T0K1Y0           0000000
T0J2N0           0000000
T0G1E0           0000000
T4A1A1           0000000          T4A1C9
T4A1E0           0000000          T4A1E9
T4A1G0           0000000          T4A1H9
T4A1J0           0000000          T4A1N9
T4A1P0           0000000          T4A1P9
T4A1R0           0000000          T4A1T9
T4A1V0           0000000          T4A2C9
T4A2E0           0000000          T4A2E9
T4A2G0           0000000          T4A2H9
T4A2J0           0000000          T4A2N9
T4A2P0           0000000          T4A2P9
T4A2R0           0000000          T4A2T9
T4A2V0           0000000          T4A3C9
T4A3E0           0000000          T4A3E9
T4A3G0           0000000          T4A3H9
T4A3J0           0000000          T4A3N9
T4A3P0           0000000          T4A3P9
T4A3R0           0000000          T4A3T9
T4A3V0           0000000          T4A4C9



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.