home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / databas.com / DATABASE.DOC < prev   
Encoding:
Text File  |  1989-05-21  |  8.4 KB  |  150 lines

  1.  
  2.  
  3.  
  4.  
  5.       
  6.       
  7.                                  DATABASE.BAS
  8.                             MicroComputer Services
  9.                                   Jose Garcia
  10.                            PO Box 580  Dauphin, PA  17018
  11.                                  (717)921-8764
  12.                            CIS user number 71211,124
  13.       
  14.       
  15.       DATABASE.BAS is a simple name/address database program to demonstrate
  16.       the text entry, record selection (by means of a bounce bar) and index
  17.       routines that I have written.  It was written with version 4.5 but will 
  18.       run in version 4.0 as well.  QuickBASIC MUST BE STARTED WITH THE /AH
  19.       PARAMETER - in other words for this program to work properly you MUST
  20.       start QuickBASIC by typing QB /AH (more on this later).  Any of the code
  21.       can be used by other programmers but I ask that the comments be left
  22.       intact.  The program creates a database record file, names.dat and an
  23.       index file, names.ndx in the default directory.  If you have questions,
  24.       comments or improvements concerning the code please drop me a line -
  25.       either U.S. mail or CIS.  I will reply as soon as my schedule permits.
  26.       
  27.       I originally wrote DATABASE.BAS to demonstrate the txt.edit routine that
  28.       I had written.  As I started DATABASE.BAS I realized that I needed a
  29.       program that would emulate some common dBASE procedures.  Thus,
  30.       DATABASE.BAS grew to it's present size.  It is not perfect and I hope that
  31.       programmers who download this file will improve the coding and let me
  32.       know the improvements made to the routines contained in DATABASE.BAS.
  33.       
  34.       
  35.       The comments in the coding should help to explain what is happening and
  36.       I will add to that now.  To begin with, the TXT.EDIT routine is completely
  37.       generic and can be used in other programs or compiled and used from
  38.       within a QB library.  All that needs to be done is to dimension a
  39.       temporary array to hold the fields declared in the TYPE statement, make
  40.       each element in the array represent one of those fields.  Then call
  41.       TXT.EDIT (arrayname), (starting screen row), (starting screen column),
  42.       (flag, -  0 or 1, where 0 is overtype mode and 1 is insert mode).  The
  43.       routine will continue until all array elements (fields) have entries or
  44.       <CR>'s.  Then the array elements are switched back to the TYPE variables
  45.       to be used by the rest of the program.
  46.       
  47.       The GETNAME routine can be used in other programs if the screen locations
  48.       (LOCATE) are changed to accommodate your program and the TYPE variables
  49.       are changed to your names.  BORDER, HIGHLIGHT, LOWLIGHT, PAUSE and
  50.       BOX routines will have to be included.  It allows the user to choose a
  51.       record entry easily by using the arrow keys, highlighting the record
  52.       desired and pressing <RETURN>.  It eliminates the errors caused by users
  53.       having to type in the names of record entries and making typographical
  54.       errors.
  55.       
  56.       
  57.       
  58.       
  59.       The DB.INDEX routine called in the ON ERROR routine is used if the
  60.       database file contains records but the index file is missing.  It can be
  61.       used to restore a corrupted index file or to build an new index file using
  62.       the records contained in the data base.  Note: it only works with database
  63.       files created by QuickBASIC programs, it will not work with Ashton-Tate's
  64.       dBASE version database files (.DBF).  Your code will have to be changed
  65.       to use your TYPE'd variable names, database record filename and your
  66.       index filename in the DB.INDEX, OPENINDEX, REINDEX and UPDATENDX
  67.       routines.  The index file is read and entered into a dynamic array at the
  68.       start of the program.  All updates to the index are made to the memory
  69.       array and are not written to file until the program exits normally (by
  70.       using 5 at the main menu or arrowing down to QUIT and pressing <ENTER>.
  71.       NOTE:If records are added to the database record file while running in the
  72.       QuickBASIC environment and you "BREAK" <CTL><BRK> out of the program
  73.       instead of QUITing with choice 5 on the menu, the index file will not be
  74.       updated and you will get an error the next time you run the program. 
  75.       Always QUIT the program through the menu.  Else DEL NAMES.NDX to fix.
  76.       The new index is then written to disk and will be ready for the next
  77.       session.  The index array is stored dynamically in the far heap and
  78.       outside of the 64K BASIC boundary for variables (DGROUP) so that arrays
  79.       larger than 64K can be used (this would happen in large commercial
  80.       applications).  To ensure correct operation of the DB.INDEX, OPENINDEX,
  81.       REINDEX and UPDATENDX routines, QB MUST be started with QB /AH. 
  82.       Also, use the /AH switch when compling from the command line with BC.
  83.       
  84.       The menu routine is "borrowed" from Frank Neal, it is a popular menu
  85.       bounce-bar routine.  For it to work, the variables choice% and np% MUST
  86.       be dimensioned as shared with a   DIM SHARED choice%, np%   statement. 
  87.       Where choice% is the variable that returns the users menu choice and np%
  88.       is the variable that contains the number of menu choices, also the number
  89.       of elements in the array m$ should be dimensioned, but is not necessary.
  90.       
  91.       The DELETE routine is of interest because of the method used in deleting
  92.       records.  When a record is deleted, the DELETE routine simply adds an
  93.       ASCII 20 (the paragraph symbol) as the first character in the field being
  94.       indexed.  When records are displayed, any record beginning with an ASCII
  95.       20 is simply skipped.  When new records are added, the DATAENTRY routine 
  96.       after getting a new entry but before it is added to the database record 
  97.       file looks in the index to see if there is an entry that starts with
  98.       an ASCII 20.  If there is such an entry, the new record is saved with the
  99.       record number of the record containing the ASCII 20, thus overwriting it
  100.       and finally physically deleting it from the database file and index. 
  101.       
  102.       The REINDEX, SEARCH%, NOSPACE$ and SORT routines were implemented
  103.       from routines contained in the book Microsoft QuickBASIC Second Edition
  104.       by Douglas Hergert.  The SORT routine is a shell sort. The SEARCH%
  105.       function is a binary search.  The NOSPACE$ function removes any spaces
  106.       in the index record of the fields names.first and names.last.  The REINDEX
  107.       routine simply adds a new entry to the index array in memory.
  108.       
  109.       I would appreciate any comments or improvements concerning this code. 
  110.       It did take me some time and effort to get the routines "up and running"
  111.       so please take the time to contact me.
  112.       
  113.       Enjoy,
  114.       Jose Garcia
  115.  
  116.          ----------------end-of-author's-documentation---------------
  117.  
  118.                         Software Library Information:
  119.  
  120.                    This disk copy provided as a service of
  121.  
  122.                         The Public (Software) Library
  123.  
  124.          We are not the authors of this program, nor are we associated
  125.          with the author in any way other than as a distributor of the
  126.          program in accordance with the author's terms of distribution.
  127.  
  128.          Please direct shareware payments and specific questions about
  129.          this program to the author of the program, whose name appears
  130.          elsewhere in  this documentation. If you have trouble getting
  131.          in touch with the author,  we will do whatever we can to help
  132.          you with your questions. All programs have been tested and do
  133.          run.  To report problems,  please use the form that is in the
  134.          file PROBLEM.DOC on many of our disks or in other written for-
  135.          mat with screen printouts, if possible.  The P(s)L cannot de-
  136.          bug programs over the telephone.
  137.  
  138.          Disks in the P(s)L are updated monthly, so if you did not get
  139.          this disk  directly from the P(s)L,  you should be aware that
  140.          the files in this set may no  longer be the current versions.
  141.  
  142.          For a copy of the latest monthly software library newsletter
  143.          and a list of the 1,800+ disks in the library, call or write
  144.  
  145.                         The Public (Software) Library
  146.                               P.O.Box 35705 - F
  147.                            Houston, TX 77235-5705
  148.                                (713) 665-7017
  149.  
  150.