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

  1. **
  2. **  PROGRAM TITLE  : HFORM
  3. **
  4. **   WRITTEN BY    :  Paul Long
  5. **
  6. **   WRITTEN FOR   :  Copyright (C) 1992 All rights reserved. XL Systems, Inc.
  7. **
  8. **   PROGRAM INTENT:  Functions for converting forms data to GHOST data
  9. **                    and adds it to a DBF.
  10. **
  11. **   NOTE:            This file uses a hybrid approach  It uses "traditional,"
  12. **                    non-OOP programming, but organizing the code along OOP
  13. **                    lines, e.g., one source file per "class."
  14. **
  15. #include "inkey.ch"
  16.  
  17. memvar cLastName, cFirstName, cMiddleInitial, cAcctNo, cExamNo, cPIC, cSSN, ;
  18.       dDOB, adDOS
  19.  
  20. static nFormEntries, lFormFound
  21.  
  22.  
  23. *******************************************************
  24. *
  25. *                             FormNew
  26. *
  27. *******************************************************
  28. * Construct Form object mainly by constructing DOSFile object.
  29. *
  30. function FormNew(cFileName)
  31.  
  32. // Initialize variables to a known state
  33. public cLastName := "", cFirstName := "", cMiddleInitial := "", ;
  34.       cAcctNo := "", cExamNo := "", cPIC := "", cSSN := "", ;
  35.       dDOB := ctod("  /  /  "), adDOS := {}
  36. nFormEntries := 0
  37. FormFound(.t.)
  38.  
  39. return DOSFileNew(cFileName)
  40.  
  41.  
  42. *******************************************************
  43. *
  44. *                             FormDestruct
  45. *
  46. *******************************************************
  47. * Destruct form object by destructing input file
  48. *
  49. function FormDestruct(nHandle)
  50.  
  51. DOSFileDestruct(nHandle)
  52.  
  53. return nil
  54.  
  55.  
  56. *******************************************************
  57. *
  58. *                             FormAdd2DBF
  59. *
  60. *******************************************************
  61. * Convert forms data to GHOST data and add to DBF
  62. *
  63. function FormAdd2DBF(nHandle, cDBF)
  64.  
  65. if file(cDBF + ".dbf")                 // Make sure output .DBF exists
  66.    use (cDBF) exclusive new
  67.    if neterr()
  68.       ?? "*** ERROR *** " + cDBF + ".dbf cannot be opened"
  69.    else
  70.       do while FormSkip(nHandle)       // Read each form
  71.          // Write data for this form
  72.          FormWrite(cDBF)
  73.          ?? ++nFormEntries, cLastName, chr(K_RETURN)  // Tell user progess
  74.       enddo
  75.       (cDBF)->(dbclosearea())
  76.    endif
  77. else
  78.    ?? "*** ERROR *** " + cDBF + ".dbf file is missing"
  79. endif
  80.  
  81. return nil
  82.  
  83.  
  84. *******************************************************
  85. *
  86. *                             FormEntries
  87. *
  88. *******************************************************
  89. * Return number of entries in last-converted form
  90. *
  91. function FormEntries
  92.  
  93. return nFormEntries
  94.  
  95.  
  96. *******************************************************
  97. *
  98. *                             FormWrite
  99. *
  100. *******************************************************
  101. * Write service information from the current form.
  102. *
  103. function FormWrite(cDBF)
  104.  
  105. // Add n records to DBF
  106. aeval(adDOS, { | dDOS | ;
  107.       (cDBF)->(dbappend()), ;
  108.       (cDBF)->acctno := cAcctNo, ;
  109.       (cDBF)->examno := cExamNo, ;
  110.       (cDBF)->svcdate := dDOS, ;
  111.       (cDBF)->ssn := cSSN, ;
  112.       (cDBF)->pic := cPIC, ;
  113.       (cDBF)->firstname := cFirstName, ;
  114.       (cDBF)->midinitial := cMiddleInitial, ;
  115.       (cDBF)->lastname := cLastName, ;
  116.       (cDBF)->birthdate := dDOB ;
  117.                })
  118.  
  119. return nil
  120.  
  121.  
  122. *******************************************************
  123. *
  124. *                             FormFound
  125. *
  126. *******************************************************
  127. * Return whether last search succeeded.
  128. *
  129. function FormFound(lWhetherFound)
  130.  
  131. if lWhetherFound != nil
  132.    lFormFound := lWhetherFound
  133. endif
  134.  
  135. return lFormFound
  136.