' Filename: BOOK.BAS
'
' Book Management Database Program
' ---- ---------- -------- -------
'
' This program illustrates using QBasic to create a book-tracking
' database program.  You can keep track of your book inventory,
' the authors in your library, the price you paid for each book,
' the condition of teh book, and more.

' The program's easy-to-use data-entry screens and reports
' make keeping track of your persnal collection of books easy.
'

'
' Updated by,
'   Richard Copeland 1995


' SUBS (31) total

DECLARE SUB RandPal ()
DECLARE SUB ScreenSaver ()
DECLARE SUB LeaveManagment ()
DECLARE SUB EditData ()
DECLARE SUB GetLookTitle (s.title$)
DECLARE SUB LookBook ()
DECLARE SUB DispScrnTitlesT ()
DECLARE SUB ScrnPrintT (init%, author$, title$, edition$, cover$)
DECLARE SUB DispScrnTitlesA ()
DECLARE SUB ScrnPrintA (init%, author$, title$, edition$, cover$)
DECLARE SUB ScrnOrPrint (dev$)
DECLARE SUB PrinterPrintT (init%, author$, title$, edition$, cover$)
DECLARE SUB PrintTitles ()
DECLARE SUB PrinterPrintA (init%, author$, title$, edition$, cover$)
DECLARE SUB PrintBookTitle ()
DECLARE SUB PrintBookAuth ()
DECLARE SUB DispMessage (mess$)
DECLARE SUB FileSearch (s.title$)
DECLARE SUB PressEnter ()
DECLARE SUB BadThe ()
DECLARE SUB GetFileName ()
DECLARE SUB GetField (row%, col%, data$)
DECLARE SUB GetCover (cover$)
DECLARE SUB FixTitle ()
DECLARE SUB ErrorMsg1 (Message$)
DECLARE SUB DispFieldData ()
DECLARE SUB DispPrompts ()
DECLARE SUB EnterBook (MaxNumBooks%)
DECLARE SUB DispFieldNames ()
DECLARE SUB DispMenu ()



TYPE bookrec
   title    AS STRING * 30   ' Title of book
   author   AS STRING * 25   ' Author name
   cond     AS STRING * 10   ' Condition
   pubdate  AS STRING * 20   ' Publication Date
   edition  AS STRING * 10   ' Edition (1st, 2nd, etc.)
   cover    AS STRING * 1    ' H/S for Hardcover or Softcover
   notes    AS STRING * 160  ' Misc. notes on the book
END TYPE

' The followign are global since almost EVERY procedure needs
' them
COMMON SHARED Book AS bookrec            ' A user-defined type
COMMON SHARED bookfile$                  ' Book datafile to use

CLS
GetFileName       ' Get the filename of the book file
READ MaxNumBooks% ' Maximum number of books to enter
DATA 500
DO
  DispMenu        ' Display menu and get menu option
  SELECT CASE menu.option%
      CASE (1): EnterBook (MaxNumBooks%) ' Get a book
      CASE (2): LookBook          ' Look at an individual book
      CASE (3): PrintBookAuth     ' Print book listing by author
      CASE (4): PrintBookTitle    ' Print book lisitng by title
      CASE (5): GetFileName       ' Get a specific book file
      CASE (6): ScreenSaver       ' Will Start Screen Saver
      CASE (7): LeaveManagment    ' Will leave and return to Program Manager
   CASE ELSE
     LeaveManagment
   END SELECT

LOOP UNTIL (menu.option% = 8)

SUB BadThe
'
' Prints error at bottom of screen if
' they typed The as the first three letters
' of title.
'
  CALL ErrorMsg1("The title cannot begin with `The'")
  LOCATE 24, 16
  PRINT "Press ENTER to try another one...";
  LINE INPUT ; ans$
  LOCATE 24, 12
  PRINT 24, 12
  PRINT SPACE$(80)    ' Erase the error messages
  COLOR 7, 1
 
END SUB

SUB DispFieldData
'
' Displays Found book's data in highlighted fields.
'
  COLOR 15, 1           ' Highlight data in fields
  LOCATE 6, 12          ' Print a match from file
  PRINT Book.title
  LOCATE 8, 13
  PRINT Book.author
  LOCATE 11, 16
  PRINT Book.cond
  LOCATE 11, 53
  PRINT Book.pubdate
  LOCATE 15, 14
  PRINT Book.edition
  LOCATE 15, 58
  PRINT Book.cover
  LOCATE 18, 12
  PRINT RTRIM$(Book.notes)

END SUB

SUB DispFieldNames
'
' Simply prints the names of each field
' in their place of teh screen, and a
' lot of spaces after them to clear
' whatever may still be on the line.
'
  COLOR 7, 1
  LOCATE 6, 5
  PRINT "Group:" + SPACE$(50);
  LOCATE 8, 5
  PRINT "Title:" + SPACE$(50);
  LOCATE 11, 5
  PRINT "Layble:" + SPACE$(20);
  LOCATE 11, 35
  PRINT "(C) Date:" + SPACE$(20);
  LOCATE 15, 5
  PRINT "Volum:" + SPACE$(20);
  LOCATE 15, 35
  PRINT "Caset/Compact (C/D):" + SPACE$(20);
  LOCATE 18, 5
  PRINT "Notes:" + SPACE$(50);  ' Old notes on the screen may
  LOCATE 19, 1                  ' take more than one line
  PRINT SPACE$(79);
  LOCATE 20, 1
  PRINT SPACE$(79);
 

END SUB

SUB DispMenu
'
' This subroutine simply displays the book database main menu.
' The user enters the option he or she desires.
' The menu keeps displaying until a valid option is entered.
'

SHARED menu.option%   ' Be able to use the main procedure's
                      ' variable

COLOR 7, 1    ' White letters on blue background
CLS
PRINT
PRINT TAB(20); "*** CD Database Program ***"
PRINT
PRINT
PRINT TAB(10); "Here are your choices:"
PRINT
PRINT TAB(20); "1.  Enter a new CD"
PRINT
PRINT TAB(20); "2.  Search For CD(s) to edit"
PRINT
PRINT TAB(20); "3.  Print a listing of all CD(s) by Artist"
PRINT
PRINT TAB(20); "4.  Print a listing of all CD(s) by title"
PRINT
PRINT TAB(20); "5.  Change CD File"
PRINT
PRINT TAB(20); "6.  Start Screen Saver"
PRINT
PRINT TAB(20); "7.  Exit this program"
PRINT
PRINT TAB(10); "What is your choice? _"
DO
  ans$ = INKEY$
LOOP WHILE (ans$ = "")

LOCATE 21, 31                   ' Echo the user's input
PRINT ans$

menu.option% = VAL(ans$)

END SUB

SUB DispMessage (mess$)
'
' Displays a red message at bottom of screen
'
 DIM messline AS STRING * 79    ' Message line that will be
                                ' printed
 COLOR 12, 1    ' Bright red characters on blue
 mess$ = "*** " + mess$ + " ***"         ' Enclose in asterisks
 mlen = LEN(mess$)    ' Length of error message to print
 MID$(messline, (79 - mlen) / 2) = mess$  ' Center error
                                          ' message

 LOCATE 23, 1
 PRINT messline;

 COLOR 7, 1     ' Restore white on blue

END SUB

SUB DispPrompts
'
' This subroutine is called from the data-entry routine.
' It simply prints the dat-entry screen title and prompts
' for each field.
'
  COLOR 7, 1
  PRINT
  PRINT TAB(20); "*** Enter a CD's Information ***"
  PRINT TAB(20); "    --------------------------"
 
  CALL DispFieldNames             ' Display field names


END SUB

SUB DispScrnTitlesA
'
' Prints new titles on the screen, by Author field.
'
  PRINT "Group"; TAB(27); "Title"; TAB(58); "Vollum";
  PRINT TAB(69); "Type"
  PRINT STRING$(79, "-");


END SUB

SUB DispScrnTitlesT
'
' Prints new titles on the screen, Title field first.
'
  PRINT "Group"; TAB(32); "Title"; TAB(58); "Vollum";
  PRINT TAB(69); "Type"
  PRINT STRING$(79, "-");


END SUB

SUB EditData
'
' This routine lets the user press ENTER through the data,
' changing whatever needs to be changed on the screen.
'
  COLOR 15, 1           ' Highlight all input

 
  LOCATE 6, 12
  LINE INPUT title$
  IF (title$ <> "") THEN
     Book.title = title$
     CALL FixTitle
     LOCATE 6, 12
     PRINT Book.title
  END IF

 
  LOCATE 8, 13
  LINE INPUT author$
  IF (author$ <> "") THEN Book.author = author$
  LOCATE 8, 13
  PRINT Book.author

 
  LOCATE 11, 16
  LINE INPUT cond$
  IF (cond$ <> "") THEN Book.cond = cond$
  LOCATE 11, 16
  PRINT Book.cond

 
  LOCATE 11, 53
  LINE INPUT pubdate$
  IF (pubdate$ <> "") THEN Book.pubdate = pubdate$
  LOCATE 11, 53
  PRINT Book.pubdate
  
 
  LOCATE 15, 14
  LINE INPUT edition$
  IF (edition$ <> "") THEN Book.edition = edition$
  LOCATE 15, 14
  PRINT Book.edition

 
  GetCover (cover$)
  IF (cover$ <> "") THEN Book.cover = cover$
  COLOR 15, 1
  LOCATE 15, 58
  PRINT Book.cover

 
  LOCATE 18, 12
  LINE INPUT notes$
  IF (notes$ <> "") THEN Book.notes = notes$
  LOCATE 18, 12
  PRINT RTRIM$(Book.notes)


END SUB

SUB EnterBook (MaxNumBooks%)
'
' This subroutine gets the user's input for a book.
' That information is then written to the file.
'
  OPEN bookfile$ FOR APPEND AS #1       ' Add to end of file
  IF LOC(1) / (LEN(Book) + 19) > MaxNumBooks% THEN
     CLS
     ErrorMsg1 ("This file has the maximum number of CD's")
     CLOSE #1
     EXIT SUB
  END IF

  DO                            ' Repeat until they want to quit
    CLS
   
    CALL DispPrompts            ' Display the screen prompts
    CALL GetField(6, 12, Book.title)  ' Get the title, etc.
    IF (Book.title = SPACE$(30)) THEN ' If they only pressed ENTER,
        CLOSE #1            ' close the data file without writing
        EXIT SUB            ' to it, and return to the Main Menu.
        END IF
        CALL FixTitle       ' Move `The' to end of title, if needed
        COLOR 7, 1
        CALL GetField(8, 13, Book.author)
        CALL GetField(11, 16, Book.cond)
        CALL GetField(11, 53, Book.pubdate)
        CALL GetField(15, 14, Book.edition)
       
        Book.cover = UCASE$(Book.edition)    ' Convert it to uppercase
                                             ' Ensure that an
                                             ' H or S is entered
        CALL GetCover(Book.cover)

       
        CALL GetField(18, 12, Book.notes)

       
        DO
          LOCATE 23, 15
          COLOR 12, 1
          INPUT "Do you want to change anything (Y/N)"; ans$
          IF (UCASE$(LEFT$(ans$, 1)) = "Y") THEN
             LOCATE 23, 15
             PRINT STRING$(60, " ")
             CALL EditData
          END IF
        LOOP UNTIL (UCASE$(LEFT$(ans$, 1)) = "N")

        WRITE #1, Book.title, Book.author, Book.cond
        WRITE #1, Book.pubdate, Book.edition, Book.cover, Book.notes
       
        LOCATE 23, 15           ' See if they want another
        COLOR 12, 1             ' Red on blue
        PRINT STRING$(60, " ")
        LOCATE 23, 15
        INPUT "Do you want to enter another (Y/N)"; ans$
        ans$ = UCASE$(ans$)
    
     LOOP UNTIL (LEFT$(ans$, 1) = "N")
     CLOSE #1

END SUB

SUB ErrorMsg1 (Message$)
'
' Briefly displays a red error message at bottom of screen.
'

DIM errorline AS STRING * 79    ' Error line that will be
                                ' printed

BEEP
COLOR 12, 1     ' Red characters on blue
Message$ = "*** " + Message$ + " ***"   ' Enclose in asterisks
lerr = LEN(Message$)    ' Length of error message to print
MID$(errorline, (79 - lerr) / 2) = Message$  ' Center error message

LOCATE 23, 1
PRINT errorline;

FOR i = 1 TO 1000  ' Timing loop while user reads error
NEXT i


errorline = STRING$(79, " ")    ' Blank the message and return the colors


LOCATE 23, 1
PRINT errorline;
COLOR 7, 1


END SUB

SUB FileSearch (s.title$)
'
' Searches for the title (or partial title) the usre enterd.
'


  OPEN bookfile$ FOR INPUT AS #1

  DO            ' Search through file for book
    CALL DispFieldNames
    INPUT #1, Book.title, Book.author
    INPUT #1, Book.cond, Book.pubdate
    INPUT #1, Book.edition, Book.cover, Book.notes

    IF (LEFT$(UCASE$(Book.title), LEN(s.title$)) = UCASE$(s.title$)) THEN
        CALL DispFieldData ' Display each field's data
        LOCATE 23, 10      ' Clear bottom message area
        PRINT SPACE$(70)
    DO                     ' See if this is the correct book
      LOCATE 23, 15
      COLOR 12, 1          ' Bold red on blue
      PRINT "Is this the correct CD you were looking for ";
      INPUT "(Y/N)"; ans$
      ans$ = UCASE$(ans$)
    LOOP UNTIL ((ans$ = "Y") OR (ans$ = "N"))
    IF (ans$ = "Y") THEN        ' Wait until they are through
     
       CALL EditData
      
       CLOSE #1
       EXIT SUB                 ' Return to Main Menu
    END IF
  END IF
LOOP UNTIL (EOF(1))
CLOSE #1
ErrorMsg1 ("There are no more CD's to search for")


END SUB

SUB FixTitle
'
' If the title starts with "The..." this routine
' will move ", The" to the end of the title.
'
  
  IF UCASE$(LEFT$(Book.title, 4)) = "THE " THEN
     ' Trim any trailing spaces, temporarily, off the title.
     ' Then append ', The' to the end of the book title
     ' and take off the prefix `The' before actually saving the
     ' "real" title.
     Book.title = RIGHT$(RTRIM$(Book.title), LEN(RTRIM$(Book.title)) - 4)
     Book.title = RTRIM$(Book.title) + ", The"
     COLOR 15, 1
     LOCATE 6, 12
     PRINT Book.title        ' Display the new title
  END IF


END SUB

SUB GetCover (cover$)
'
' This routine ensures that the user types either
' an H or S for Hardcover or Softcoer, respectively.
'
  DO
    CALL GetField(15, 58, cover$)
    cover$ = UCASE$(cover$)
    IF ((cover$ <> "C") AND (cover$ <> "D") AND (cover$ <> "")) THEN CALL ErrorMsg1("You must type an C or D")
    
  LOOP UNTIL ((cover$ = "C") OR (cover$ = "D") OR (cover$ = " "))
  LOCATE 23, 10    ' Remove error message
  PRINT SPACE$(26)
  LOCATE 15, 58    ' Display uppercase equivalent of the S or H
  COLOR 15, 1      ' Highlght it
  PRINT cover$
  COLOR 7, 1       ' Back to normal characters
END SUB

SUB GetField (row%, col%, data$)
'
' A small function used to place cursor and
' highlihgt input data for each field.
'
  LOCATE row%, col%
  LINE INPUT data$
  LOCATE row%, col%
  COLOR 15, 1
  PRINT data$; "  "
  COLOR 7, 1


END SUB

SUB GetFileName
'
' Asks the user for the name of the disk file to use.
' This allows for more than one data file.  They might have
' a file of technical books, on for fiction, etc.
'

CLS     ' Clears the Menu Options
 
  LOCATE 10, 10
  INPUT "What is the name of the CD file to use"; bookfile$

  IF (RIGHT$(bookfile$, 4) <> ".DAT") THEN     ' Append the extension
    
     bookfile$ = bookfile$ + ".DAT"
  END IF

END SUB

SUB GetLookTitle (s.title$)
'
' Get a valid title to look for.
' The user cannot begn a title with `The' when searching.
'
  DO
    LOCATE 23, 12       ' Bottom of screen message telling user
                        ' what to do
    COLOR 12, 1         ' Red on Blue Colors
    PRINT "* * Type a title, or first few letters of title * *"
    COLOR 7, 1          ' White on blue again
    LOCATE 6, 12
    PRINT SPACE$(60)    ' Clear anything that might be onscreen
    CALL GetField(6, 12, s.title$)    ' Get title to search for
    IF (s.title$ = "") THEN EXIT SUB  ' If they only pressed
                                      ' ENTER, return
    IF (LEFT$(UCASE$(s.title$), 3) = "THE ") THEN
       CALL BadThe   ' Do not let them start title with The...
    END IF
  LOOP WHILE (LEFT$(UCASE$(s.title$), 3) = "THE ")


END SUB

SUB LeaveManagment

'Will Decide if you want to leave or stay

CLS
PRINT
PRINT "You are about to Leave the CD Database Managment Program"
INPUT "Continue (Y/N)"; W$
IF W$ = "Y" THEN CLS : PRINT "Please Wait...": CHAIN "moneycga"
IF W$ = "N" THEN CLS : CALL DispMenu
IF W$ = "y" THEN CLS : PRINT "Please Wait...": CHAIN "moneycga"
IF W$ = "n" THEN CLS : CALL DispMenu

END SUB

SUB LookBook
'
' Requests a title, or partial title, and displays that book's
' information.
'
  CLS
  PRINT
  PRINT TAB(20); ' "*** Look at a Cd's Information ***"
  PRINT TAB(20); "      ----------------------------"
  CALL DispFieldNames           ' Display the field names on the screen
  CALL GetLookTitle(s.title$)   ' Get the title to look for
  CALL FileSearch(s.title$)     ' Search for the title


END SUB

SUB PressEnter
'
' Prompt, in red at bottom of screen, for user to press ENTER
'
  COLOR 12, 1
  LOCATE 23, 15
  PRINT SPACE$(60)
  LOCATE 23, 20
  LINE INPUT ; "Press ENTER to continue..."; ans$
  COLOR 7, 1


END SUB

SUB PrintBookAuth
'
' Prints a report alphabetically by the author's name.  (This
' implies that the user entered them in last name order!)
' The file is read into parallel arrays and stored.
'
  REDIM author$(500), title$(500)   ' Parallel arrays to hold
  REDIM edition$(500), cover$(500) ' the data printed

  CALL DispMessage("Please wait while sorting...")    ' Tell user to wait
 
 OPEN bookfile$ FOR INPUT AS #1
  num.recs = 1

  DO
    INPUT #1, title$(num.recs), author$(num.recs)
    INPUT #1, cond$, pubdate$, edition$(num.recs)
    INPUT #1, cover$(num.recs), notes$
    num.rec = num.recs + 1
  LOOP UNTIL (EOF(1))
  CLOSE #1
FOR i = 1 TO num.recs
  FOR j = i TO num.recs - 1
    IF (author$(i) > author$(j)) THEN
       SWAP author$(i), author$(j)
       SWAP title$(i), title$(j)
       SWAP edition$(i), edition$(j)
       SWAP cover$(i), cover$(j)
    END IF
  NEXT j
NEXT i


CALL ScrnOrPrint(dev$)    ' Asks if user wants data on screen or printer

IF (dev$ = "S") THEN
   CALL ScrnPrintA(1, "", "", "", "")   ' Initalize Screen
ELSE
   CALL PrinterPrintA(1, "", "", "", "") ' Initialize Screen
END IF


FOR ctr = 1 TO num.recs
   IF (dev$ = "S") THEN
      CALL ScrnPrintA(0, author$(ctr), title$(ctr), edition$(ctr), cover$(ctr))
   ELSE
      CALL PrinterPrintA(0, author$(ctr), title$(ctr), edition$(ctr), cover$(ctr))
  
   END IF
NEXT ctr
CALL PressEnter


END SUB

SUB PrintBookTitle
'
' Prints a report alphabetically by the title.  The file is
' read into parallel arrays and sorted.
'
  REDIM author$(500), title$(500)   ' Parallel arrays to hold
  REDIM edition$(500), cover$(500) ' the data printed
 
 
  CALL DispMessage("Please wait while sorting...")  ' Tell user to wait
 
 
  OPEN bookfile$ FOR INPUT AS #1
  num.recs = 1

 
  DO
    INPUT #1, title$(num.recs), author$(num.recs)
    INPUT #1, cond$, pubdate$, edition$(num.recs)
    INPUT #1, cover$(num.recs), notes$
    num.recs = num.recs + 1
  LOOP UNTIL (EOF(1))
  CLOSE #1

  FOR i = 1 TO num.recs
    FOR j = i TO num.recs - 1
      IF (title$(i) > title$(j)) THEN
         SWAP author$(i), author$(j)
         SWAP title$(i), title$(j)
         SWAP edition$(i), edition$(j)
         SWAP cover$(i), cover$(j)
      END IF
    NEXT j
  NEXT i

  CALL ScrnOrPrint(dev$)    ' Asks if user wants data on screen or printer
 
  IF (dev$ = "S") THEN
     CALL ScrnPrintT(1, "", "", "", "")    ' Intitalize Screen
  ELSE
     CALL PrinterPrintT(1, "", "", "", "")    ' Initialize Screen
  END IF

  FOR ctr = 1 TO num.recs
     IF (dev$ = "S") THEN
        CALL ScrnPrintT(0, author$(ctr), title$(ctr), edition$(ctr), cover$(ctr))
     ELSE
       CALL PrinterPrintT(0, author$(ctr), title$(ctr), edition$(ctr), cover$(ctr))
     END IF
NEXT ctr
     CALL PressEnter

END SUB

SUB PrinterPrintA (init%, author$, title$, edition$, cover$)
'
' Prints a record on the printer.  This subroutine keeps track
' or the printed lines and prints a title at each new page
' (after 66 lines) and form feeds at the end of each page.  If
' the  init& argument is equal to 1, this routine zeros out the
' printing variables and assumes this call is the start of a new
' listing.  Otherwise, the static variables keep their values.
'
  
  STATIC linect AS INTEGER

      IF (init% = 1) THEN   ' If this were called for 1st time...
         LPRINT CHR$(11)    ' Form Feed
         linect = 3
         CALL PrintTitles
         EXIT SUB
      END IF                ' Else, all future times after 1st...

      IF (linect = 2) THEN
         CALL PrintTitles
         linect = 3
      END IF

      LPRINT title$; TAB(3); author$; TAB(58); edition$; TAB(69); cover$

      linect = linect + 1
      IF linect = 64 THEN
         linect = 2
         LPRINT CHR$(11)
      END IF


END SUB

SUB PrinterPrintT (init%, author$, titel$, edition$, cover$)
'
' Prints a record on the printer.  This subroutine keeps track
' of the printed lines and prints a title at ech new page
' (after 66 lines) and form feeds at the end of each page.  If
' the init% argumentis equal to 1, this routinezeros out the
' printing variables and ssumes this call is teh start of a new
' listing.  Otherwise, the static variables keep their values.
'

STATIC linect AS INTEGER

  IF (init% = 1) THEN    ' If this were called for 1st time...
     LPRINT CHR$(11)     ' Form Feed
     linect = 3
     CALL PrintTitles
     EXIT SUB
  END IF                 ' Else, all future times after 1st...

  IF (linect = 2) THEN
     CALL PrintTitles
     linect = 3
  END IF

  LPRINT title$; TAB(32); autor$; TAB(58); edition$; TAB(69); cover$

  linect = linect + 1
  IF linect = 64 THEN
     linect = 2
     LPRINT CHR$(11)
  END IF


END SUB

SUB PrintTitles
'
' Prints new titles on the printer
'
  LPRINT "Group"; TAB(32); "Title"; TAB(58); "Vollum";
  LPRINT TAB(69); "Type"
  LPRINT STRING$(79, "-");


END SUB

SUB RandPal
  
    FOR WorkColor = 1 TO 15
        red = RND * 63
        green = RND * 63
        blue = RND * 63

    NEXT

END SUB

SUB ScreenSaver

' Will Start Screen Saver

DO
  CLS : SLEEP 1
 LOCATE 12, 20: PRINT "[press the S P A C E  B A R to continue]"
   SLEEP 5
LOOP UNTIL INKEY$ = " "

CALL DispMenu

END SUB

SUB ScrnOrPrint (dev$)
'
' Asks the user if he or she wants to print the list
' on the screen or printer.
'
  CLS

  DO
    LOCATE 12, 8
    PRINT "Do you want to see listing on the Screen or Printer ";
    INPUT "(S/P)"; dev$
    dev$ = UCASE$(LEFT$(dev$, 1))  ' Convert singe-letter answer to upper
  LOOP UNTIL ((dev$ = "S") OR (dev$ = "P"))
  CLS


END SUB

SUB ScrnPrintA (init%, author$, title$, edition$, cover$)
'
' Prints a record on the screen.  This subroutine keeps track
' of the screen lines printd and prints a title at each
' new screen and pauses at the end of each.  If the init%
' argument is equal to 1, this routine zeros out the display
' variables and assumes this call is the start of a new
' listing.  Otherwise, the static variables keep their values.
'

STATIC linect AS INTEGER

    IF (init% = 1) THEN         ' If this were called for 1st time....
       CLS
       linect = 3
       CALL DispScrnTitlesA
       EXIT SUB
    END IF                      ' Else, all future times after 1st...

IF (linect = 2) THEN
   CALL DispScrnTitlesA
   linect = 3
END IF

LOCATE linect, 1
PRINT author$

LOCATE linect, 27
PRINT title$

LOCATE linect, 58
PRINT edition$

LOCATE linect, 69
PRINT cover$

linect = linect + 1
IF linect = 22 THEN
   CALL PressEnter
   linect = 2
   CLS
END IF

END SUB

SUB ScrnPrintT (init%, author$, title$, edition$, cover$)
'
' Prints a record on the screen.   This subroutine keeps track
' of the screen lines printed and prints a title at each
' new screen and pauses at the end of each.  if the init%
' argument is equal to 1, this routine zeros out he display
' cariables and assumes this call is the start of a new
' listing.  Otherwise, the static variables keep their values.
'

STATIC linect AS INTEGER

   IF (init% = 1) THEN    ' If this were called for 1st time...
      CLS
      linect = 3
      CALL DispScrnTitlesT
      EXIT SUB
      END IF                    ' Elese, all future times after 1st...

      IF (linect = 2) THEN
         CALL DispScrnTitlesT
         linect = 3
      END IF

      LOCATE linect, 1
      PRINT title$

      LOCATE linect, 32
      PRINT author$

      LOCATE linect, 58
      PRINT edition$

      LOCATE linect, 69
      PRINT cover$

      linect = linect + 1
      IF linect = 22 THEN
         CALL PressEnter
         linect = 2
         CLS
      END IF


END SUB

