home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / xbase / library / clipper / oop / oopexm / oformxyz.prg < prev    next >
Encoding:
Text File  |  1992-01-27  |  2.8 KB  |  98 lines

  1. **
  2. **  PROGRAM TITLE  : FORMXYZ
  3. **
  4. **   WRITTEN BY    :  Paul Long
  5. **
  6. **   WRITTEN FOR   :  Copyright (C) 1992 All rights reserved. XL Systems, Inc.
  7. **
  8. **   PROGRAM INTENT:  Converts XYZ company's DSHS forms data
  9. **                    to GHOST data and adds it to the SERVICE.DBF file.
  10. **                    Name of forms input file is expected on command line.
  11. **
  12. #include "oclip.ch"
  13.  
  14. // Name of DBF that receives converted form data
  15. #define OUTDBFNAME   "service"
  16.  
  17.                                                                         
  18. local oForm                               // Will become an XYZ-form object
  19.  
  20. parameter cInputFile                      // Name of input file to convert
  21.  
  22. if (oForm := XYZForm():New(cInputFile)) != nil
  23.  
  24.    // Convert and add service entries to DBF
  25.    oForm:Add2DBF(OUTDBFNAME)
  26.  
  27.    ?? ltrim(str(oForm:Entries())) + ;
  28.          " entries were added to " + OUTDBFNAME + ".dbf"
  29.  
  30.    oForm:Destruct()
  31.  
  32. endif
  33.  
  34.  
  35. // Class that inherits from the Form abstract superclass
  36. CLASS XYZForm FROM Form
  37.   METHOD Read = XYZRead
  38.   METHOD Skip = XYZSkip
  39. ENDCLASS
  40.  
  41.  
  42. *******************************************************
  43. *
  44. *                             XYZSkip
  45. *
  46. *******************************************************
  47. * Skip to next form.
  48. *
  49. METHOD FUNCTION XYZSkip
  50.  
  51. // Each form has "DSHS-OFFICE" at the top
  52. if ::Found(::oFile:Locate("DSHS-OFFICE"):Found())
  53.    ::Read()
  54. endif
  55.  
  56. return Self
  57.  
  58.  
  59. *******************************************************
  60. *
  61. *                             XYZRead
  62. *
  63. *******************************************************
  64. * Read the next form from the input file, saving pertinent data for latter
  65. * output by Write().
  66. *
  67. METHOD FUNCTION XYZRead
  68.  
  69. local n
  70.  
  71. ::oFile:Skip(9)                           // Skip down to name line
  72. ::cLastName := ::oFile:Field(4, 15)
  73. ::cFirstName := ::oFile:Field(19, 13)
  74. ::cMiddleInitial := ::oFile:Field(32, 1)
  75. ::dDOB := ctod(::oFile:Field(43, 8))
  76.  
  77. ::oFile:Skip(3)                           // Skip down to PIC line
  78. ::cPIC := ::oFile:Field(56, 14)
  79.  
  80. ::oFile:Skip(31)                          // Skip down to first service line
  81. ::adDOS := {}                             // Clear array from previous form
  82. for n = 1 to 6                            // Maximum of 6 services per form
  83.    if empty(::oFile:Field(3, 6))          // If no more service, exit loop
  84.       exit
  85.    endif
  86.    // Reformat and convert date of service, then add to date-of-service array
  87.    aadd(::adDOS, ctod(::oFile:Field(3, 2) + "/" + ;
  88.          ::oFile:Field(5, 2) + "/" + ::oFile:Field(7, 2)))
  89.    ::oFile:Skip(2)                        // (Double spaced)
  90. next     
  91.  
  92. // Skip down to account-number line
  93. ::oFile:Skip(20 - (2 * n))
  94. // (We can only hold the last 9 of the 10 account-number characters)
  95. ::cAcctNo := ::oFile:Field(5, 9)
  96.  
  97. return Self
  98.