Code: Select all
; Begin-----------------------------------------------------------------
;
; Cheetah - PureBASIC Wrapper
;
; Simply add this file to your program with the command:
; XIncludeFile "Cheetah2.pbi"
;
; Created by Bob Houle (blueb) & Stefan Schnell
;
; ----------------------------------------------------------------------
; Global variables----------------------------------------------------
Global xdbhDLL.l
; Insert your registration code here--------------------------------
; Cheetah database constants------------------------------------------
Enumeration
#XDBTRUE = 1
#XDBFALSE = 0
#MAX_INDEXES = 100
#MAX_FIELDS = 1000
#MAX_CONDITIONS = 50
#MAX_INDEXKEYS = 6
#MAX_CHARFIELD_SIZE = 256
#MAX_NUMFIELD_SIZE = 20
#ENCRYPT_NONE = 0
#ENCRYPT_RC4 = 1
#ENCRYPT_KEYEDXOR = 2
#ENCRYPT_SUPERSCRAMBLE = 3
#QUERY_AND = 1
#QUERY_OR = 2
#EQUAL_TO = 1
#NOT_EQUAL_TO = 2
#LESS_THAN = 3
#GREATER_THAN = 4
#LESS_THAN_EQUAL_TO = 5
#GREATER_THAN_EQUAL_TO = 6
#CONTAINS = 7
#BETWEEN = 8
#SUM = 9
#MINIMUM = 10
#MAXIMUM = 11
#AVERAGE = 12
#WILDCARD = 13
#SORT_ASCEND = 1
#SORT_DESCEND = 0
#XDBREADONLY = 0
#XDBWRITEONLY = 1
#XDBREADWRITE = 2
#XDBDENYREADWRITE = 1
#XDBDENYWRITE = 2
#XDBDENYREAD = 3
#XDBDENYNONE = 4
#XDBUNIQUE_CONTINUE = 0
#XDBUNIQUE_ERROR = 1
; Errors----------------------------------------------------------
#FILE_ACCESS_ERROR = 4000
#INVALID_DATE_FORMAT = 4001
#FILE_READ_ONLY = 4002
#FILE_WRITE_ONLY = 4003
#INVALID_FILENAME = 4004
#ENGINE_NOT_INITIALIZED = 5000
#FILE_NOT_FOUND = 5001
#TOO_MANY_FILES_OPEN = 5002
#INVALID_STRUCTURE = 5003
#FILE_NOT_OPEN = 5004
#RECORD_OUT_OF_RANGE = 5005
#FIELD_NOT_FOUND = 5006
#INVALID_FILE_HANDLE = 5007
#INVALID_FIELD_LENGTH = 5008
#DUPLICATE_ALIAS_NAME = 5009
#INVALID_ACCESSMODE = 5010
#INVALID_SHAREMODE = 5011
#RECORD_BUSY = 5012
#INCOMPATIBLE_MEMO_FIELDS = 5013
#RECORDSIZE_EXCEEDED = 5014
#INVALID_ENCRYPTIONKEY = 5015
#DATABASE_NOT_OPEN = 7000
#TOO_MANY_INDEXES_OPEN = 7002
#INVALID_KEY_EXPRESSION = 7003
#INDEX_NOT_OPEN = 7004
#INDEX_UNIQUE_KEYS_ONLY = 7005
#SEEK_NO_INDEX_SET = 7006
#INDEX_NOT_FOUND = 7007
#QUERY_NOT_GENERATED = 9000
#QUERY_INVALID_FIELDNAME = 9001
#QUERY_INVALID_COMPARISON = 9002
#QUERY_MISSING_DELIMITERS = 9003
#QUERY_MISSING_SEARCHSTRING = 9004
#QUERY_TOO_MANY_EXPRESSIONS = 9005
#QUERY_EXPECTED_NUMERIC_STRING = 9006
#QUERY_ERROR_GETRECORD = 9007
#QUERY_INVALID_HANDLE = 9008
#QUERY_INVALID_JOINPHRASE = 9009
#QUERY_NO_WILDCARD_FOUND = 9010
#QUERY_INVALID_PARENTHESIS = 9011
#DLL_EXPIRED = 99999
EndEnumeration
; Cheetah database functions------------------------------------------
; ------------------------------------------------------------------
Procedure.s xdbCToD(BASICdate.s)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "CTOD_Z", @BASICdate))
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbDToS(CheetahDate.s)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "DTOS_Z", @CheetahDate))
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbAddDate(StartDate.s, NumDays.l)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBADDDATE_Z", @StartDate, NumDays))
EndProcedure
; ------------------------------------------------------------------
Procedure xdbAddField(FieldInfo.s)
CallFunction(xdbhDLL, "XDBADDFIELD_Z", @FieldInfo)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbAddRecord(DBFhandle.l)
CallFunction(xdbhDLL, "XDBADDRECORD_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbAlias(DBFhandle.l)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBALIAS_Z", DBFhandle))
EndProcedure
; ------------------------------------------------------------------
Procedure xdbAppendRecord(DBFhandle.l)
CallFunction(xdbhDLL, "XDBAPPENDRECORD_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbAppPath()
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBAPPPATH_Z"))
EndProcedure
; ------------------------------------------------------------------
Procedure xdbAssignField(DBFhandle.l, FieldName.s, FieldNumber.l, FieldString.s)
CallFunction(xdbhDLL, "XDBASSIGNFIELD_Z", DBFhandle, @FieldName, FieldNumber, @FieldString)
EndProcedure
; Currency: 8byte float---------------------------------------------
;
; This function does not work with PureBASIC, because PureBASIC
; supports only 4byte floating point
;
; ------------------------------------------------------------------
;Procedure xdbAssignFieldCUR(DBFhandle.l, FieldName.s, FieldNumber.l, CurrencyValue.f)
; CallFunction(xdbhDLL, "XDBASSIGNFIELDCUR_Z", DBFhandle, @FieldName, FieldNumber, @CurrencyValue)
;EndProcedure
; Double: 8byte float-----------------------------------------------
;
; This function does not work with PureBASIC, because PureBASIC
; supports only 4byte floating point
;
; ------------------------------------------------------------------
;Procedure xdbAssignFieldDBL(DBFhandle.l, FieldName.s, FieldNumber.l, DoubleValue.f)
; CallFunction(xdbhDLL, "XDBASSIGNFIELDDBL_Z", DBFhandle, @FieldName, FieldNumber, @DoubleValue)
;EndProcedure
; Integer: From -32768 to +32767------------------------------------
Procedure xdbAssignFieldINT(DBFhandle.l, FieldName.s, FieldNumber.l, IntValue.w)
CallFunction(xdbhDLL, "XDBASSIGNFIELDINT_Z", DBFhandle, @FieldName, FieldNumber, IntValue)
EndProcedure
; Long: From -2147483648 to +2147483647-----------------------------
Procedure xdbAssignFieldLNG(DBFhandle.l, FieldName.s, FieldNumber.l, LongValue.l)
CallFunction(xdbhDLL, "XDBASSIGNFIELDLNG_Z", DBFhandle, @FieldName, FieldNumber, LongValue)
EndProcedure
; Single: 4byte float-----------------------------------------------
Procedure xdbAssignFieldSNG(DBFhandle.l, FieldName.s, FieldNumber.l, SingleValue.f)
CallFunction(xdbhDLL, "XDBASSIGNFIELDSNG_Z", DBFhandle, @FieldName, FieldNumber, @SingleValue)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbAssignMemo(DBFhandle.l, FieldName.s, FieldNumber.l, MemAddress.l, StringLength.l)
CallFunction(xdbhDLL, "XDBASSIGNMEMO_Z", DBFhandle, @FieldName, FieldNumber, MemAddress, StringLength)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbBOF(DBFhandle.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBBOF_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure _xdbClearBuffer(DBFhandle.l)
CallFunction(xdbhDLL, "XDBCLEARBUFFER_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbClose(DBFhandle.l)
CallFunction(xdbhDLL, "XDBCLOSE_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbCloseAllIndexes(DBFhandle.l)
CallFunction(xdbhDLL, "XDBCLOSEALLINDEXES_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbCloseIndex(DBFhandle.l, idxHandle.l)
CallFunction(xdbhDLL, "XDBCLOSEINDEX_Z", DBFhandle, idxHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbCreate(FileName.s, FieldArray.s)
CallFunction(xdbhDLL, "XDBCREATE_Z", @FileName, @FieldArray)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbCreateExtended(FileName.s, FieldArray.s, MemoBlockSize.l, Algorithm.l, EncryptionKey.s)
CallFunction(xdbhDLL, "XDBCREATEEXTENDED_Z", @FileName, @FieldArray, MemoBlockSize, Algorithm, @EncryptionKey)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbCreateFields(DBFname.s)
CallFunction(xdbhDLL, "XDBCREATEFIELDS_Z", @DBFname)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbCreateFieldsExtended(FileName.s, MemoBlockSize.l, Algorithm.l, EncryptionKey.s)
CallFunction(xdbhDLL, "XDBCREATEFIELDSEXTENDED_Z", @FileName, MemoBlockSize, Algorithm, @EncryptionKey)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbCreateIndex(IndexFileName.s, DBFhandle.l, IndexExpression.s, Duplicates.l)
CallFunction(xdbhDLL, "XDBCREATEINDEX_Z", @IndexFileName, DBFhandle, @IndexExpression, Duplicates)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbCreateQuery(DBFhandle.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBCREATEQUERY_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbDatabaseHandles(DBFileName.s, CheetahHandle.l, WindowsHandle.l)
CallFunction(xdbhDLL, "XDBDATABASEHANDLES_Z", @DBFileName, CheetahHandle, WindowsHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbDateToJulian(DateString.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBDATETOJULIAN_Z", @DateString)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbDaysApart(DateFrom.s, DateTo.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBDAYSAPART_Z", @DateFrom, @DateTo)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbDaysInMonth(Year.l, Month.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBDAYSINMONTH_Z", Year, Month)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbDebugMode(TrueFalse.l)
CallFunction(xdbhDLL, "XDBDEBUGMODE_Z", TrueFalse)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbDeleted(DBFhandle.l, RecordNumber.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBDELETED_Z", DBFhandle, RecordNumber)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbDeleteRecord(DBFhandle.l, RecordNumber.l)
CallFunction(xdbhDLL, "XDBDELETERECORD_Z", DBFhandle, RecordNumber)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbDestroyQuery(QueryHandle.l)
CallFunction(xdbhDLL, "XDBDESTROYQUERY_Z", QueryHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbEncryptionMethod(DBFhandle.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBENCRYPTIONMETHOD_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbEOF(DBFhandle.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBEOF_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbError()
ProcedureReturn CallFunction(xdbhDLL, "XDBERROR_Z")
EndProcedure
; ------------------------------------------------------------------
Procedure xdbFailedLockInfo(DBFhandle.l, Reason.s, Username.s, Workstation.s, LockDate.s, LockTime.s)
CallFunction(xdbhDLL, "XDBFAILEDLOCKINFO_Z", DBFhandle, @Reason, @Username, @Workstation, @LockDate, @LockTime)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbFieldCount(DBFhandle.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBFIELDCOUNT_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbFieldDecimals(DBFhandle.l, FieldNumber.l, FieldName.s, FieldType.s, FieldLength.l, FieldDecimals.l)
CallFunction(xdbhDLL, "XDBFIELDDECIMALS_Z", DBFhandle, FieldNumber, @FieldName, @FieldType, FieldLength, FieldDecimals)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbFieldInfo(DBFhandle.l, FieldNumber.l, FieldName.s, FieldType.s, FieldLength.l, FieldDecimals.l)
CallFunction(xdbhDLL, "XDBFIELDINFO_Z", DBFhandle, FieldNumber, @FieldName, @FieldType, FieldLength, FieldDecimals)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbFieldLength(DBFhandle.l, FieldNumber.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBFIELDLENGTH_Z", DBFhandle, FieldNumber)
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbFieldName(DBFhandle.l, FieldNumber.l)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBFIELDNAME_Z", DBFhandle, FieldNumber))
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbFieldNumber(DBFhandle.l, FieldName.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBFIELDNUMBER_Z", DBFhandle, @FieldName)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbFieldPadding(DBFhandle.l, TrueFalse.l)
CallFunction(xdbhDLL, "XDBFIELDPADDING_Z", DBFhandle, TrueFalse)
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbFieldType(DBFhandle.l, FieldNumber.l)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBFIELDTYPE_Z", DBFhandle, FieldNumber))
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbFieldValue(DBFhandle.l, FieldName.s, FieldNumber.l)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBFIELDVALUE_Z", DBFhandle, @FieldName, FieldNumber))
EndProcedure
; Currency: 8byte float---------------------------------------------
;
; This function does not work with PureBASIC, because PureBASIC
; supports only 4byte floating point
;
; ------------------------------------------------------------------
;Procedure.f xdbFieldValueCUR(DBFhandle.l, FieldName.s, FieldNumber.l)
; ProcedureReturn CallFunction(xdbhDLL, "XDBFIELDVALUECUR_Z", DBFhandle, @FieldName, FieldNumber)
;EndProcedure
; Double: 8byte float-----------------------------------------------
;
; This function does not work with PureBASIC, because PureBASIC
; supports only 4byte floating point
;
; ------------------------------------------------------------------
;Procedure.f xdbFieldValueDBL(DBFhandle.l, FieldName.s, FieldNumber.l)
; ProcedureReturn CallFunction(xdbhDLL, "XDBFIELDVALUEDBL_Z", DBFhandle, @FieldName, FieldNumber)
;EndProcedure
; Integer: From -32768 to +32767------------------------------------
Procedure.w xdbFieldValueINT(DBFhandle.l, FieldName.s, FieldNumber.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBFIELDVALUEINT_Z", DBFhandle, @FieldName, FieldNumber)
EndProcedure
; Long: From -2147483648 to +2147483647-----------------------------
Procedure.l xdbFieldValueLNG(DBFhandle.l, FieldName.s, FieldNumber.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBFIELDVALUELNG_Z", DBFhandle, @FieldName, FieldNumber)
EndProcedure
; Single: 4byte float-----------------------------------------------
Procedure.f xdbFieldValueSNG(DBFhandle.l, FieldName.s, FieldNumber.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBFIELDVALUESNG_Z", DBFhandle, @FieldName, FieldNumber)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbFlushDatabase(DBFhandle.l)
CallFunction(xdbhDLL, "XDBFLUSHDATABASE_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbGetRecord(DBFhandle.l, RecordNumber.l)
CallFunction(xdbhDLL, "XDBGETRECORD_Z", DBFhandle, RecordNumber)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbHtmlStripTag(QueryHandle.l, TrueFalse.l)
CallFunction(xdbhDLL, "XDBHTMLSTRIPTAG_Z", QueryHandle, TrueFalse)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbIndexHandles(IndexFileName.s, CheetahHandle.l, WindowsHandle.l)
CallFunction(xdbhDLL, "XDBINDEXHANDLES_Z", @IndexFileName, CheetahHandle, WindowsHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbIsEditLock(DBFhandle.l, RecordNumber.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBISEDITLOCK_Z", DBFhandle, RecordNumber)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbIsEncrypted(DBFhandle.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBISENCRYPTED_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbJulianToDate(JulianNumber.l)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBJULIANTODATE_Z", JulianNumber))
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbKeyCount(DBFhandle.l, idxHandle.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBKEYCOUNT_Z", DBFhandle, idxHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbKeyExpression(DBFhandle.l, idxHandle.l)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBKEYEXPRESSION_Z", DBFhandle, idxHandle))
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbKeyLength(DBFhandle.l, idxHandle.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBKEYLENGTH_Z", DBFhandle, idxHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbKeyPosition(idxHandle.l, KeyPosition.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBKEYPOSITION_Z", idxHandle, KeyPosition)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbKeyUnique(DBFhandle.l, idxHandle.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBKEYUNIQUE_Z", DBFhandle, idxHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbLastUpdated(DBFhandle.l, YearNr.l, MonthNr.l, DayNr.l)
CallFunction(xdbhDLL, "XDBLASTUPDATED_Z", YearNr, MonthNr, DayNr)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbMemoValueAddr(DBFhandle.l, FieldName.s, FieldCode.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBMEMOVALUEADDR_Z", DBFhandle, @FieldName, FieldCode)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbMemoValueLen(DBFhandle.l, FieldName.s, FieldCode.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBMEMOVALUELEN_Z", DBFhandle, @FieldName, FieldCode)
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbMKI(IntValue.w)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBMKI_Z", IntValue))
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbMKL(LongValue.l)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBMKL_Z", LongValue))
EndProcedure
; ------------------------------------------------------------------
Procedure xdbMoveFirst(DBFhandle.l, idxHandle.l)
CallFunction(xdbhDLL, "XDBMOVEFIRST_Z", DBFhandle, idxHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbMoveLast(DBFhandle.l, idxHandle.l)
CallFunction(xdbhDLL, "XDBMOVELAST_Z", DBFhandle, idxHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbMoveNext(DBFhandle.l, idxHandle.l)
CallFunction(xdbhDLL, "XDBMOVENEXT_Z", DBFhandle, idxHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbMovePrev(DBFhandle.l, idxHandle.l)
CallFunction(xdbhDLL, "XDBMOVEPREV_Z", DBFhandle, idxHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbMultiUser(TrueFalse.l, NumRetries.l, WaitTimes.l)
CallFunction(xdbhDLL, "XDBMULTIUSER_Z", TrueFalse, NumRetries, WaitTimes)
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbNameOfDay(DateCheck.s)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBNAMEOFDAY_Z", @DateCheck))
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbOpen(FileName.s, EncryptionKey.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBOPEN_Z", @FileName, @EncryptionKey)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbOpenEx(FileName.s, AccessMode.l, ShareMode.l, EncryptionKey.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBOPENEX_Z", @FileName, AccessMode, ShareMode, @EncryptionKey)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbOpenIndex(IndexFilename.s, DBFhandle.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBOPENINDEX_Z", @IndexFilename, DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbPack(DBFhandle.l)
CallFunction(xdbhDLL, "XDBPACK_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbPutRecord(DBFhandle.l, RecordNumber.l)
CallFunction(xdbhDLL, "XDBPUTRECORD_Z", DBFhandle, @RecordNumber)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbQueryAVG(QueryHandle.l, FieldName.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBQUERYAVG_Z", QueryHandle, @FieldName)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbQueryCondition(QueryHandle.l, JoinPhrases.l, FieldName.s, Equality.l, vParameter1.s, vParameter2.s)
CallFunction(xdbhDLL, "XDBQUERYCONDITION_Z", QueryHandle, JoinPhrases, @FieldName, Equality, @vParameter1, @vParameter2)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbQueryDistinct(QueryHandle.l, FieldName.s)
CallFunction(xdbhDLL, "XDBQUERYDISTINCT_Z", QueryHandle, @FieldName)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbQueryExecute(QueryHandle.l)
CallFunction(xdbhDLL, "XDBQUERYEXECUTE_Z", QueryHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbQueryIndex(QueryHandle.l)
CallFunction(xdbhDLL, "XDBQUERYINDEX_Z", QueryHandle)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbQueryMAX(QueryHandle.l, FieldName.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBQUERYMAX_Z", QueryHandle, @FieldName)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbQueryMIN(QueryHandle.l, FieldName.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBQUERYMIN_Z", QueryHandle, @FieldName)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbQuerySort(QueryHandle.l, FieldName.s, SortDirection.l)
CallFunction(xdbhDLL, "XDBQUERYSORT_Z", QueryHandle, @FieldName, SortDirection)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbQuerySUM(QueryHandle.l, FieldName.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBQUERYSUM_Z", QueryHandle, @FieldName)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbRecallRecord(DBFhandle.l, RecordNumber.l)
CallFunction(xdbhDLL, "XDBRECALLRECORD_Z", DBFhandle, RecordNumber)
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbRecordBuffer(DBFhandle.l)
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBRECORDBUFFER_Z", DBFhandle))
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbRecordCount(DBFhandle.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBRECORDCOUNT_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbRecordNumber(DBFhandle.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBRECORDNUMBER_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbRegisteredTo()
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBREGISTEREDTO_Z"))
EndProcedure
; ------------------------------------------------------------------
Procedure xdbReindex(DBFhandle.l, idxHandle.l, UniqueContinueOrError.l)
CallFunction(xdbhDLL, "XDBREINDEX_Z", DBFhandle, idxHandle, UniqueContinueOrError)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbReindexAll(DBFhandle.l, UniqueContinueOrError.l)
CallFunction(xdbhDLL, "XDBREINDEXALL_Z", DBFhandle, UniqueContinueOrError)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbRemoveEditLock(DBFhandle.l, Lock_Num.l)
CallFunction(xdbhDLL, "XDBREMOVEEDITLOCK_Z", DBFhandle, Lock_Num)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbRemoveExclusiveLock(DBFhandle.l, Lock_Num.l)
CallFunction(xdbhDLL, "XDBREMOVEEXCLUSIVELOCK_Z", DBFhandle, Lock_Num)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbResetError()
CallFunction(xdbhDLL, "XDBRESETERROR_Z")
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbSeek(DBFhandle.l, idxHandle.l, KeyToLookFor.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBSEEK_Z", DBFhandle, idxHandle, @KeyToLookFor)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbSeekNext(DBFhandle.l, idxHandle.l, KeyToLookFor.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBSEEKNEXT_Z", DBFhandle, idxHandle, @KeyToLookFor)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbSeekPartial(DBFhandle.l, idxHandle.l, PartialKeyToLookFor.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBSEEKPARTIAL_Z", DBFhandle, idxHandle, @PartialKeyToLookFor)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbSeekPartialNext(DBFhandle.l, idxHandle.l, PartialKeyToLookFor.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBSEEKPARTIALNEXT_Z", DBFhandle, idxHandle, @PartialKeyToLookFor)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbSetAlias(DBFhandle.l, NewAliasName.s)
CallFunction(xdbhDLL, "XDBSETALIAS_Z", DBFhandle, @NewAliasName)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbSetCallBack(hWnd.l)
CallFunction(xdbhDLL, "XDBSETCALLBACK_Z", hWnd)
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbSetEditLock(DBFhandle.l, RecordNumber.l)
ProcedureReturn CallFunction(xdbhDLL, "XDBSETEDITLOCK_Z", DBFhandle, RecordNumber)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbSetExclusiveLock(DBFhandle.l)
CallFunction(xdbhDLL, "XDBSETEXCLUSIVELOCK_Z", DBFhandle)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbSkipDeleted(DBFhandle.l, OnOff.l)
CallFunction(xdbhDLL, "XDBSKIPDELETED_Z", DBFhandle, OnOff)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbSpeedAppend(DBFhandle.l, OnOff.l)
CallFunction(xdbhDLL, "XDBSPEEDAPPEND_Z", DBFhandle, OnOff)
EndProcedure
; ------------------------------------------------------------------
Procedure xdbTempFileName()
ProcedureReturn PeekL(CallFunction(xdbhDLL, "XDBTEMPFILENAME_Z"))
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbTodaysDate()
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBTODAYSDATE_Z"))
EndProcedure
; ------------------------------------------------------------------
Procedure.l xdbValidDate(DateCheck.s)
ProcedureReturn CallFunction(xdbhDLL, "XDBVALIDDATE_Z", @DateCheck)
EndProcedure
; ------------------------------------------------------------------
Procedure.s xdbVersion()
ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBVERSION_Z"))
EndProcedure
; ------------------------------------------------------------------
Procedure xdbZap(DBFhandle.l)
CallFunction(xdbhDLL, "XDBZAP_Z", DBFhandle)
EndProcedure
; Procedure xdbClearBuffer------------------------------------------
;
; Procedure to correct Cheetah xdbClearBuffer bug
; Thanks to Bruce Brown
;
; ------------------------------------------------------------------
Procedure xdbClearBuffer(DBFhandle.l)
_xdbClearBuffer(DBFhandle)
For i = 1 To xdbFieldCount(DBFhandle)
Select xdbFieldType(DBFhandle, i)
Case "I" ; Integer
xdbAssignFieldINT(DBFhandle, "", i, 0)
Case "W" ; Long
xdbAssignFieldLNG(DBFhandle, "", i, 0)
Case "S" ; Single
xdbAssignFieldSNG(DBFhandle, "", i, 0)
;Case "X" ; Double, not supported by PureBASIC
; xdbAssignFieldDBL(DBFhandle, "", i, 0)
;Case "Y" ; Currency, not supported by PureBASIC
; xdbAssignFieldCUR(DBFhandle, "", i, 0)
EndSelect
Next
EndProcedure
; Procedure xdbUseDLL-------------------------------------------------
;
; Procedure to load CHEETAH2.DLL permanently
;
; --------------------------------------------------------------------
Procedure xdbUseDLL()
xdbhDLL = OpenLibrary(#PB_Any, "CHEETAH2.DLL")
EndProcedure
; Procedure xdbFreeDLL------------------------------------------------
;
; Procedure to unload CHEETAH2.DLL after xdbUseDLL
;
; --------------------------------------------------------------------
Procedure xdbFreeDLL()
CloseLibrary(xdbhDLL)
EndProcedure
; Procedure AnyErrors-------------------------------------------------
;
; Returns the error number
;
; --------------------------------------------------------------------
Procedure AnyErrors()
ErrorReturn = xdbError()
If ErrorReturn
Select ErrorReturn
; System errors-----------------------------------------------
Case #FILE_ACCESS_ERROR
ErrorAns.s = "FILE ACCESS ERROR"
Case #INVALID_DATE_FORMAT
ErrorAns.s = "INVALID DATE FORMAT"
Case #FILE_READ_ONLY
ErrorAns.s = "FILE READ ONLY"
Case #FILE_WRITE_ONLY
ErrorAns.s = "FILE WRITE ONLY"
Case #INVALID_FILENAME
ErrorAns.s = "INVALID FILENAME"
; Database errors---------------------------------------------
Case #ENGINE_NOT_INITIALIZED
ErrorAns.s = "ENGINE NOT INITIALIZED"
Case #FILE_NOT_FOUND
ErrorAns.s = "FILE NOT FOUND"
Case #TOO_MANY_FILES_OPEN
ErrorAns.s = "TOO MANY FILES OPEN"
Case #INVALID_STRUCTURE
ErrorAns.s = "INVALID STRUCTURE"
Case #FILE_NOT_OPEN
ErrorAns.s = "FILE NOT OPEN"
Case #RECORD_OUT_OF_RANGE
ErrorAns.s = "RECORD OUT OF RANGE"
Case #FIELD_NOT_FOUND
ErrorAns.s = "FIELD NOT FOUND"
Case #INVALID_FILE_HANDLE
ErrorAns.s = "INVALID FILE HANDLE"
Case #INVALID_FIELD_LENGTH
ErrorAns.s = "INVALID FIELD LENGTH"
Case #DUPLICATE_ALIAS_NAME
ErrorAns.s = "DUPLICATE ALIAS NAME"
Case #INVALID_ACCESSMODE
ErrorAns.s = "INVALID ACCESSMODE"
Case #INVALID_SHAREMODE
ErrorAns.s = "INVALID SHAREMODE"
Case #RECORD_BUSY
ErrorAns.s = "RECORD BUSY"
Case #INCOMPATIBLE_MEMO_FIELDS
ErrorAns.s = "INCOMPATIBLE MEMO FIELDS"
Case #RECORDSIZE_EXCEEDED
ErrorAns.s = "RECORDSIZE EXCEEDED"
Case #INVALID_ENCRYPTIONKEY
ErrorAns.s = "INVALID ENCRYPTIONKEY"
; Index errors------------------------------------------------
Case #DATABASE_NOT_OPEN
ErrorAns.s = "DATABASE NOT OPEN"
Case #TOO_MANY_INDEXES_OPEN
ErrorAns.s = "TOO MANY INDEXES OPEN"
Case #INVALID_KEY_EXPRESSION
ErrorAns.s = "INVALID KEY EXPRESSION"
Case #INDEX_NOT_OPEN
ErrorAns.s = "INDEX NOT OPEN"
Case #INDEX_UNIQUE_KEYS_ONLY
ErrorAns.s = "INDEX UNIQUE KEYS ONLY"
Case #SEEK_NO_INDEX_SET
ErrorAns.s = "SEEK NO INDEX_SET"
Case #INDEX_NOT_FOUND
ErrorAns.s = "INDEX NOT FOUND"
; Query errors------------------------------------------------
Case #QUERY_NOT_GENERATED
ErrorAns.s = "QUERY NOT GENERATED"
Case #QUERY_INVALID_FIELDNAME
ErrorAns.s = "QUERY INVALID FIELDNAME"
Case #QUERY_INVALID_COMPARISON
ErrorAns.s = "QUERY INVALID COMPARISON"
Case #QUERY_MISSING_DELIMITERS
ErrorAns.s = "QUERY MISSING DELIMITERS"
Case #QUERY_MISSING_SEARCHSTRING
ErrorAns.s = "QUERY MISSING SEARCHSTRING"
Case #QUERY_TOO_MANY_EXPRESSIONS
ErrorAns.s = "QUERY TOO MANY EXPRESSIONS"
Case #QUERY_EXPECTED_NUMERIC_STRING
ErrorAns.s = "QUERY EXPECTED NUMERIC STRING"
Case #QUERY_ERROR_GETRECORD
ErrorAns.s = "QUERY ERROR GETRECORD"
Case #QUERY_INVALID_HANDLE
ErrorAns.s = "QUERY INVALID HANDLE"
Case #QUERY_INVALID_JOINPHRASE
ErrorAns.s = "QUERY INVALID JOINPHRASE"
Case #QUERY_NO_WILDCARD_FOUND
ErrorAns.s = "QUERY NO WILDCARD FOUND"
Case #QUERY_INVALID_PARENTHESIS
ErrorAns.s = "QUERY INVALID PARENTHESIS"
; DLL errors--------------------------------------------------
Case #DLL_EXPIRED
ErrorAns.s = "DLL has expired (unregistered users)"
; Now not define errors---------------------------------------
Default
ErrorAns.s = "Cheetah DLL Error: " + Str(ErrorReturn) + Chr(13) + Chr(10) + "Look at Cheetah help file for the actual error list"
EndSelect
MessageRequester("Cheetah DBF", ErrorAns, #MB_OK | #MB_ICONERROR)
xdbResetError()
EndIf
EndProcedure
; End-------------------------------------------------------------------