Cannot Create Database Using CheetahInc.pb

Just starting out? Need help? Post your questions and find answers here.
Jumbuck
User
User
Posts: 63
Joined: Mon Nov 03, 2008 8:30 am
Location: Australia

Cannot Create Database Using CheetahInc.pb

Post by Jumbuck »

The code below will not create the database Operator.dbf'
Compiles without error.
A search of drive fails to find any existence of this file.
Followed examples found but nothing seems to work. Must be missing
something somewhere.
Not sure about AnyErrors(). Could not find reference to anywhere but
have to test for errors somehow.

Code: Select all

;Place all INCLUDE files here
XIncludeFile "CheetahInc.pb"

;Place any Library files here
xdbUseDLL()
xdbActivate(#X1)

;Always Declare any Procedures here
Declare CreateOperatorDatabase()

;Test If database files exist If Not create
DBFName.s = "Operator.dbf"
dbHandle.l = xdbOpen(DBFName,"")
If AnyErrors() 
MessageRequester("MESSAGE","Operator.dbf does not exist..Create now?", #MB_ICONQUESTION)
xdbResetError()
CreateOperatorDatabase()
EndIf

;Actually wish to create many more databases here

;Lots of code here
End

Procedure CreateOperatorDatabase()
;Define the fields of the database 
;Change To Directory where Database will reside
DBFName.s = "Operator.dbf"
AllFields.s = "OPERATOR,C,35,0"
AllFields.s = AllFields.s + "ADDRESS,C,35,0"
AllFields.s = AllFields.s +  "POSTAL,C,35,0"
AllFields.s = AllFields.s +  "TOWNCITY,C,35,0"
AllFields.s = AllFields.s +  "POSTCODE,C,4,0"
AllFields.s = AllFields.s +  "PHONE,C,15,0"
AllFields.s = AllFields.s +  "FAX,C,15,0" 
AllFields.s = AllFields.s +  "ACN,C,10,0"
AllFields.s = AllFields.s +  "REGIST1,C,20,0"
AllFields.s = AllFields.s +  "REGIST2,C,20,0"
AllFields.s = AllFields.s +  "FEEDLOT,C,10,0"
AllFields.s = AllFields.s +  "ABN,C,15,0"
AllFields.s = AllFields.s +  "GSTRATE,C,5,0"

;Create the database
xdbCreate(DBFName,AllFields)
;Check For error creating the database
If AnyErrors()
  MessageRequester("ERROR","Unable to create database file Operator.dbf", 0)
Goto Exit1:
EndIf
dbHandle = xdbOpen(DBFName,"")
If AnyErrors()
  MessageRequester("ERROR","Unable to open database file Operator.dbf", 0)
EndIf
;Close the Database
xdbClose(dbHandle)
Exit1:
xdbResetError()
EndProcedure

;***************************************************************************
Jumbuck
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Post by blueb »

I think you didn't use the proper syntax for creating fields (see code)
PS - You do NOT need to activate the code... no passwords required.

Code: Select all

; *********************************************************************
; 
; Purpose: Demo code showing how to create a database and index. Also
;          shows how to open and close the database and index.

; *********************************************************************

;Use the Cheetah Include file
XIncludeFile "Cheetah2.pbi"

; Use Cheetah library
  xdbUseDLL()
 
;Define the names of the database & index
    DBFname.s = "Operator.dbf"
    IDXname.s = "Operator.idx"

;Create the database
   
    AllFields.s = "OPERATOR,C,35,0;" 
    AllFields.s = AllFields.s + "ADDRESS,C,35,0;"          ;<<<<<< Notice the semicolons required between fields
    AllFields.s = AllFields.s +  "POSTAL,C,35,0;" 
    AllFields.s = AllFields.s +  "TOWNCITY,C,35,0;" 
    AllFields.s = AllFields.s +  "POSTCODE,C,4,0;" 
    AllFields.s = AllFields.s +  "PHONE,C,15,0;" 
    AllFields.s = AllFields.s +  "FAX,C,15,0;" 
    AllFields.s = AllFields.s +  "ACN,C,10,0;" 
    AllFields.s = AllFields.s +  "REGIST1,C,20,0;" 
    AllFields.s = AllFields.s +  "REGIST2,C,20,0;" 
    AllFields.s = AllFields.s +  "FEEDLOT,C,10,0;" 
    AllFields.s = AllFields.s +  "ABN,C,15,0;" 
    AllFields.s = AllFields.s +  "GSTRATE,C,5,0" 
    
    xdbCreate(DBFName, AllFields)
 
;Open the database (database must be open prior To creating index)
    dbHandle.l = xdbOpen(DBFName, "") ; no encryption = ""
    AnyErrors() 

;Create the index (database must be open)
   IndexExpr.s = "UPPER(OPERATOR)"   ;index is not case sensitive
   Duplicates.l = #XDBTRUE         ;allow duplicate customer ID's
    
   xdbCreateIndex(IDXName, dbHandle, IndexExpr, Duplicates)

;Open the index
   idxHandle.l = xdbOpenIndex(IDXname, dbHandle)
 
   msg.s = "DBFname: " + DBFname + Chr(10) + "dbHandle:" +  Str(dbHandle) + Chr(10) + Chr(10) + "IDXname: " + IDXname + Chr(10) + "idxHandle:" + Str(idxHandle)
   MessageRequester("Create DBF", msg, 0)

;Close the database And related index
 xdbClose(dbHandle)                                 
  
;Close any open DLL's  
 xdbFreeDLL()
End
I've included a sample for you to test. Notice that I'm using an updated include file, but yours should work, but I'll post it for other users.

--blueb
Last edited by blueb on Wed Jan 28, 2009 4:10 pm, edited 1 time in total.
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Post by blueb »

Here's the latest PBI file for Cheatah.DLL

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-------------------------------------------------------------------
HTH,
--blueb
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Jumbuck
User
User
Posts: 63
Joined: Mon Nov 03, 2008 8:30 am
Location: Australia

Post by Jumbuck »

blueb,
Edited my code as suggested with semicolon but no good.
Copied your Cheetah2.pbi file into PB working directory and tried again.
Still no good.
Then tried your example and Debug shows below;-
DBFName: Operator.dbf
dBHandle: 0
IdxName: Operator.idx
dbHandle: 0
However neither the .dbf or .idx file appears to be written to disk.
No errors reported.
What else could be wrong?.
Jumbuck
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

if GetLasterror_() after xdbUseDLL() says 126 its a missing dll file.

Code: Select all

  xdbUseDLL() 
  Debug GetLastError_()
Jumbuck
User
User
Posts: 63
Joined: Mon Nov 03, 2008 8:30 am
Location: Australia

Post by Jumbuck »

ABBKlaus,
Thanks. Error returned is 126.
But what does this mean. The Cheetah2.pbi file is present.
Jumbuck
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

sorry for my ignorance and maybe Off-Topic, but:

What ist the advantage of Cheetah in comparison with SQLite?

Thx in advance & Greetings ... Kiffi
Hygge
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

> What ist the advantage of Cheetah in comparison with SQLite?
Doesn't require learning of SQL :wink:

@Jumbuck
Put the cheetah.dll in the directory of your program
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

ts-soft wrote:Doesn't require learning of SQL :wink:
ah, i see :)

Greetings ... Kiffi
Hygge
harkon
Enthusiast
Enthusiast
Posts: 217
Joined: Wed Nov 23, 2005 5:48 pm

Post by harkon »

Jumbuck wrote:ABBKlaus,
Thanks. Error returned is 126.
But what does this mean. The Cheetah2.pbi file is present.
Jumbuck
It means you are missing the .dll.

From the cheetah docs ;
ReadMe.txt

***** IMPORTANT *****

The Cheetah DLL (cheetah2.dll) must be located in a path where your
application can locate it. This is a pure 100% Windows DLL (not an
ActiveX DLL) so there are no Registry entries that can define where
the DLL resides.

Option 1: Copy the DLL to the directory your application resides in
and in your code change to that directory. You can use the xdbAppPath
function to accomplish this. (This is the preferred Option)

Option 2: Copy the DLL to the Windows\System folder. That folder
should be visible to your application so there should be no problems
accessing the functions.
Also I forgot, make sure you either set the compiler to create temporary executable in the source dir, or make sure the xdbAppPath is properly set.
Missed it by that much!!
HK
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

would be a good idea to inform the user that the dll is missing.

(I am already doing this in the PureDymo wrapper)

Code: Select all

Procedure.s IPF_GetLastError()
  err=GetLastError_()
  buffer.l=0
  ferr=FormatMessage_(#FORMAT_MESSAGE_ALLOCATE_BUFFER|#FORMAT_MESSAGE_FROM_SYSTEM,0,err,GetUserDefaultLangID_(),@buffer,0,0)
  If buffer<>0
    errormsg$=PeekS(buffer)
    LocalFree_(buffer)
    errormsg$=RemoveString(errormsg$,Chr(13)+Chr(10))
    ProcedureReturn errormsg$
  EndIf
EndProcedure

Procedure xdbUseDLL()
  xdbhDLL = OpenLibrary(#PB_Any, "CHEETAH2.DLL")
  If Not xdbhDLL
    MessageRequester(*MSGText.s,IPF_GetLastError(),#MB_ICONWARNING) ; *MSGText=0 If this parameter is NULL, the default title Error is used.
  EndIf
EndProcedure

xdbUseDLL()
Jumbuck
User
User
Posts: 63
Joined: Mon Nov 03, 2008 8:30 am
Location: Australia

Post by Jumbuck »

Thanks ABBKlaus & Others who helped,
The Cheetah2.dll was not missing but obviously in the wrong place.
Moved a copy into the PB library folder. However it may be that your
xdbhDLL = OpenLibrary(#PB_Any, "CHEETAH2.DLL") found it anyway.
Transferred your code to my program. Got an error Line 63:Procedure
is already declared. (Could be from Include file).
Line 63 = Procedure xdbUseDLL()
Went back and changed code as below.
Now have required Operator.dbf file which according to header appears
to be correct. Will now move on and create other databases.
Debug GetLastError_() now returns 0
Thanks again.

Code: Select all

;Place all INCLUDE files here
XIncludeFile "Cheetah2.pbi"

Procedure.s IPF_GetLastError()
  err=GetLastError_()
  buffer.l=0
  ferr=FormatMessage_(#FORMAT_MESSAGE_ALLOCATE_BUFFER|#FORMAT_MESSAGE_FROM_SYSTEM,0,err,GetUserDefaultLangID_(),@buffer,0,0)
  If buffer<>0
    errormsg$=PeekS(buffer)
    LocalFree_(buffer)
    errormsg$=RemoveString(errormsg$,Chr(13)+Chr(10))
    ProcedureReturn errormsg$
 EndIf
EndProcedure

;Procedure xdbUseDLL()
  xdbhDLL = OpenLibrary(#PB_Any, "CHEETAH2.DLL")
  If Not xdbhDLL
    MessageRequester(*MSGText.s,IPF_GetLastError(),#MB_ICONWARNING) ; *MSGText=0 If this parameter is NULL, the default title Error is used.
  EndIf
;EndProcedure 

;xdbUseDLL() 
;Debug GetLastError_() 
Jumbuck
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

"The Cheetah2.dll was not missing but obviously in the wrong place."
If a dll doesn't appear to be working, just preface it with the full path and it will be okay.
Moved a copy into the PB library folder.
I'd suggest not to put foreign DLL's into the PB library directory. That is for PB format libraries and PB format USER created libraries. Might lead to confusion later on.

Make a resources directory (most of us do) that contain image, help, DLL's etc and then create generic include files to reference them.
However it may be that your xdbhDLL = OpenLibrary(#PB_Any, "CHEETAH2.DLL") found it anyway.

For Instance, make a set of directories to sort out your future works, something like this:

C:\My Development Dirs\Projects
C:\My Development Dirs\Images\
C:\My Development Dirs\Help Files\
C:\My Development Dirs\DLL's\
C:\My Development Dirs\Miscellaneous\
C:\My Development Dirs\Forms\

For your Cheetah development:

C:\My Development Dirs\Projects\Cheetah Database\
C:\My Development Dirs\Projects\Cheetah Database\DLL\
C:\My Development Dirs\Projects\Cheetah Database\Forms\
C:\My Development Dirs\Projects\Cheetah Database\Documents\
C:\My Development Dirs\Projects\Cheetah Database\Other\
C:\My Development Dirs\Projects\Cheetah Database\Images\

When you create your project, make a copy of your needed Cheetah dll's in the local cheetah dll directory (keep the originals safe somewhere just in case) and reference it locally thus:

OpenLibrary(#PB_Any, "DLL\CHEETAH2.DLL")

PB will expand this path to read:

C:\My Development Dirs\Projects\Cheetah Database\DLL\CHEETAH2.DLL
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
pablov
User
User
Posts: 19
Joined: Mon Apr 06, 2009 11:55 am

Re: Cannot Create Database Using CheetahInc.pb

Post by pablov »

Greetings.
How to read MEMO field, using cheetah2.dll
Or other tools are necessary?
Thanks
Post Reply