home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / database / mf_db.zip / MF.BAS < prev    next >
BASIC Source File  |  1993-05-21  |  5KB  |  126 lines

  1. Option Explicit
  2. '*************  MF DLL calls ***************
  3.  
  4. ' Use this file with any program you create in VB
  5. ' It contains all the declarations needed for accessing
  6. ' the MF database.
  7.  
  8.     ' *** ADMIN ***
  9. Declare Function mfInit% Lib "mf.dll" (extensionDLLs As Any)
  10. Declare Function mfDeInit% Lib "mf.dll" (ByVal task%)
  11. Declare Function mfOpen% Lib "mf.dll" (ByVal FileName$, ByVal task%)
  12. Declare Function mfClose% Lib "mf.dll" (ByVal task%, ByVal dbHndl%)
  13. Declare Function mfCreateDB% Lib "mf.dll" (ByVal FileName$, ByVal RecSize%, ByVal NumIndexs%, rSizeArray As Any, typeArray As Any)
  14.  
  15.     ' *** GENERAL ***
  16. Declare Function mfInfoDB% Lib "mf.dll" (RecSize%, NumIndexs%, NumRecs&, ByVal task%, ByVal dbHndl%)
  17. Declare Function mfInfoIndex% Lib "mf.dll" (ByVal task%, ByVal dbHndl%, ByVal indexNumber%)
  18.  
  19.  
  20.  
  21.     ' *** DATA I/O ***
  22. Declare Function mfRead% Lib "mf.dll" (ByVal RecordNum&, record As Any, ByVal task%, ByVal dbHndl%, ByVal opt%)
  23. Declare Function mfWrite% Lib "mf.dll" (ByVal RecordNum&, record As Any, ByVal task%, ByVal dbHndl%, ByVal opt%)
  24. Declare Function mfDelete% Lib "mf.dll" (ByVal RecordNum&, ByVal task%, ByVal dbHndl%)
  25. Declare Function mfAppendData& Lib "mf.dll" (record As Any, ByVal task%, ByVal dbHndl%)
  26.  
  27.     ' ***  Movement  ***
  28. Declare Function mfTop& Lib "mf.dll" (ByVal task%, ByVal dbHndl%, ByVal indexNumber%)
  29. Declare Function mfBottom& Lib "mf.dll" (ByVal task%, ByVal dbHndl%, ByVal indexNumber%)
  30. Declare Function mfSkip& Lib "mf.dll" (ByVal FromRecord&, ByVal HowFarToSkip&, ByVal task%, ByVal dbHndl%, ByVal indexNumber%)
  31.     ' Since VB doesn't support passing 'void' pointers -- we have to trick it to do the job
  32.     ' SeekS is for STRINGS
  33.     ' SeekO is for anything else...
  34. Declare Function mfSeekS& Lib "mf.dll" Alias "mfSeek" (ByVal skStr$, retcode%, ByVal task%, ByVal dbHndl%, ByVal xNum%)
  35. Declare Function mfSeekO& Lib "mf.dll" Alias "mfSeek" (skStr As Any, retcode%, ByVal task%, ByVal dbHndl%, ByVal xNum%)
  36.  
  37.  
  38.     ' Severe-Performance functions
  39. Declare Function mfReadListS& Lib "mf.dll" Alias "mfReadList" (ByVal record As Long, ByVal skStr$, ByVal FuzzyLength%, hitList As Any, ByVal maxHits&, ByVal task%, ByVal dbHndl%, ByVal xNum%)
  40. Declare Function mfReadListO& Lib "mf.dll" Alias "mfReadList" (ByVal record As Long, skStr As Any, ByVal FuzzyLength%, hitList As Any, ByVal maxHits&, ByVal task%, ByVal dbHndl%, ByVal xNum%)
  41. Declare Function mfReadListNull& Lib "mf.dll" Alias "mfReadList" (ByVal record As Long, ByVal skStr As Long, ByVal FuzzyLength%, hitList As Any, ByVal maxHits&, ByVal task%, ByVal dbHndl%, ByVal xNum%)
  42.  
  43.  
  44.  
  45. ' Constants:
  46. ' READ and WRITE options
  47. Global Const MFRW_ALL = -1
  48. Global Const MFRW_DATA = -2
  49. Global Const MFRW_KEY = -3
  50.  
  51.     ' Seek Top/Bottom
  52.     ' Return codes when there's no higher/lower key
  53.     ' or no data at all...
  54. Global Const MFSEEK_BOF = -1
  55. Global Const MFSEEK_EOF = -2
  56. Global Const MFSEEK_NODATA = -3
  57.  
  58.     ' parameter set in iCode for an mfSeek
  59. Global Const MFSEEK_EXACT_MATCH = 1
  60. Global Const MFSEEK_PARTIAL_MATCH = 2
  61.  
  62.     ' SP constants
  63. Global Const MF_SP_COUNT = -1
  64.  
  65.     ' index type information
  66. Global Const MFCOMP_CHAR = 1
  67. Global Const MFCOMP_INT = 2
  68. Global Const MFCOMP_LONG = 3
  69. Global Const MFCOMP_CHARIC = 4  ' Case insensitive strings
  70. Global Const MFCOMP_UDK = 100   ' Or greater...
  71.  
  72.     ' used for an array on index sizes on createDB
  73. Type tIntArray
  74.     i As Integer
  75. End Type
  76.  
  77.     ' Used for getting a hit-list in the severe-performance functions
  78. Type tLongArray
  79.     l As Long
  80. End Type
  81.  
  82. ' Required on mfInit when using extensions to MF
  83. Type tExtDLL
  84.     type As Integer
  85.     DLLName As String * 128
  86. End Type
  87.  
  88.     ' Need 1 task handle per application instance
  89. Global TaskHndl As Integer ' Task handle # for this instance
  90.  
  91. Sub mfBeginRun ()
  92.     ReDim extDLLs(0 To 1) As tExtDLL
  93.     
  94.     extDLLs(0).type = MFCOMP_UDK    ' tells mf to use this dll for UDK's
  95.     extDLLs(0).DLLName = "mfUDK.dll"
  96.     extDLLs(1).type = -1    ' tells MF there are NO more extensions to load
  97.  
  98.  
  99.     ' Add this line as the first line in your application
  100.     ' (or, at least before you use the dbms)
  101.     ' The TaskHndl is your unique handle to the database
  102.     ' If the hndl is -1, then 10 apps are already accessing the
  103.     ' database -- close some!
  104.     TaskHndl = mfInit(extDLLs(0))
  105.     If TaskHndl < 0 Then
  106.         MsgBox "No database handles available -- please close some active windows"
  107.         End
  108.     End If
  109. End Sub
  110.  
  111. ' Call when you are completely done with the database
  112. ' for the entire program...
  113. Sub mfEndRun ()
  114.     junk = mfDeInit(TaskHndl)
  115. End Sub
  116.  
  117. ' Pad a string with 'char'
  118. Function Pad$ (num%, char$)
  119.     Dim n%, r$
  120.     For n = 1 To num
  121.         r = r + char
  122.     Next n
  123.     Pad = r
  124. End Function
  125.  
  126.