'***********************************************
'*   For this structure see MBMDefs.h /C++ declarations
'***********************************************

'Unit MBMDefs.txt


Global Const db_OK = 0
Global Const db_ErrExists = 1
Global Const db_ErrNotExists = 2
Global Const db_TooManyFields = 3
Global Const db_NoMemAvail = 4
Global Const db_FileNotFound = 5
Global Const db_ReadError = 6
Global Const db_WriteError = 7
Global Const db_RecSizeError = 8
Global Const db_NbRecError = 9
Global Const db_DynRecError = 10
Global Const db_OPNAError = 11
Global Const db_ErrNotNumber = 12
Global Const db_ErrUnknownTable = 13
Global Const db_ErrRecTooFar = 18
Global Const db_ErrTableClosed = 19

Global Const db_FieldSizeError = 48
Global Const db_ErrUnknownType = 34
Global Const db_ErrFieldCount = 30

Global Const Maxfields = 2500





                                ' Table Flags
Global Const fg_Static = 0                  ' fg_Nous + fg_Memoire + fg_Static + fg_ReadWrite
Global Const fg_Disk = 2                    ' fg_Memoire

                                ' Modes for OpenFile
Global Const md_Closed = 0
Global Const md_Consult = 1
Global Const md_Create = 2
Global Const md_ReadWrite = 4

                                ' Modes for AddRecord
Global Const md_BEGINNING = 1
Global Const md_END = 2
Global Const md_SORTED = 4

                                ' Flags for kind of sort in a table
Global Const NoSort = 0
Global Const AscendantSort = 1
Global Const DescendantSort = 2

'***********************************************
'*   For this structure see MBMDefs.h /C++ declarations
'***********************************************

Type PTable
      Version   As Integer      ' compiling version of the table
      IdTable   As String   ' LPSTR in C a table is known by its string identifier
      DataFile  As String   ' LPSTR in C a table may be stored in a data file
                           ' rem  As the full path should be given
      Flags     As Integer   ' defines the type of the table  As
                           '   ---------------------------------------
                           '   MEMORY   As fully in memory
                           '     the table is loaded in memory from
                           '     DataFile and stored in DataFile when
                           '     closed
                           '     if Datafile is NIL, the table may be
                           '     used as a temporary table
                           '   DISK     As fully stored on disk with
                           '             buffered access
                           '     the table is never fully in memory
                           '     (a record one by one or buffered)
                           '   ---------------------------------------
                           '   DYNAMIC  As
                           '     the number of records may change
                           '     during execution
                           '   ---------------------------------------
                           '   READONLY  As
                           '     a table opened in CONSULT mode can not
                           '     modify its records
                           '   READWRITE  As
                           '     a table opened in CONSULT mode can
                           '     modify its records
                           '   ---------------------------------------
      NbFields  As Integer   '  number of fields in each record
      Fields    As String * 21  'LPSTR in C   name of each field in a record
      Types     As String * 21  '  LPSTR in C type of each field in a record  As
                           '    String       Size in memory
                           '    ------       --------------
                           '     BYTE             1
                           '     SHORTINT         1
                           '     CHAR             1
                           '     Integer             2
                           '     INTEGER          2
                           '     LONGINT          4
                           '     REAL             6
                           '     STRINGxxx    xxx + 1
                           '     BUFFBYTExxx    xxx
      Offsets  As Long  '  LPSTR in C Offset from the beginning of the record
                           '  for each field
      MaxRecs   As Integer      '  number max of record allowed for a table
                           '    $FFFF for a DYNAMIC table

      RecSize   As Integer      '  size of a record
      Current   As Integer      '  current record accessed
      NbRecs    As Integer      '  number of records in the table

      Handle    As Integer   '  Handle to allocated memory (static)
      DataPtr   As Long   '  LPSTR in C Pointer to allocated memory (dynamic)
      Modified  As Integer   '  Flag to set when table contents change
      OpenStatus  As Integer    '  Open status As (os_CLOSED, os_CREATE,
                           '                os_CONSULT

      Limits    As Long   '
      Extra      As Long  '  LPSTR in C Pointer to Extra Data Record
      XREFInc    As Integer     '  Increment for XREF Chk
      SortFlag   As Integer     '  Sort's type flag
                           '  NoSort         = 0
                           '  AscendantSort  = 1
                           '  DescendantSort = 2
      CloseFlag  As Integer     '  Not Used Reserved
      DefaultFlag  As Integer  ' if DefaultFlag then default values are
                             ' stored in record 0
      NumFldSort   As Integer    'Number of primary fields on which the
                            'table is sorted

      ModifiedRec  As Integer    'The record number which was modified
      Unique       As Integer    'If there is a Uniqe Field in the record
      TableType    As Integer    'Type of the table
                            'DB    = 0
                            'DBSYS = 2   System table
     Owner    As Long      'LPSTR in C the owner of the table
     VarSize  As Integer   '  LPSTR in C Size of Variable


   End Type

'***********************************************
'UNIT TuADS.txt
' in case of problem : See also Tuads.h C++ function declarations
'***********************************************


Global Const Err_TypeSize = 100

' ***************Export functions of ADS.DLL *****************

Declare Function TbGetCursor Lib "ADS.DLL" (ByVal hClient As Integer) As Integer

Declare Function CloseCursor Lib "ADS.DLL" (ByVal hCursor As Integer) As Integer

Declare Function ClientDone Lib "ADS.DLL" (ByVal hClient As Integer) As Integer

Declare Function fOpenTable Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal FileName As String, ByVal IdTable As String, ByVal mode As Integer) As Integer

'***********************************************
'can not define for visual basic
'Declare Function  DefineTable  Lib "ADS" (hCursor    As Variant, ByVal     IdTable    As  String, ByVal     DataFile   As  String, Flags      As Integer, NbField    As Integer, ByVal     Fields     As  StringArray, ByVal     Types      As  StringArray,MaxRecs    As Variant,SortFlag   As Byte,NumFldSort  As Variant)  As  Integer
'***********************************************


Declare Function CreateTable Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String) As Integer

'***********************************************
'Can not define for VB
'Declare Function  OpenTable Lib "ADS.DLL" (hCursor As Integer,  ByVal IdTable As  String, mode As Integer ) As  Integer
'***********************************************

Declare Function CloseTable Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String) As Integer


Declare Function SaveTable Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String, ByVal FileName As String) As Integer

Declare Function SortTable Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String, ByVal SortType As Integer, ByVal NbField As Integer) As Integer

Declare Function GetTableInfo Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String) As Long


Declare Function ResetTable Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String) As Integer

Declare Function TbResetTable Lib "ADS.DLL" (Table As PTable) As Integer

Declare Function RenameTable Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal FromIdTable As String, ByVal TOIdTable As String) As Integer

Declare Function AddRecord Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String, ByVal Buffer As String, ByVal BufSize As Integer, ByVal mode As Integer) As Integer

Declare Function GetRecord Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String, ByVal RecNb As Integer, ByVal Buffer As String, ByVal BufSize As Integer) As Integer


Declare Function SetRecord Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String, ByVal RecNb As Integer, ByVal Buffer As String, ByVal BufSize As Integer) As Integer


Declare Function DeleteRecord Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String, ByVal RecNb As Integer) As Integer

Declare Function GetField Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String, ByVal idField As String, ByVal PosField As Integer, ByVal RecNb As Integer, ByVal FieldBuffer As String, ByVal FldSize As Integer) As Integer

Declare Function SetField Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String, ByVal idField As String, ByVal PosField As Integer, ByVal RecNb As Integer, ByVal FieldBuffer As String, ByVal FldSize As Integer) As Integer

Declare Function GetValue Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal Table_Name As String, ByVal Data_Name As String, ByVal PosField As Integer, ByVal RecNb As Integer, ByVal FieldBuffer As String, ByVal Field_Size As Integer) As Integer


Declare Function SetValue Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal Table_Name As String, ByVal Data_Name As String, ByVal PosField As Integer, ByVal RecNb As Integer, ByVal FieldBuffer As String, ByVal Field_Size As Integer) As Integer

Declare Function TbGetValue Lib "ADS.DLL" (Table As PTable, ByVal PosField As Integer, ByVal RecNb As Integer, ByVal FieldBuffer As String, ByVal Field_Size As Integer) As Integer

Declare Function TbSetValue Lib "ADS.DLL" (Table As PTable, ByVal Data_Name As String, ByVal PosField As Integer, ByVal RecNb As Integer, ByVal FieldBuffer As String, ByVal Field_Size As Integer) As Integer

Declare Function TbGetField Lib "ADS.DLL" (Table As PTable, ByVal RecNb As Integer, ByVal FR As Integer, ByVal Buffer As String, ByVal BufSize As Integer) As Integer

Declare Function TbSetField Lib "ADS.DLL" (Table As PTable, ByVal RecNb As Integer, FR As Integer, ByVal Buffer As String, ByVal BufSize As Integer) As Integer

Declare Function TbGetRecord Lib "ADS.DLL" (Table As PTable, ByVal RecNb As Integer, ByVal Buffer As String, ByVal BufSize As Integer) As Integer

Declare Function TbSetRecord Lib "ADS.DLL" (Table As PTable, ByVal RecNb As Integer, ByVal Buffer As String, ByVal BufSize As Integer) As Integer

Declare Function TbAddRecord Lib "ADS.DLL" (Table As PTable, ByVal Buffer As String, ByVal BufSize As Integer, ByVal mode As Integer) As Integer

Declare Function TbInsRecord Lib "ADS.DLL" (Table As PTable, ByVal Buffer As String, ByVal BufSize As Integer, ByVal RecNb As Integer) As Integer

Declare Function TbDeleteRecord Lib "ADS.DLL" (Table As PTable, ByVal RecNb As Integer) As Integer

Declare Function TbGetFieldAddress Lib "ADS.DLL" (Table As PTable, ByVal RecNb As Integer, ByVal FR As Integer) As String

Declare Function TbGetRecordAddress Lib "ADS.DLL" (Table As PTable, ByVal RecNb As Integer) As String

Declare Function SearchRecord Lib "ADS.DLL" (hCursor As Integer, ByVal IdTable As String, ByVal idField As String, ByVal FieldBuffer As String, ByVal FldSize As Integer, ByVal RecNb As Integer) As Integer

Declare Function SearchKey Lib "ADS.DLL" (hCursor As Integer, ByVal IdTable As String, Nflds As Integer, ByVal RecBuffer As String, ByVal RecNb As Integer) As Integer

Declare Function TbSearchKey Lib "ADS.DLL" (Table As PTable, ByVal Nflds As Integer, ByVal RecBuffer As String, ByVal RecNb As Integer) As Integer

Declare Function TbSearchRef Lib "ADS.DLL" (Table As PTable, ByVal Nflds As Integer, RecBuffer As String) As Integer

Declare Function GetType Lib "ADS.DLL" (Table As PTable, ByVal idField As String, ByVal PosField As Integer, ByVal VrType As String) As Integer

Declare Function GetTypeSize Lib "ADS.DLL" (TheType As String) As Integer

Declare Function GetVarType Lib "ADS.DLL" (Table As PTable, ByVal idField As String, ByVal PosField As Integer, ByVal VrType As String) As Integer

Declare Function GetDataType Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String, ByVal idField As String, ByVal PosField As Integer, ByVal VrType As String) As Integer

Declare Function GetFieldPos Lib "ADS.DLL" (Table As PTable, ByVal idField As String) As Integer

Declare Function GetFldPos Lib "ADS.DLL" (Table As PTable, ByVal idField As String) As Integer

Declare Function GetFldName Lib "ADS.DLL" (Table As PTable, ByVal FR As Integer, ByVal fldName As String) As Integer

Declare Function GetNbRecs Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal IdTable As String) As Integer

Declare Function TbGetNbRecs Lib "ADS.DLL" (Table As PTable) As Integer

Declare Function Register_Runtime Lib "ADS.DLL" (ByVal USER As String, ByVal CODE As String, ByVal Distributor As String) As Integer

'*********************Base management *****************

Declare Function OpenMBase Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal MBaseFile As String, ByVal mode As Integer) As Integer

Declare Function CloseMBase Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal MBaseFile As String) As Integer

Declare Function SaveMBase Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal MBaseFile As String) As Integer

Declare Function SortMBase Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal MBaseFile As String) As Integer

Declare Function DeleteMBase Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal MBaseFile As String) As Integer

Declare Function SaveASMBase Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal MBase As String, ByVal ASMBaseFile As String) As Integer

Declare Function OpenMBaseTable Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal MBaseFile As String, ByVal TableFile As String) As Integer

Declare Function IsBaseModified Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal MBaseFile As String) As Integer

Declare Function SetBaseModified Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal MBaseFile As String, ByVal Modified As Integer) As Integer

Declare Function CloseBase Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal MBaseFile As String) As Integer

Declare Function SortBase Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal MBaseFile As String) As Integer

Declare Function OpenBase Lib "ADS.DLL" (ByVal hCursor As Integer, ByVal MBaseFile As String, ByVal mode As Integer) As Integer




