home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l391_1 / 3.ddi / BOOKGEN.BA$ / BOOKGEN.bin
Encoding:
Text File  |  1992-08-19  |  20.6 KB  |  445 lines

  1. ' ------------------------------------------------------------------------
  2. ' Visual Basic for MS-DOS BookLook ISAM Demo Program
  3. '
  4. ' BOOKGEN.BAS - General routines support module.
  5. '
  6. ' Booklook is an ISAM sample program that manages a
  7. ' database of fictitious library books (BOOKS.MDB).
  8. '
  9. ' Refer to module-level comments in BOOKLOOK.FRM
  10. ' for more information about this sample program.
  11. '
  12. ' Copyright (C) 1982-1992 Microsoft Corporation
  13. '
  14. ' You have a royalty-free right to use, modify, reproduce
  15. ' and distribute the sample applications and toolkits provided with
  16. ' Visual Basic for MS-DOS (and/or any modified version)
  17. ' in any way you find useful, provided that you agree that
  18. ' Microsoft has no warranty, obligations or liability for
  19. ' any of the sample applications or toolkits.
  20. ' ------------------------------------------------------------------------
  21.  
  22. ' Include file containing procedure declarations and variable definitions.
  23. '$INCLUDE: 'BOOKLOOK.BI'
  24.  
  25.  
  26. ' Sample library data for creating a new ISAM file.
  27. ' Format is:
  28. '   Number records in CardHolder table
  29. '   Cardholder record 1
  30. '   Cardholder record 2
  31. '      ....
  32. '   Cardholder record n
  33. '
  34. '   Number records in BookStock table
  35. '   BookStock record 1
  36. '   BookStock record 2
  37. '      ....
  38. '   BookStock record n
  39. '
  40. '   Number records in BooksOut table
  41. '   BooksOut record 1
  42. '   BooksOut record 2
  43. '      ....
  44. '   BooksOut record n
  45. '
  46. DATA 16
  47. DATA "Tomas, Richard", "213 Happy Lane", "Erehwon", "WA",  98042 ,  31277
  48. DATA "Johnson, Pamela", "61 Rendezvous Road", "Redburn", "WA",  98073 ,  17445
  49. DATA "Jones, Ted", "743 Orderly Park", "Oso", "WA",  98137 ,  16632
  50. DATA "Sands, Steve", "1234 Sequential Street", "Index", "WA",  98333 ,  22321
  51. DATA "Richards, Ellen", "1519 Whammadiddle Drive", "Sourwood Mountain", "NC",  37128 ,  10324
  52. DATA "Green, Richard", "666 Spirit Circle", "Port Townsend", "WA",  98432 ,  11121
  53. DATA "Mull, John", "23014 Somewhere Place", "Lincoln", "NY",  98021 ,  23175
  54. DATA "Barnes, Ralph", "34 Crampon Blvd", "Tucson", "AK",  97234 ,  12113
  55. DATA "Jackson, Sally", "89 Gold Camp Lane", "Barrow", "AZ",  76113 ,  39442
  56. DATA "Burke, Barbara", "4 Circle Square", "Kluter", "MN",  53396 ,  11345
  57. DATA "Stevens, Tom", "911 S. Porsche Drive", "Coupeville", "WA",  98239 ,  11443
  58. DATA "Blake, Ruth", "232 Rana Road", "Pipiens", "CA",  92021 ,  22222
  59. DATA "Adams, Mark", "6 Lighthouse Lane", "Sandville", "WA",  82345 ,  27731
  60. DATA "Press, Beth", "122 S. Amazon Road", "Volvo City", "VA",  68122 ,  21905
  61. DATA "Rollins, Nancy", "Aleph-0 Cardinal Court", "Infinity", "WA",  97191 ,  15907
  62. DATA "Carey, Evan", "1 Cartesian Street", "Cogito", "CA",  94305 ,  20202
  63. DATA  51
  64. DATA "Computer BASIC the Easy Way", "Downing, Douglas", "Barron",  9.95 ,  2 ,  81200.4253
  65. DATA "Microsoft Quick BASIC Programming for the PC", "Cornell, Gary", "Sams",  21.95 ,  1 ,  67202.2683
  66. DATA "Exploring the Geometry of Nature: Computer...", "Reitman, Edward", "TAB Bks",  24.95 ,  1 ,  83069.1375
  67. DATA "Advanced Structured Basic for the IBM PC", "Carney, Richard", "HarBraceJ",  18 ,  1 ,  15501.2347
  68. DATA "Microsoft BASIC Using a Modular Structure", "Bradley, Julia C.", "Wm C Brown",  10.95 ,  2 ,  69703.0276
  69. DATA "Introduction to Computing with BASIC", "Spencer, Donald D.", "Camelot Pub",  12.95 ,  1 ,  89218.1419
  70. DATA "Computer Mathematics with BASIC Programming", "Spencer, Donald D.", "Camelot Pub",  14.95 ,  1 ,  89218.1354
  71. DATA "Introduction to Computing Using BASIC", "Levine, Leonard", "Kendall-Hunt",  10.95 ,  1 ,  84034.6565
  72. DATA "Basic Keyboarding Applications", "LaBarre, James E., et al.", "SRA",  29.95 ,  1 ,  13351.3501
  73. DATA "BASIC: A Structured Approach, IBM Version", "IBM Technical Staff", "SW Pub",  14.95 ,  2 ,  53810.7901
  74. DATA "Handbook of Basic for the IBM PC, XT, etc.", "Schneider, David I.", "Brady Bks",  24.95 ,  3 ,  13372.5802
  75. DATA "Structured BASIC Programming", "Moriber, Harry", "Merrill",  29.95 ,  1 ,  67520.0715
  76. DATA "Advanced QuickBASIC", "Knecht, Ken", "Scott F",  21.95 ,  1 ,  67338.1501
  77. DATA "QuickBasic: Programming Techniques & Library...", "Shammas, Namir C.", "M&T Pub Inc",  19.95 ,  1 ,  15585.1004
  78. DATA "Microsoft BASIC: Programming the IBM PC", "Bent, Robert J.; Sethares, George C.", "Brooks-Cole",  24 ,  2 ,  53410.1161
  79. DATA "The BASIC Book", "Fanzone, Penny; Hankins, Tom", "Knopf",  11.95 ,  2 ,  39439.3236
  80. DATA "Computer Concepts & Applications", "O'Brien", "Irwin",  33.95 ,  3 ,  25607.0016
  81. DATA "Computers & End-User Software with BASIC", "Athey, Thomas H., et al.", "Scott F",  22.95 ,  2 ,  67338.4055
  82. DATA "Computer Information Systems with BASIC: A...", "Tom, Paul", "Scott F",  22.95 ,  1 ,  67318.7608
  83. DATA "Instructional Design for Computers: Cognitive...", "Gallini, Joan K.; Gredler, Margaret", "Scott F",  22.95 ,  1 ,  67339.8196
  84. DATA "Programming in Basic for Engineers", "Rojiani, Kamal B.", "PWS-Kent Pub",  28.5 ,  1 ,  53491.8999
  85. DATA "Advanced Structured Basic: File Processing...", "Payne, James", "PWS-Kent Pub",  24.5 ,  1 ,  53491.8722
  86. DATA "BASIC: Concepts & Structured Problem-Solving", "Boillot, Michel", "West Pub",  35.75 ,  2 ,  31465.4615
  87. DATA "Microsoft QuickBASIC: Developing Structured...", "Hergert, Douglas", "Microsoft",  19.95 ,  2 ,  15561.5125
  88. DATA "The Microsoft QuickBASIC Programmer's Toolbox", "Craig, John C.", "Microsoft",  22.95 ,  1 ,  15561.1276
  89. DATA "QuickBASIC Made Easy", "Albrecht, Bob; Wiegand, Wenden; Brow", "Osborne-McGraw",  19.95 ,  1 ,  78814.2819
  90. DATA "Advanced QuickBASIC", "Albrecht, Bob; Inman, Don; Crane, Do", "McGraw",  21.95 ,  1 ,  70081.1361
  91. DATA "Using QuickBASIC", "Inman, Don; Albrecht, Bob", "Osborne-McGraw",  19.95 ,  1 ,  70081.2747
  92. DATA "Structured BASIC Programming on IBM PCs", "Castek, John", "Wiley",  12.95 ,  1 ,  77160.4895
  93. DATA "Structured Basic Fundamentals & Style for IBM PC..", "Quansey, James S.; Maniotes, John", "Boyd & Fraser",  30 ,  1 ,  87835.2899
  94. DATA "Quick Basic 4.0 Programming for the IBM", "Townsend, Carl", "Sams",  12.95 ,  1 ,  67222.6332
  95. DATA "Handbook of Basic for the IBM PC, XT,...", "Schneider, David I.", "Brady Comp Bks",  24.95 ,  1 ,  13372.5821
  96. DATA "Structured BASIC Programming", "Moriber, Harry", "Merrill",  27.95 ,  1 ,  67520.7015
  97. DATA "Advanced BASIC Programming", "Onyett, Lloyd", "Heath",  21 ,  1 ,  66915.4415
  98. DATA "BASIC Game Plans: Computer Games & Puzzles...", "Baumann, Ruediger", "Birkhauser",  35 ,  1 ,  81763.3677
  99. DATA "Short Course in Structured BASIC Programming...", "Blissmer, Robert H.; Castek, John E.", "Wiley",  45.95 ,  1 ,  47160.1713
  100. DATA "Big Blue BASIC: Programming the IBM PC...", "Rob, Peter", "Wadsworth Pub",  19.95 ,  1 ,  53408.7056
  101. DATA "Using Microsoft Quickbasic to Write Better...", "Cooper, James", "Wiley",  35 ,  1 ,  47161.3011
  102. DATA "Programming in BASIC: A Structured Approach", "Stern, Matthew H.; Cashman, Mark", "Comp Info Sci",  27.95 ,  1 ,  93647.7032
  103. DATA "Basic for the IBM PC", "Shelly, Gary B.; Cashman, Thomas J.", "Boyd & Fraser",  30 ,  1 ,  87835.2122
  104. DATA "Structured BASIC Applied to Technology", "Adamson, Thomas A.", "Merrill",  24.95 ,  1 ,  67520.7721
  105. DATA "Structured BASIC Applied to Technology", "Adamson, Thomas A.", "Merrill",  24.95 ,  1 ,  67520.7722
  106. DATA "Structured BASIC Applied to Technology", "Adamson, Thomas A.", "Merrill",  25.95 ,  1 ,  67520.7723
  107. DATA "Structured BASIC Applied to Technology", "Adamson, Thomas A.", "Merrill",  25.95 ,  1 ,  67520.7724
  108. DATA "Structured BASIC Applied to Technology", "Adamson, Thomas A.", "Merrill",  26.5 ,  1 ,  67520.7725
  109. DATA "Problem Solving with ANSI Structured BASIC", "Yarmish, Rina; Yarmish, Joshua", "SRA",  10.95 ,  1 ,  13168.8846
  110. DATA "QuickBASIC", "Scott, Fred", "Scott F",  22.95 ,  1 ,  67338.0823
  111. DATA "Number Problem Visual Masters: With BASIC...", "Spencer, Donald D.", "Camelot Pub",  13.95 ,  1 ,  89218.1567
  112. DATA "Math Problem Visual Masters: With BASIC...", "Spencer, Donald D.", "Camelot Pub",  13.95 ,  1 ,  89218.1568
  113. DATA "IBM-PC Basic with An Introduction to...", "Serebreny, Raphael E.", "P-H",  26.67 ,  1 ,  13449.4057
  114. DATA "Introduction to Computers & Information Systems...", "Athey, Thomas H.; Zmud, Robert W.", "Scott F",  19.95 ,  1 ,  67318.9891
  115. DATA  37
  116. DATA  31277 ,  69703.0276 ,  33803
  117. DATA  23175 ,  15585.1004 ,  34200
  118. DATA  31277 ,  53491.8999 ,  33950
  119. DATA  17445 ,  67520.0715 ,  33820
  120. DATA  23175 ,  15561.5125 ,  33878
  121. DATA  17445 ,  81200.4253 ,  33836
  122. DATA  12113 ,  13449.4057 ,  33911
  123. DATA  39442 ,  67318.9891 ,  33945
  124. DATA  11345 ,  71313.5867 ,  33973
  125. DATA  27731 ,  25607.0016 ,  34041
  126. DATA  17445 ,  66915.4415 ,  34003
  127. DATA  31277 ,  70081.1361 ,  34123
  128. DATA  23175 ,  53491.8722 ,  33811
  129. DATA  17445 ,  53410.1161 ,  33945
  130. DATA  12113 ,  67520.7723 ,  33999
  131. DATA  39442 ,  47160.1713 ,  34110
  132. DATA  31277 ,  87835.2899 ,  33945
  133. DATA  23175 ,  77160.4895 ,  33879
  134. DATA  31277 ,  31465.4615 ,  33841
  135. DATA  17445 ,  93647.7032 ,  33945
  136. DATA  31277 ,  47161.3011 ,  33973
  137. DATA  23175 ,  13168.8846 ,  33841
  138. DATA  17445 ,  67318.7608 ,  34070
  139. DATA  12113 ,  13372.5802 ,  34101
  140. DATA  23175 ,  70081.2747 ,  34098
  141. DATA  17445 ,  13372.5821 ,  33822
  142. DATA  12113 ,  67222.6332 ,  33755
  143. DATA  39442 ,  89218.1354 ,  33750
  144. DATA  31277 ,  53810.7901 ,  33805
  145. DATA  23175 ,  84034.6565 ,  33945
  146. DATA  31277 ,  89218.1567 ,  34073
  147. DATA  17445 ,  78814.2819 ,  34141
  148. DATA  31277 ,  67520.7721 ,  33993
  149. DATA  10324 ,  67339.8196 ,  33900
  150. DATA  21905 ,  39439.3236 ,  33850
  151. DATA  20202 ,  15561.1276 ,  33859
  152. DATA  22222 ,  15501.2347 ,  33950
  153.  
  154. ' Record display routine.
  155. ' Displays current record from active table on the form
  156. ' corresponding to that table.
  157. '
  158. SUB DisplayRecord ()
  159.     ' Setup error handling for display errors.
  160.     ON LOCAL ERROR GOTO DisplayError
  161.     
  162.     SELECT CASE BigRec.TableNum
  163.     ' Display record from BookStock table on the BookStock form.
  164.     CASE cBookStockTableNum
  165.         ' Check if table contains records.
  166.         IF LOF(cBookStockTableNum) > 0 THEN
  167.             ' Get the current record.
  168.             RETRIEVE cBookStockTableNum, BigRec.Inventory
  169.  
  170.             ' Determine if book is checked out.
  171.             SETINDEX cBooksOutTableNum, "IDIndexBO"
  172.             SEEKEQ cBooksOutTableNum, BigRec.Inventory.IDnum
  173.  
  174.             ' If book is checked out, update status to reflect it.
  175.             IF NOT EOF(cBooksOutTableNum) THEN
  176.                 RETRIEVE cBooksOutTableNum, BigRec.OutBooks
  177.                 frmBookStock.lblStatus.Caption = "Status:   OUT"
  178.                 frmBookStock.lblDueDate.Caption = "Due Date: " + FORMAT$(BigRec.OutBooks.DueDate, "mm/dd/yy")
  179.                 frmBookStock.cmdCheck.Caption = "Check In..."
  180.             ' Book is not checked out.
  181.             ELSE
  182.                 frmBookStock.lblStatus.Caption = "Status:   IN"
  183.                 frmBookStock.lblDueDate.Caption = "Due Date:"
  184.                 frmBookStock.cmdCheck.Caption = "Check Out..."
  185.             END IF
  186.         ' Table contains no records.
  187.         ELSE
  188.             BigRec.Inventory.Title = ""
  189.             BigRec.Inventory.Author = ""
  190.             BigRec.Inventory.Publisher = ""
  191.             BigRec.Inventory.Price = -1
  192.             BigRec.Inventory.Edition = -1
  193.             BigRec.Inventory.IDnum = -1
  194.             frmBookStock.lblStatus.Caption = "Status:   "
  195.             frmBookStock.lblDueDate.Caption = "Due Date:"
  196.         END IF
  197.  
  198.         ' Display contents of BigRec.Inventory (current record) on the form.
  199.         frmBookStock.txtTitle.Text = RTRIM$(BigRec.Inventory.Title)
  200.         frmBookStock.txtAuthor.Text = RTRIM$(BigRec.Inventory.Author)
  201.         frmBookStock.txtPublisher.Text = RTRIM$(BigRec.Inventory.Publisher)
  202.         IF BigRec.Inventory.Price = -1 THEN
  203.             frmBookStock.txtPrice.Text = ""
  204.         ELSE
  205.             frmBookStock.txtPrice.Text = LTRIM$(STR$(BigRec.Inventory.Price))
  206.         END IF
  207.         IF BigRec.Inventory.Edition = -1 THEN
  208.             frmBookStock.txtEdition.Text = ""
  209.         ELSE
  210.             frmBookStock.txtEdition.Text = LTRIM$(STR$(BigRec.Inventory.Edition))
  211.         END IF
  212.         IF BigRec.Inventory.IDnum = -1 THEN
  213.             frmBookStock.txtID.Text = ""
  214.         ELSE
  215.             frmBookStock.txtID.Text = LTRIM$(STR$(BigRec.Inventory.IDnum))
  216.         END IF
  217.  
  218.         BookRecordChanged = FALSE   ' Reset record changed flag.
  219.  
  220.     ' Display record from CardHolders table on the CardHolders form.
  221.     CASE cCardHoldersTableNum
  222.         ' Check if table contains records.
  223.         IF LOF(cCardHoldersTableNum) > 0 THEN
  224.             ' Get the current record.
  225.             RETRIEVE cCardHoldersTableNum, BigRec.Lendee
  226.         ELSE
  227.             BigRec.Lendee.TheName = ""
  228.             BigRec.Lendee.Street = ""
  229.             BigRec.Lendee.City = ""
  230.             BigRec.Lendee.State = ""
  231.             BigRec.Lendee.Zip = -1
  232.             BigRec.Lendee.CardNum = -1
  233.         END IF
  234.  
  235.         ' Display contents of BigRec.Lendee (current record) on the form.
  236.         frmCardHolder.txtName.Text = RTRIM$(BigRec.Lendee.TheName)
  237.         frmCardHolder.txtStreet.Text = RTRIM$(BigRec.Lendee.Street)
  238.         frmCardHolder.txtCity.Text = RTRIM$(BigRec.Lendee.City)
  239.         frmCardHolder.txtState.Text = RTRIM$(BigRec.Lendee.State)
  240.         IF BigRec.Lendee.Zip = -1 THEN
  241.             frmCardHolder.txtZip.Text = ""
  242.         ELSE
  243.             frmCardHolder.txtZip.Text = LTRIM$(STR$(BigRec.Lendee.Zip))
  244.         END IF
  245.         IF BigRec.Lendee.CardNum = -1 THEN
  246.             frmCardHolder.txtCardNum.Text = ""
  247.         ELSE
  248.             frmCardHolder.txtCardNum.Text = LTRIM$(STR$(BigRec.Lendee.CardNum))
  249.         END IF
  250.  
  251.         CardRecordChanged = FALSE   ' Reset record changed flag.
  252.     END SELECT
  253.  
  254.     EXIT SUB
  255.  
  256. ' Display error handling routine.
  257. DisplayError:
  258.     RESUME NEXT                     ' Ignore errors and continue.
  259. END SUB
  260.  
  261. ' Common Key handling routine.
  262. ' Traps up arrow, down arrow, home, and end keys used to
  263. ' navigate active ISAM table.  Called from each
  264. ' control's individual KeyDown event procedure to
  265. ' save code duplication.
  266. '
  267. SUB KeyHandle (KeyCode AS INTEGER)
  268.     SELECT CASE KeyCode
  269.     ' Down arrow key - moves to next record in table.
  270.     CASE 40
  271.         CALL SaveRecord                 ' Save current record if changed.
  272.         MOVENEXT BigRec.TableNum
  273.         IF EOF(BigRec.TableNum) THEN MOVELAST BigRec.TableNum
  274.         CALL DisplayRecord
  275.  
  276.     ' Up arrow key - moves to previous record in table.
  277.     CASE 38
  278.         CALL SaveRecord                 ' Save current record if changed.
  279.         MOVEPREVIOUS BigRec.TableNum
  280.         IF BOF(BigRec.TableNum) THEN MOVEFIRST BigRec.TableNum
  281.         CALL DisplayRecord
  282.  
  283.     ' End key - moves to last record in table.
  284.     CASE 35
  285.         CALL SaveRecord                 ' Save current record if changed.
  286.         MOVELAST BigRec.TableNum
  287.         CALL DisplayRecord
  288.  
  289.     ' Home key - moves to first record in table.
  290.     CASE 36
  291.         CALL SaveRecord                 ' Save current record if changed.
  292.         MOVEFIRST BigRec.TableNum
  293.         CALL DisplayRecord
  294.     END SELECT
  295. END SUB
  296.  
  297. ' ISAM file opening/creation routine.
  298. ' Attempts to open sample ISAM file 'BOOKS.MDB'.  If
  299. ' open fails or file does not exist, a new file is
  300. ' created.
  301. '
  302. SUB OpenFile ()
  303.     ' Setup error handling for ISAM file open errors.
  304.     ON LOCAL ERROR GOTO OpenError
  305.  
  306.     ' Clear screen.
  307.     CLS
  308.  
  309.     ' Open sample ISAM file if it exists.
  310.     IF DIR$("BOOKS.MDB") <> "" THEN
  311.         OPEN "BOOKS.MDB" FOR ISAM Books "BookStock" AS cBookStockTableNum
  312.         OPEN "BOOKS.MDB" FOR ISAM Borrowers "CardHolders" AS cCardHoldersTableNum
  313.         OPEN "BOOKS.MDB" FOR ISAM BookStatus "BooksOut" AS cBooksOutTableNum
  314.  
  315.     ' Create a new file if sample can't be found.
  316.     ' Note, this will always occur the first time this
  317.     ' program is run since no sample file is shipped.
  318.     ELSE
  319.         LOCATE 3, 10
  320.         PRINT "Sample ISAM file 'BOOKS.MDB' not found in "
  321.         LOCATE 4, 10
  322.         PRINT CURDIR$ + ".  Creating new 'BOOKS.MDB'.  Please wait..."
  323.  
  324.         ' Create new BOOKS.MDB sample file.
  325.         OPEN "BOOKS.MDB" FOR ISAM Books "BookStock" AS cBookStockTableNum
  326.         OPEN "BOOKS.MDB" FOR ISAM Borrowers "CardHolders" AS cCardHoldersTableNum
  327.         OPEN "BOOKS.MDB" FOR ISAM BookStatus "BooksOut" AS cBooksOutTableNum
  328.  
  329.         ' Create table indexes.
  330.         CREATEINDEX cBookStockTableNum, "TitleIndexBS", 0, "Title"
  331.         CREATEINDEX cBookStockTableNum, "AuthorIndexBS", 0, "Author"
  332.         CREATEINDEX cBookStockTableNum, "PubIndexBS", 0, "Publisher"
  333.         CREATEINDEX cBookStockTableNum, "IDIndex", 1, "IDnum"     ' Note unique index
  334.         CREATEINDEX cBookStockTableNum, "BigIndex", 0, "Title", "Author", "IDnum"
  335.         CREATEINDEX cBooksOutTableNum, "IDIndexBO", 0, "IDnum"
  336.         CREATEINDEX cBooksOutTableNum, "CardNumIndexBO", 0, "CardNum"
  337.         CREATEINDEX cCardHoldersTableNum, "NameIndexCH", 0, "TheName"
  338.         CREATEINDEX cCardHoldersTableNum, "StateIndexCH", 0, "State"
  339.         CREATEINDEX cCardHoldersTableNum, "ZipIndexCH", 0, "Zip"
  340.         CREATEINDEX cCardHoldersTableNum, "CardNumIndexCH", 1, "CardNum"  ' Unique index
  341.  
  342.         READ count%
  343.         FOR i% = 1 TO count%
  344.             READ BigRec.Lendee.TheName, BigRec.Lendee.Street, BigRec.Lendee.City, BigRec.Lendee.State, BigRec.Lendee.Zip, BigRec.Lendee.CardNum
  345.             INSERT cCardHoldersTableNum, BigRec.Lendee
  346.         NEXT i%
  347.         READ count%
  348.         FOR i% = 1 TO count%
  349.             READ BigRec.Inventory.Title, BigRec.Inventory.Author, BigRec.Inventory.Publisher, BigRec.Inventory.Price, BigRec.Inventory.Edition, BigRec.Inventory.IDnum
  350.             INSERT cBookStockTableNum, BigRec.Inventory
  351.         NEXT i%
  352.         READ count%
  353.         FOR i% = 1 TO count%
  354.             READ BigRec.OutBooks.CardNum, BigRec.OutBooks.IDnum, BigRec.OutBooks.DueDate
  355.             INSERT cBooksOutTableNum, BigRec.OutBooks
  356.         NEXT i%
  357.     END IF
  358.  
  359.     EXIT SUB
  360.  
  361. ' File open error handling routine.
  362. OpenError:
  363.     SELECT CASE ERR
  364.     ' Correct ISAM support not loaded.
  365.     CASE 73:
  366.         LOCATE 6, 10
  367.         PRINT "ISAM support not available.  Exit and load PROISAMD.EXE."
  368.         END
  369.  
  370.     ' General handling for all other errors.
  371.     CASE ELSE
  372.         LOCATE 6, 10
  373.         PRINT "Error: " + ERROR$ + "."
  374.         LOCATE 7, 10
  375.         PRINT "Please correct the problem then restart the program."
  376.         LOCATE 8, 10
  377.         PRINT "To create a new sample ISAM file, delete 'BOOKS.MDB' from"
  378.         LOCATE 9, 10
  379.         PRINT CURDIR$ + " then restart the program."
  380.  
  381.         END
  382.     END SELECT
  383. END SUB
  384.  
  385. ' Record update routine.
  386. ' Checks for changes to current record and prompts
  387. ' user to save them.
  388. '
  389. SUB SaveRecord ()
  390.     ' Setup error handling for save errors.
  391.     ON LOCAL ERROR GOTO SaveError
  392.  
  393.     ' Save changes to BookStock record only if record
  394.     ' changed and active table is BookStock table.
  395.     IF BookRecordChanged AND BigRec.TableNum = cBookStockTableNum THEN
  396.         ' Prompt to save changes.
  397.         x% = MSGBOX("Save updated record?", 4, frmBooklook.Caption)
  398.  
  399.         ' Get changed values from textboxes and update record.
  400.         IF x% = 6 THEN
  401.             BigRec.Inventory.Author = frmBookStock.txtAuthor.Text
  402.             BigRec.Inventory.Edition = VAL(frmBookStock.txtEdition.Text)
  403.             BigRec.Inventory.IDnum = VAL(frmBookStock.txtID.Text)
  404.             BigRec.Inventory.Price = VAL(frmBookStock.txtPrice.Text)
  405.             BigRec.Inventory.Publisher = frmBookStock.txtPublisher.Text
  406.             BigRec.Inventory.Title = frmBookStock.txtTitle.Text
  407.             UPDATE BigRec.TableNum, BigRec.Inventory
  408.         END IF
  409.  
  410.         BookRecordChanged = FALSE       ' Reset record changed flag.
  411.  
  412.     ' Save changes to CardHolders record only if record
  413.     ' changed and active table is CardHolders table.
  414.     ELSEIF CardRecordChanged AND BigRec.TableNum = cCardHoldersTableNum THEN
  415.         ' Prompt to save changes.
  416.         x% = MSGBOX("Save updated record?", 4, frmBooklook.Caption)
  417.  
  418.         ' Get changed values from textboxes and update record.
  419.         IF x% = 6 THEN
  420.             BigRec.Lendee.TheName = frmCardHolder.txtName.Text
  421.             BigRec.Lendee.Street = frmCardHolder.txtStreet.Text
  422.             BigRec.Lendee.City = frmCardHolder.txtCity.Text
  423.             BigRec.Lendee.State = frmCardHolder.txtState.Text
  424.             BigRec.Lendee.Zip = VAL(frmCardHolder.txtZip.Text)
  425.             BigRec.Lendee.CardNum = VAL(frmCardHolder.txtCardNum.Text)
  426.             UPDATE cCardHoldersTableNum, BigRec.Lendee
  427.         END IF
  428.  
  429.         CardRecordChanged = FALSE           ' Reset record changed flag.
  430.     END IF
  431.  
  432.     EXIT SUB
  433.  
  434. ' Save error handling routine.
  435. SaveError:
  436.     SELECT CASE ERR
  437.     CASE 86                             ' Duplicate index
  438.         MSGBOX ERROR$, 0, frmBooklook.Caption
  439.         EXIT SUB
  440.     CASE ELSE                           ' Ignore other errors and continue.
  441.         RESUME NEXT
  442.     END SELECT
  443. END SUB
  444.  
  445.