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

  1. **
  2. **  PROGRAM TITLE  : HFORMXYZ
  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. **   NOTE:            This file uses a hybrid approach  It uses "traditional,"
  13. **                    non-OOP programming, but organizing the code along OOP
  14. **                    lines, e.g., one source file per "class."
  15. **
  16. #include "fileio.ch"
  17.  
  18. // Name of DBF that receives converted form data
  19. #define OUTDBFNAME   "service"
  20.  
  21.  
  22. local nHandle
  23.  
  24. parameter cInputFile                      // Name of input file to convert
  25.  
  26. if (nHandle := FormNew(cInputFile)) != F_ERROR
  27.  
  28.    // Convert and add service entries to DBF
  29.    FormAdd2DBF(nHandle, OUTDBFNAME)
  30.  
  31.    ?? ltrim(str(FormEntries())) + ;
  32.             " entries were added to " + OUTDBFNAME + ".dbf"
  33.  
  34.    FormDestruct(nHandle)
  35.  
  36. endif
  37.  
  38.  
  39. *******************************************************
  40. *
  41. *                             FormSkip
  42. *
  43. *******************************************************
  44. * Skip to next form.
  45. *
  46. function FormSkip(nHandle)
  47.  
  48. // Each form has "DSHS-OFFICE" at the top
  49. DOSFileLocate(nHandle, "DSHS-OFFICE")
  50. if FormFound(DOSFileFound())
  51.    FormRead(nHandle)
  52. endif
  53.  
  54. return FormFound()
  55.  
  56.  
  57. *******************************************************
  58. *
  59. *                             FormRead
  60. *
  61. *******************************************************
  62. * Read the next form from the input file, saving pertinent data for latter
  63. * output by Write().
  64. *
  65. function FormRead(nHandle)
  66.  
  67. memvar cLastName, cFirstName, cMiddleInitial, cAcctNo, cExamNo, cPIC, cSSN, ;
  68.       dDOB, adDOS
  69.  
  70. local n, cRecord
  71.  
  72. cRecord := DOSFileSkip(nHandle, 9)        // Skip down to name line
  73. cLastName := substr(cRecord, 4, 15)
  74. cFirstName := substr(cRecord, 19, 13)
  75. cMiddleInitial := substr(cRecord, 32, 1)
  76. dDOB := ctod(substr(cRecord, 43, 8))
  77.  
  78. cRecord := DOSFileSkip(nHandle, 3)        // Skip down to PIC line
  79. cPIC := substr(cRecord, 56, 14)
  80.  
  81. cRecord := DOSFileSkip(nHandle, 31)       // Skip down to first service line
  82. adDOS := {}                               // Clear array from previous form
  83. for n = 1 to 6                            // Maximum of 6 services per form
  84.    if empty(substr(cRecord, 3, 6))        // If no more service, exit loop
  85.       exit
  86.    endif
  87.    // Reformat and convert date of service, then add to date-of-service array
  88.    aadd(adDOS, ctod(substr(cRecord, 3, 2) + "/" + ;
  89.          substr(cRecord, 5, 2) + "/" + substr(cRecord, 7, 2)))
  90.    cRecord := DOSFileSkip(nHandle, 2)     // (Double spaced)
  91. next     
  92.  
  93. // Skip down to account-number line
  94. cRecord := DOSFileSkip(nHandle, 20 - (2 * n))
  95. // (We can only hold the last 9 of the 10 account-number characters)
  96. cAcctNo := substr(cRecord, 5, 9)
  97.  
  98. return nil
  99.