home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / dgenius.zip / DGENI002.PRG < prev    next >
Text File  |  1987-01-31  |  7KB  |  337 lines

  1. * System....: dGENIUS
  2. * Program...: dGENI002.prg
  3. * Purpose...: Database File Appender
  4. * Requires..: INSTALDG.prg,STRUX.dbf,SKELETON.dbf
  5. * Author....: Brian Corll
  6. * Dates.....: 01/22/87
  7. * Notice....: copyright 1987 the Author
  8. * Version...: 1.0 (x3)
  9.  
  10. Procedure Appender
  11.  
  12. set esca off
  13.  
  14.  
  15. clear
  16. set defa to a
  17. set path to
  18. mdrive=space(1)
  19. set colo to gr+/n,w/b+
  20. @ 1,0 say "Place the diskette containing your database in drive A."
  21. wait "Press the Enter key when you are ready."
  22.  
  23.  
  24. ap=.t.
  25. do while ap
  26.  
  27. clear
  28. @ 1,0 say "The following files are available on drive A:"
  29. dir A:
  30. dbfname=space(8)
  31. @ 23,0 say "Which database do you want to append?" get dbfname picture "!!!!!!!!"
  32. @ 24,0 say "Enter RETURN if no database files are shown."
  33. read
  34.  
  35. if upper(dbfname)="RETURN"
  36. @ 23,0 clea to 24,79
  37. @ 23,0 say "Put the correct diskette in the same drive!"
  38. wait
  39. loop
  40. else
  41. endif
  42.  
  43. if .not. file('&dbfname..dbf')
  44. do while .not. file('&dbfname..dbf')
  45. ? chr(7),chr(7),chr(7)
  46. set colo to r+/n
  47. dbfname=space(8)
  48. @ 24,0 clear
  49. @ 24,0 say "Incorrect file name. Try again:" get dbfname picture "!!!!!!!!"
  50. read
  51. if file('&dbfname..dbf')
  52. exit
  53. else
  54. endif
  55. enddo
  56. else
  57. endif
  58.  
  59. set colo to gr+/n,w/b+
  60. use &dbfname
  61. bc=.t.
  62. do while bc
  63. clear
  64. am=space(1)
  65. @ 1,0 say "Enter A to add,M to return to the menu:" get am picture "!"
  66. @ 2,0 say "Press the Ctrl and End keys when you are finished adding or editing records."
  67. read
  68. if am="A"
  69. appe blank
  70. brow
  71. endif
  72. if am="M"
  73. clear
  74. ok=space(1)
  75. set colo to bg+/n
  76. @ 1,0 say "Do you want to make a backup copy of your database? (Y or N)" get ok picture "!"
  77. read
  78. if ok="Y"
  79. set colo to rb+/n
  80. @ 3,0 say "Place the backup diskette in drive B."
  81. wait "Press the Enter key when you are ready."
  82. copyname=trim(dbfname)
  83. run copy a:\©name..dbf b:/v
  84. clear
  85. set colo to g+/n
  86. @ 1,0 say "Backup copy complete and verified."
  87. wait "Press the Enter key to return to the menu."
  88. set defa to c
  89. set path to c:\dbase
  90. bc=.f.
  91. exit
  92. endif
  93. if ok="N"
  94. set defa to c
  95. set path to c:\dbase
  96. bc=.f.
  97. exit
  98. endif
  99. endif
  100. enddo
  101. return
  102.  
  103.  
  104.  
  105. Procedure Finder
  106. clear
  107. set colo to gr+/n,n/bg+
  108. set defa to a
  109. set path to
  110. set scor on
  111. @ 1,0 say "Place the diskette containing your database file in ;
  112. drive A."
  113. wait "Press the Enter key when you're ready."
  114. dbfname=space(8)
  115. clear
  116. @ 1,0 say "The following database files are available on drive A:"
  117. dir a:
  118. @ 24,0 say "Which database file do you want to use?" get dbfname ;
  119. picture "!!!!!!!!"
  120. read
  121.  
  122. if .not. file('&dbfname..dbf')
  123.     do while .not. file('&dbfname..dbf')
  124.     ? chr(7)
  125.     @ 24,0 clear
  126.     @ 24,0 say "Incorrect file name. Enter again:" get dbfname ;
  127. picture "!!!!!!!!"
  128.     read
  129.     if file('&dbfname..dbf')
  130.     exit
  131.     else
  132.     loop
  133.     endif
  134.     enddo
  135. endif
  136.  
  137. clear
  138. copyname=trim(dbfname)
  139. @ 1,0 say "Copying the "+upper(copyname)+" database file......"
  140. run copy a:\©name..dbf c:\dbase/v
  141. set defa to c
  142. set path to c:\dbase
  143. use ©name
  144. copy stru exte to skeleton
  145. use skeleton
  146. store reccount() to mem1
  147. go top
  148. x=2
  149. y=0
  150. clear
  151. @ 1,0 say "The following fields are available in the "+dbfname+" database file:"
  152.  
  153.  
  154. do while .not. eof()
  155.    @ x,y say ltrim(str(recno()))+". "+upper(field_name)
  156.    x=x+1
  157.    if x=24
  158.    x=2
  159.    y=15
  160.    endif
  161.    if x=24 .and. y=15
  162.    x=2
  163.    y=30
  164.    endif
  165.    if x=24 .and. y=30
  166.    x=2
  167.    y=45
  168.    endif
  169.    if x=24 .and. y=45
  170.    x=2
  171.    y=60
  172.    endif
  173.    skip
  174. enddo
  175. fldno=0
  176. @ 24,0 say "Enter the number of the field you want to use to find a record:" get fldno ;
  177. picture "@Z 999" range 1,mem1
  178. read
  179. go fldno
  180. mfield=field_name
  181. get_box=field_len
  182. mtype=field_type
  183. @ 24,0 clear
  184. @ 24,0 say "Creating a new index for the "+upper(copyname)+" database."
  185. use ©name
  186. set talk on
  187. index on &mfield to new
  188. set talk off
  189. bc=.t.
  190. do while bc
  191. use ©name index new
  192. clear
  193. findfld=space(get_box)
  194.  
  195. if mtype="D"
  196. oktogo=space(1)
  197. @ 1,0 say "Enter C to continue,R to return to the menu:" get oktogo pict "!"
  198. read
  199. if oktogo="R"
  200. clear
  201. @ 1,0 say "RETURNING TO MENU...."
  202. exit
  203. else
  204. endif
  205. @ 1,0 clear
  206. @ 1,0 say "Enter the "+trim(upper(mfield))+" you wish to find:" get findfld pict "@D"
  207. read
  208. @ 2,0 say "Searching database...."
  209. loca for &mfield=ctod('&findfld')
  210.      if .not. found()
  211.      @ 3,0 say "I cannot find a record for the date "+findfld+"."
  212.      gonogo=space(1)
  213.      @ 4,0 say "Do you want to try again?" get gonogo pict "!"
  214.      read
  215.          if gonogo="Y"
  216.             loop
  217.          endif
  218.          if gonogo="N"
  219.             bc=.f.
  220.             exit
  221.          endif
  222.       else
  223.       @ 3,0 say "I found the record you want."
  224.       mporvee=space(1)
  225.       @ 4,0 say "To print it, enter a P."
  226.       @ 5,0 say "To view it , enter a V."
  227.       @ 6,0 say "To change it,enter a C."
  228.       @ 7,0 say "To delete it, enter a D."
  229.       @ 8,0 say "Enter choice here:======>" get mporvee pict "!"
  230.       read
  231.       do case
  232.           case mporvee="P"
  233.           disp to prin
  234.           case mporvee="V"
  235.           clear
  236.           disp
  237.           wait
  238.           case mporvee="C"
  239.           brow
  240.           case mporvee="D"
  241.           dele
  242.           @ 24,0 say "REMOVING RECORD FROM DATABASE....."
  243.           pack
  244.       endcase
  245. endif
  246. endif
  247.  
  248. if mtype="C" .or. mtype="N"
  249. oktogo=space(1)
  250. @ 1,0 say "Enter C to continue,R to return to the menu:" get oktogo pict "!"
  251. read
  252. if oktogo="R"
  253. clear
  254. @ 1,0 say "RETURNING TO MENU...."
  255. exit
  256. else
  257. endif
  258. @ 1,0 clear
  259. @ 1,0 say "Enter the "+trim(upper(mfield))+" you want to find:" get findfld picture "@!"
  260. read
  261. endif
  262.  
  263. if mtype="L"
  264. oktogo=space(1)
  265. @ 1,0 say "Enter C to continue,R to return to the menu:" get oktogo pict "!"
  266. read
  267. if oktogo="R"
  268. clear
  269. @ 1,0 say "RETURNING TO MENU...."
  270. exit
  271. else
  272. endif
  273. @ 1,0 clear
  274. @ 1,0 say "Enter the "+trim(upper(mfield))+" you want to find:" get findfld pict "!"
  275. read
  276. endif
  277.  
  278. if mtype<>"D"
  279. find_me=trim(findfld)
  280. find &find_me
  281. endif
  282.  
  283. if .not. found()
  284.    @ 2,0 say "I cannot locate a record for "+upper(find_me)+"!"
  285.    yesno=space(1)
  286.    @ 3,0 say "Do you want to try another "+trim(upper(mfield))+"?" get yesno picture "!"
  287.    read
  288.    if yesno="Y"
  289.    loop
  290.    endif
  291.    if yesno="N"
  292.    bc=.f.
  293.    exit
  294.    endif
  295. else
  296.     @ 2,0 say "I found the record you want."
  297.     mporvee=space(1)
  298.     @ 3,0 say "If you want to print it,enter P."
  299.     @ 4,0 say "If you want to view it,enter V."
  300.     @ 5,0 say "If you want to change it, enter C."
  301.     @ 6,0 say "If you want to delete it,enter D."
  302.     @ 7,0 say "Enter choice here:=====>" get mporvee picture "!"
  303.     read
  304.  
  305.     do case
  306.        case mporvee="P"
  307.            disp to prin
  308.        case mporvee="V"
  309.            clear
  310.            disp
  311.            mqorno=space(1)
  312.            @ 24,0 say "Do you want to look for another record?" get mqorno picture "!"
  313.            read
  314.                if mqorno="Y"
  315.                    loop
  316.                 endif
  317.                if mqorno="N"
  318.                    bc=.f.
  319.                    exit
  320.                endif
  321.        case mporvee="C"
  322.             brow
  323.        case mporvee="D"
  324.             @ 24,0 say "REMOVING RECORD FROM DATABASE...."
  325.             dele
  326.             pack
  327.        endcase
  328. endif
  329. enddo
  330. clear
  331. @ 1,0 say "RETURNING TO MENU...."
  332. run copy c:\dbase\©name..dbf a:/v
  333. run del c:\dbase\©name..dbf
  334. run del c:\dbase\new.ndx
  335. return
  336.  
  337.