home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 101.img / QB45-1.ZIP / QLBDUMP.BAS < prev    next >
BASIC Source File  |  1988-08-12  |  3KB  |  89 lines

  1. ' This program prints the names of QuickLibrary procedures
  2.  
  3. DECLARE SUB DumpSym (SymStart AS INTEGER, QHdrPos AS LONG)
  4.  
  5. TYPE ExeHdr                  ' Part of DOS .EXE header
  6.     other1    AS STRING * 8  ' Other header information
  7.     CParHdr   AS INTEGER     ' Size of header in paragraphs
  8.     other2    AS STRING * 10 ' Other header information
  9.     IP        AS INTEGER     ' Initial IP value
  10.     CS        AS INTEGER     ' Initial (relative) CS value
  11. END TYPE
  12.  
  13. TYPE QBHdr                   ' QLB header
  14.     QBHead    AS STRING * 6  ' QB specific heading
  15.     Magic     AS INTEGER     ' Magic word: identifies file as
  16.                              ' a Quick library
  17.     SymStart  AS INTEGER     ' Offset from header to first code symbol
  18.     DatStart  AS INTEGER     ' Offset from header to first data symbol
  19. END TYPE
  20.  
  21. TYPE QbSym                   ' QuickLib symbol entry
  22.     Flags     AS INTEGER     ' Symbol flags
  23.     NameStart AS INTEGER     ' Offset into name table
  24.     other     AS STRING * 4  ' Other header info
  25. END TYPE
  26.  
  27. DIM EHdr AS ExeHdr, Qhdr AS QBHdr, QHdrPos AS LONG
  28.  
  29. INPUT "Enter QuickLibrary file name: ", FileName$
  30. FileName$ = UCASE$(FileName$)
  31. IF INSTR(FileName$, ".QLB") = 0 THEN FileName$ = FileName$ + ".QLB"
  32.  
  33. INPUT "Enter output file name or press ENTER for screen: ", OutFile$
  34. OutFile$ = UCASE$(OutFile$)
  35. IF OutFile$ = "" THEN OutFile$ = "CON"
  36.  
  37. OPEN FileName$ FOR BINARY AS #1
  38. OPEN OutFile$ FOR OUTPUT AS #2
  39.  
  40. GET #1, , EHdr               ' Read the EXE format header.
  41.  
  42. QHdrPos = (EHdr.CParHdr + EHdr.CS) * 16 + EHdr.IP + 1
  43.  
  44. GET #1, QHdrPos, Qhdr        ' Read the QuickLib format header.
  45.  
  46. IF Qhdr.Magic <> &H6C75 THEN PRINT "Not a QB UserLibrary": END
  47.  
  48. PRINT #2, "Code Symbols:": PRINT #2,
  49. DumpSym Qhdr.SymStart, QHdrPos ' dump code symbols
  50. PRINT #2,
  51.  
  52. PRINT #2, "Data Symbols:": PRINT #2, ""
  53. DumpSym Qhdr.DatStart, QHdrPos ' dump data symbols
  54. PRINT #2,
  55.  
  56. END
  57.  
  58. SUB DumpSym (SymStart AS INTEGER, QHdrPos AS LONG)
  59.    DIM QlbSym AS QbSym
  60.    DIM NextSym AS LONG, CurrentSym AS LONG
  61.  
  62.    ' Calculate the location of the first symbol entry, then read that entry:
  63.    NextSym = QHdrPos + SymStart
  64.    GET #1, NextSym, QlbSym
  65.  
  66.    DO
  67.       NextSym = SEEK(1)          ' Save the location of the next
  68.                                  ' symbol.
  69.       CurrentSym = QHdrPos + QlbSym.NameStart
  70.       SEEK #1, CurrentSym        ' Use SEEK to move to the name
  71.                                  ' for the current symbol entry.
  72.       Prospect$ = INPUT$(40, 1)  ' Read the longest legal string,
  73.                                  ' plus one additonal byte for the
  74.                                  ' final null character (CHR$(0)).
  75.  
  76.       ' Extract the null-terminated name:
  77.       SName$ = LEFT$(Prospect$, INSTR(Prospect$, CHR$(0)))
  78.  
  79.       ' Print only those names that do not begin with "__", "$", or "b$"
  80.       ' as these names are usually considered reserved:
  81.       IF LEFT$(SName$, 2) <> "__" AND LEFT$(SName$, 1) <> "$" AND UCASE$(LEFT$(SName$, 2)) <> "B$" THEN
  82.          PRINT #2, "  " + SName$
  83.       END IF
  84.  
  85.       GET #1, NextSym, QlbSym    ' Read a symbol entry.
  86.    LOOP WHILE QlbSym.Flags       ' Flags=0 (false) means end of table.
  87. END SUB
  88.  
  89.