This program converted dates on a history file for a past Y2K project. Written for use on a Stratus computer with a VOS operating system.


   ******************************************************************
   ** Program: convhist.q                                          **
   ** Purpose: Converts history file for Y2K compliance.           **
   ** Notes..: To run this program, type "quikcode convhist.q" on  **
   **          the command line.  Compile and bind not required.   **
   ******************************************************************

    display '*****************************************************'
    display '** History file conversion - Start                 **'

    system 'delete_file  history_new.data'

  * Create history_new.data file and indexes
    system 'create_file  history_new.data -organization fixed -record_size 800'
    system 'create_index history_new.data company_symbol_date 13,2 59,7 37,4 -type embedded_key -collation ascii -order descending -duplicates -no_null_keys -automatic_update'
    system 'create_index history_new.data primary 1,6 -type embedded_key -collation ascii -order ascending -no_duplicates -null_keys -automatic_update'

    open ifa 'history.data'     binary 800  * Open old history file as input  - 800 byte records
    open ofa 'history_new.data' binary 800  * Open new history file as output - 800 byte records

100 read ifa at eof 900              * Read record, If file end - go to 900

    move ifa1-150     to ofa1-150    * Move first chunk of record to output

    if ifa151-156 is not spaces      * Cvt match date from yymmdd to ccyymmdd
      if ifa151-152 > '86'           * 86 is the pivot year
        move '19'     to ofa151-152  * Set match date century to 19 
      else
        move '20'     to ofa151-152  * Set match date century to 20 
    else
      move spaces     to ofa151-152. * Set match date century to spaces
 
    move ifa151-171   to ofa153-173  * Move next chunk of record to output
 
    if ifa172-177 is not spaces      * Cvt cxl replace date from yymmdd to ccyymmdd 
      if ifa172-173 > '86'           * 86 is the pivot year
        move '19'     to ofa174-175  * Set cxl replace date century to 19 
      else
        move '20'     to ofa174-175  * Set cxl replace date century to 20 
    else
      move spaces     to ofa174-175. * Set cxl replace date century to spaces

    move ifa172-800   to ofa176-800  * Move last chunk of record to output

    display 'match date: '       noskip
    display ifa151-156           noskip
    display '  to '              noskip
    display ofa151-158           noskip
    display '   '                noskip
    display 'cxl replace date: ' noskip
    display ifa172-177           noskip
    display '  to '              noskip
    display ofa174-181

    write ofa                        * Write converted record to new history file
    go to 100                        * Go read next record from old history file

900 close ifa                        * Close old history file
    close ofa                        * Close new history file
    display 'history.data file records read ...... = ' noskip
    display ifa-recnum
    display 'history_new.data file records written = ' noskip
    display ofa-recnum
    display '** History file conversion - End                   **'
    display '*****************************************************'
    end

Back to home Back to home