home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a013 / 1.ddi / SOURCE.EXE / F_MVARS.PRG < prev    next >
Encoding:
Text File  |  1991-01-25  |  3.0 KB  |  123 lines

  1. ** FILE F_MVARS.PRG
  2. ** Contains: CLRVARS, EQUVARS, FREEVARS, INITVARS, REPLVARS
  3.  
  4. *****************************************************************
  5. FUNCTION CLRVARS
  6. *****************************************************************
  7.  
  8. * Clears field variables created by INITVARS
  9.  
  10. * Copyright(c) 1991 -- James Occhiogrosso
  11.  
  12. LOCAL counter := 0, field_cnt := FCOUNT(), old_record := RECNO()
  13. PRIVATE field_name
  14.  
  15. * Move file pointer to end of file (dummy) record
  16. GO BOTTOM
  17. SKIP
  18.  
  19. * Equate fields to memory variables. Since this is the
  20. * end of file record, all fields are blank.
  21.  
  22. FOR counter = 1 TO field_cnt
  23.     field_name = LOWER(FIELD(counter))
  24.     m&field_name = &field_name
  25. NEXT
  26.  
  27. * Restore record pointer and return
  28. GO old_record
  29.  
  30. RETURN NIL
  31.  
  32.  
  33. *****************************************************************
  34. FUNCTION EQUVARS
  35. *****************************************************************
  36.  
  37. * Load memory variables created by INITVARS from database fields
  38.  
  39. * Copyright(c) 1991 -- James Occhiogrosso
  40.  
  41. LOCAL field_cnt := FCOUNT(), counter := 0
  42. PRIVATE field_name
  43.  
  44. * Load each viriable from corresponding field
  45. FOR counter = 1 TO field_cnt
  46.     field_name = LOWER(FIELD(counter))
  47.     m&field_name = &field_name
  48. NEXT
  49.  
  50. RETURN NIL
  51.  
  52.  
  53. *****************************************************************
  54. FUNCTION FREEVARS         
  55. *****************************************************************
  56.  
  57. * Release variables created by INITVARS
  58.  
  59. * Copyright(c) 1991 -- James Occhiogrosso
  60.  
  61. LOCAL counter := 0, field_cnt := FCOUNT()
  62. PRIVATE field_name
  63.  
  64. * Release each field variable
  65. FOR counter = 1 TO field_cnt
  66.     field_name = LOWER(FIELD(counter))
  67.     RELEASE m&field_name
  68. NEXT
  69.  
  70. RETURN NIL
  71.  
  72.  
  73. *****************************************************************
  74. FUNCTION INITVARS    
  75. *****************************************************************
  76.  
  77. * Create memory variables for each fields in active database
  78.  
  79. * Copyright(c) 1991 -- James Occhiogrosso
  80.  
  81. * Caution: This procedure declares a PUBLIC memory variable for
  82. * each field in the selected database. Release the variables by
  83. * by calling FREEVARS when you no longer need them.
  84.  
  85. LOCAL field_cnt := FCOUNT(), counter := 0
  86. PRIVATE field_name
  87.  
  88. * Get the number of fields
  89. field_cnt = FCOUNT()
  90.  
  91. * Declare a public variable for each field
  92. FOR counter = 1 TO field_cnt
  93.     field_name = LOWER(FIELD(counter))
  94.     PUBLIC m&field_name
  95. NEXT
  96.  
  97. RETURN NIL
  98.  
  99.  
  100. *****************************************************************
  101. FUNCTION REPLVARS 
  102. *****************************************************************
  103.  
  104. * Replace record with values of memory variables
  105.  
  106. * Copyright(c) 1991 -- James Occhiogrosso
  107.  
  108. LOCAL field_cnt := FCOUNT(), counter := 0
  109. PRIVATE field_name
  110.  
  111. * Get the number of fields
  112. field_cnt = FCOUNT()
  113.  
  114. * Replace each field from its associated variable
  115. FOR counter = 1 TO field_cnt
  116.     field_name = LOWER(FIELD(counter))
  117.     REPLACE &field_name WITH m&field_name
  118. NEXT
  119.  
  120. RETURN NIL
  121.  
  122.  
  123.