wrapper - dll translation

Just starting out? Need help? Post your questions and find answers here.
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

Re: wrapper - dll translation

Post by t57042 »

Another problem, when calling this function I get: number expected instead of string.

Code: Select all

;========================<[ Set Process Mods ]>========================
;Declare Sub      sluSetProcessMods lib "SQLiteningU.Dll" alias "sluSetProcessMods" ( _
 ;                                byval ModChars As Long)
 ;   ModChars is a pointer to a null-terminated string. 
 Prototype  sluSetProcessMods(ModChars.p-ascii)
Richard
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: wrapper - dll translation

Post by Danilo »

t57042 wrote:Another problem, when calling this function I get: number expected instead of string.

Code: Select all

;========================<[ Set Process Mods ]>========================
;Declare Sub      sluSetProcessMods lib "SQLiteningU.Dll" alias "sluSetProcessMods" ( _
 ;                                byval ModChars As Long)
 ;   ModChars is a pointer to a null-terminated string. 
 Prototype  sluSetProcessMods(ModChars.p-ascii)
Richard
Works here.

Code: Select all

Import "SQLiteningU.lib"
    sluF(ColumNumber.l, *FieldValue, *SizeOfField, SetNumber.l = 0)
    sluGetRow(SetNumber.l = 0, ModChars.p-ascii = 0)
    sluOpen(FileName.p-ascii = 0 , ModChars.p-ascii = 0)
    sluSel(Statement.p-ascii, SetNumber.l = 0, ModChars.p-ascii = 0)
    
    sluGetColumnName(colNumber.l, *colName.ascii, *SizeOfColumnName.Long, SetNumber.l)
    sluGetTableColumnNames(TableName.p-ascii, *colName.ascii, *SizeOfColumnName.Long)
    sluGetError(*buffer.Ascii, *bufferLen.Long)
    
    ;========================<[ Set Process Mods ]>========================
    ;Declare Sub      sluSetProcessMods lib "SQLiteningU.Dll" alias "sluSetProcessMods" ( _
    ;                                byval ModChars As Long)
    ;   ModChars is a pointer to a null-terminated string.
    sluSetProcessMods(ModChars.p-ascii)
EndImport

Import "SQLitening.lib"
    slGetColumnCount(SetNumber.l = 0)
EndImport

Procedure.s slGetError()
    Protected err$
    Protected len.l = 1024
    Protected buffer.i = AllocateMemory(len)
    
    sluGetError(buffer,@len)
    If len <> -1
        err$ = PeekS(buffer,-1,#PB_Ascii)
    EndIf
    
    FreeMemory(buffer)
    ProcedureReturn err$
EndProcedure


err = sluOpen (GetPathPart(ProgramFilename())+"sample.db3")
If Not err
    Debug sluSetProcessMods("")
    Debug slGetError()
    
    err = sluSel("Select * from Parts where rowid < 11") 
    If Not err
        
        Debug "ColumnCount: "+slGetColumnCount()
        
        Debug "sluGetRow:"
        While sluGetRow()
            
            Rec$ = ""
            For i = 1 To 4
                buffer$ = Space(100)
                len = Len(buffer$)
                sluF(i, @buffer$, @len)
                Rec$ + PeekS(@buffer$,len,#PB_Ascii) + " - "
            Next
            Debug rec$
        Wend
        Debug "----------"
        
        Debug "sluGetColumnName:"
            len = 10000
            buffer.i = AllocateMemory(len)
            sluGetColumnName(1, buffer, @len, 0)
            If len = -1
                Debug slGetError()
            Else
                s$ = PeekS(buffer,-1,#PB_Ascii)
                Debug s$
            EndIf
            FreeMemory(buffer)
        Debug "----------"

        Debug "sluGetTableColumnNames:"
            len = 10000
            buffer.i = AllocateMemory(len)
            sluGetTableColumnNames("Parts", buffer, @len)
            If len = -1
                Debug slGetError()
            Else
                start = buffer
                name$ = ""
                Repeat
                    s$ = PeekS(start,-1,#PB_Ascii)
                    start + Len(s$) + 1
                    If s$ <> ""
                        Debug s$
                        name$ + s$ + Chr(10)
                    EndIf
                Until s$ = ""
                MessageRequester("Column names for table 'Parts'",name$)
            EndIf
        FreeMemory(buffer)
        Debug "----------"
        
        
        
    Else
        Debug "Error with sluSel(): "+Str(err)
    EndIf
Else
    Debug "can't open sample.db3 - Error code: "+Str(err)
EndIf
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

Re: wrapper - dll translation

Post by t57042 »

I am not working wih the.lib file, but that can not make the difference, can it?
I attach the include file as I have it sofar and the calling program: always get the error.
Could you test it?

Many thanks

Richard

Code: Select all

;SQLiteningPB.inc

;==========================================================================
; Generated with PureDLLHelper, Copyright ©2012 by Thomas <ts-soft> Schulz
;************************************************************************
;Functions from SQliteningU.dll
;************************************************************************

;===========================<[ Field Get ]>============================
;Declare Sub      sluF lib "SQLiteningU.Dll" alias "sluF" ( _
                                ; byval ColumnNumber As Long, _
                                ; byval FieldValue As Long, _
                                ; byref SizeOfFieldValue As Long, _
                                ; byval SetNumber As Long)

;   FieldValue is a pointer to the memory which will receive the field value.
;              A Null (hex ;00') will be added to end.
;   SizeOfFieldValue is both passed and returned. Pass the size of FieldValue.
;                    It must be at least the size of the returning field value + 1.
;                    The actual length of the returing field value is returned.
;                    If the passed size is too small then error -13 will be raised
;                    and the returning length will be set to -1.
Prototype  sluF(ColumNumber.l, *FieldValue, *SizeOfField, SetNumber.l = 0)
;==========================================================================

;============================<[ Get Row ]>=============================
;Declare Function sluGetRow lib "SQLiteningU.Dll" alias "sluGetRow" ( _
                                 ;byval SetNumber As Long, _
                                ; byval ModChars As Long) As Long
;   ModChars is a pointer to a null-terminated string. If not needed you
;            may pass a zero.
Prototype  sluGetRow(SetNumber.l = 0, ModChars.p-ascii = 0)
;==========================================================================

;==============================<[ Open ]>==============================
;Declare Function sluOpen lib "SQLiteningU.Dll" alias "sluOpen" ( _
                                ; byval FileName As Long, _
                                ; byval ModChars As Long) As Long
;   FileName is a pointer to a null-terminated string. If not needed you
;            may pass a zero.
;   ModChars is a pointer to a null-terminated string. If not needed you
;            may pass a zero.
Prototype  sluOpen(FileName.p-ascii = 0 , ModChars.p-ascii = 0)
;==========================================================================

;;;==============================<[ Sel ]>===============================
;Declare Function sluSel lib "SQLiteningU.Dll" alias "sluSel" ( _
                                ; byval Statement As Long, _
                                ; byval SetNumber As Long, _
                                ; byval ModChars As Long) As Long
;   Statement is a pointer to a null-terminated string.
;   ModChars is a pointer to a null-terminated string. If not needed you
;            may pass a zero.
Prototype  sluSel(Statement.p-ascii, SetNumber.l = 0, ModChars.p-ascii = 0)
;==========================================================================

;'==============================<[ Exe ]>===============================
;Declare Function sluExe lib "SQLiteningU.Dll" alias "sluExe" (_
 ;                                byval Statement As Long, _
 ;                                byval ModChars As Long) As Long
;   Statement is a pointer to a null-terminated string.
;   ModChars is a pointer to a null-terminated string. If not needed you
;            may pass a zero.
Prototype  sluExe(Statement.p-ascii,  ModChars.p-ascii = 0)
;==========================================================================

;============================<[ Sel Str ]>=============================
;Declare Sub sluSelStr lib "SQLiteningU.Dll" alias "sluSelStr" ( _
 ;                                byval Statement As Long, _
  ;                               byval ModChars As Long, _
   ;                              byval FieldsAndRows As Long, _
    ;                             byref SizeOfFieldsAndRows As Long)
;   Statement is a pointer to a null-terminated string.
;   ModChars is a pointer to a null-terminated string. If not needed you
;            may pass a zero.
;   FieldsAndRows is a pointer to the memory which will receive the fields
;                 and rows. The fields and rows are returned as a $VT:$BS
;                 delimited text string.
;   SizeOfFieldsAndRows is both passed and returned. Pass the size of
;                       FieldsAndRows. It must be at least the size of
;                       the returning fields and rows. The actual length
;                       of the returing fields and rows is returned.
;                       If the passed size is too small then the returning
;                       length will be set to -1.
    Prototype  sluSelStr(Statement.p-ascii, ModChars.p-ascii , *FieldsAndRows.Ascii, *SizeOfFieldsAndRows.Long)
    ;==========================================================================
    
;=====================<[ Get Table Column Names ]>=====================
;Declare Sub      sluGetTableColumnNames lib "SQLiteningU.Dll" alias "sluGetTableColumnNames" ( _
 ;                                byval TableName As Long, _
  ;                               byval ColumnNames As Long, _
   ;                              byref SizeOfColumnNames As Long)
;   TableName is a pointer to a null-terminated string.
;   ColumnNames is a pointer to the memory which will receive the column
;               names. The names are returned as a delimited text string
;               which is $NUL seperated.
;   SizeOfColumnNames is both passed and returned. Pass the size of ColumnName.
;                     It must be at least the size of the returning column names.
;                     The actual length of the returing column names is returned.
;                     If the passed size is too small then the returning length
;                     will be set to -1.   
Prototype sluGetTableColumnNames(TableName.p-ascii, *colName.ascii, *SizeOfColumnName.Long)
;==========================================================================

;'===========================<[ Get Error ]>============================
;Declare Sub      sluGetError lib "SQLiteningU.Dll" alias "sluGetError" ( _
 ;                                byval Error As Long, _
  ;                               byref SizeOfError As Long)
;   Error is a pointer to the memory which will receive the field value.
;              A Null (hex '00') will be added to end.
;   SizeOfError is both passed and returned. Pass the size of Error.
;               It must be at least the size of the returning error + 1.
;               The actual length of the returing error is returned.
;               If the passed size is too small then the returning length
;               will be set to -1.
Prototype sluGetError(*buffer.Ascii, *bufferLen.Long)
;==========================================================================

;============================<[ Connect ]>=============================
;Declare Function sluConnect lib "SQLiteningU.Dll" alias "sluConnect" (_
 ;                                byval Server As Long, _
  ;                               byval Port As Long, _
   ;                              byval ModChars As Long, _
    ;                             byval OutData As Long, _
     ;                           byref SizeOfOutData As Long) As Long
;   Server is a pointer to a null-terminated string.
;   ModChars is a pointer to a null-terminated string. If not needed you
;            may pass a zero.
;   DataOut is a pointer to the returning out data. If not needed you
;           may pass a zero.
;   SizeOfOutData is both passed and returned. Pass the size of OutData.
;                 It must be at least the size of the returning out data.
;                 The actual length of the returing out data is returned.
;                 If the passed size is too small then the returning length will
;                 be set to -1.
    Prototype  sluConnect(Server.p-ascii=0, Port.l=0, modChars.p-ascii=0, *outData=0, *outDataLen.Long=0)
    ;==========================================================================
    
 ;========================<[ Set Process Mods ]>========================
;Declare Sub      sluSetProcessMods lib "SQLiteningU.Dll" alias "sluSetProcessMods" ( _
 ;                                byval ModChars As Long)
 ;   ModChars is a pointer to a null-terminated string. 
 Prototype  sluSetProcessMods(ModChars.p-ascii)
;=======================================================================  

 ;************************************************************************
;Functions from SQlitening.dll
;************************************************************************

;'========================<[ Get Column Count ]>========================
;Declare Function sluGetColumnCount lib "SQLitening.Dll" alias "slGetColumnCount" ( _
 ;                                byval SetNumber As Long) As Long
;   Calls SQLitening.Dll directly.
Prototype  slGetColumnCount(SetNumber.l = 0)
;==========================================================================
;=============================<[ Close ]>==============================
;Declare Sub      sluClose lib "SQLitening.Dll" alias "slClose"
;'   Calls SQLitening.Dll directly.
Prototype  slClose()
;========================================================================

;========================<[ Get Error Number ]>========================
;Declare Function sluGetErrorNumber lib "SQLitening.Dll" alias "slGetErrorNumber" () As Long
;   Calls SQLitening.Dll directly.
Prototype  slGetErrorNumber()
;========================================================================

Prototype  sluAttach(a, b, c)
Prototype  sluBuildBindDat(a, b, c, d, e)
Prototype  sluBuildInsertOrUpdate(a, b, c, d, e, f, g)
;Prototype  sluConnect(a, b, c, d, e)
Prototype  sluConvertDat(a, b, c, d, e)
Prototype  sluCopyDatabase(a, b, c)
;Prototype  sluExe(a, b)
Prototype  sluExeBind(a, b, c, d)
;Prototype  sluF(a, b, c, d)
Prototype  sluFN(a, b, c, d)
Prototype  sluFNX(a, b, c, d, e)
Prototype  sluFX(a, b, c, d, e)
Prototype  sluGetColumnName(a, b, c, d)
Prototype  sluGetColumnNumber(a, b)
Prototype  sluGetDatabaseAndFileNames(a, b)
;Prototype  sluGetError(a, b)
Prototype  sluGetFieldDataTypes(a, b, c)
Prototype  sluGetFile(a, b, c, d)
Prototype  sluGetHandle(a, b)
;Prototype  sluGetRow(a, b)
Prototype  sluGetStatus(a, b, c)
;Prototype  sluGetTableColumnNames(a, b, c)
Prototype  sluGetTableNames(a, b, c)
Prototype  sluIsColumnNameValid(a, b)
Prototype  sluIsDatabaseNameValid(a)
Prototype  sluIsTableNameValid(a)
;Prototype  sluOpen(a, b)
Prototype  sluPopDatabase(a)
Prototype  sluPopSet(a, b, c)
Prototype  sluPushDatabase(a)
Prototype  sluPushSet(a, b, c)
Prototype  sluPutFile(a, b, c, d)
Prototype  sluRunProc(a, b, c, d, e, f, g, h, i, j)
;Prototype  sluSel(a, b, c)
Prototype  sluSelBind(a, b, c, d, e)
;Prototype  sluSelStr(a, b, c, d)
;Prototype  sluSetProcessMods(a)
Prototype  sluSetRelNamedLocks(a, b, c, d, e)
Prototype  sulGetChangeCount(a)

Prototype  IRISDATE(a)
Prototype  slCloseSet(a)
Prototype  slDisconnect()
Prototype  slGetColumnName(a, b)
Prototype  slGetColumnNumber(a, b)
;Prototype  slGetErrorNumber()
Prototype  slGetInsertID()
Prototype  slGetUnusedSetNumber()
Prototype  slIsColumnNumberValid(a, b)
Prototype  slIsFieldNull(a, b)
Prototype  slIsOpen()
Prototype  slIsSetNumberValid(a)


Global sluAttach.sluAttach
Global sluBuildBindDat.sluBuildBindDat
Global sluBuildInsertOrUpdate.sluBuildInsertOrUpdate
Global sluConnect.sluConnect
Global sluConvertDat.sluConvertDat
Global sluCopyDatabase.sluCopyDatabase
Global sluExe.sluExe
Global sluExeBind.sluExeBind
Global sluF.sluF
Global sluFN.sluFN
Global sluFNX.sluFNX
Global sluFX.sluFX
Global sluGetColumnName.sluGetColumnName
Global sluGetColumnNumber.sluGetColumnNumber
Global sluGetDatabaseAndFileNames.sluGetDatabaseAndFileNames
Global sluGetError.sluGetError
Global sluGetFieldDataTypes.sluGetFieldDataTypes
Global sluGetFile.sluGetFile
Global sluGetHandle.sluGetHandle
Global sluGetRow.sluGetRow
Global sluGetStatus.sluGetStatus
Global sluGetTableColumnNames.sluGetTableColumnNames
Global sluGetTableNames.sluGetTableNames
Global sluIsColumnNameValid.sluIsColumnNameValid
Global sluIsDatabaseNameValid.sluIsDatabaseNameValid
Global sluIsTableNameValid.sluIsTableNameValid
Global sluOpen.sluOpen
Global sluPopDatabase.sluPopDatabase
Global sluPopSet.sluPopSet
Global sluPushDatabase.sluPushDatabase
Global sluPushSet.sluPushSet
Global sluPutFile.sluPutFile
Global sluRunProc.sluRunProc
Global sluSel.sluSel
Global sluSelBind.sluSelBind
Global sluSelStr.sluSelStr
Global sluSetProcessMods.sluSetProcessMods
Global sluSetRelNamedLocks.sluSetRelNamedLocks
Global sulGetChangeCount.sulGetChangeCount

Global IRISDATE.IRISDATE
Global slClose.slClose
Global slCloseSet.slCloseSet
Global slDisconnect.slDisconnect
Global slGetColumnCount.slGetColumnCount
Global slGetColumnName.slGetColumnName
Global slGetColumnNumber.slGetColumnNumber
Global slGetErrorNumber.slGetErrorNumber
Global slGetInsertID.slGetInsertID
Global slGetUnusedSetNumber.slGetUnusedSetNumber
Global slIsColumnNumberValid.slIsColumnNumberValid
Global slIsFieldNull.slIsFieldNull
Global slIsOpen.slIsOpen
Global slIsSetNumberValid.slIsSetNumberValid


Procedure.i SQLiteningU_LoadDLL()
  Protected hDLL.i

  hDLL = OpenLibrary(#PB_Any, "SQLiteningU.dll")
  If hDLL <> 0
    sluAttach = GetFunction(hDLL, "sluAttach")
    sluBuildBindDat = GetFunction(hDLL, "sluBuildBindDat")
    sluBuildInsertOrUpdate = GetFunction(hDLL, "sluBuildInsertOrUpdate")
    sluConnect = GetFunction(hDLL, "sluConnect")
    sluConvertDat = GetFunction(hDLL, "sluConvertDat")
    sluCopyDatabase = GetFunction(hDLL, "sluCopyDatabase")
    sluExe = GetFunction(hDLL, "sluExe")
    sluExeBind = GetFunction(hDLL, "sluExeBind")
    sluF = GetFunction(hDLL, "sluF")
    sluFN = GetFunction(hDLL, "sluFN")
    sluFNX = GetFunction(hDLL, "sluFNX")
    sluFX = GetFunction(hDLL, "sluFX")
    sluGetColumnName = GetFunction(hDLL, "sluGetColumnName")
    sluGetColumnNumber = GetFunction(hDLL, "sluGetColumnNumber")
    sluGetDatabaseAndFileNames = GetFunction(hDLL, "sluGetDatabaseAndFileNames")
    sluGetError = GetFunction(hDLL, "sluGetError")
    sluGetFieldDataTypes = GetFunction(hDLL, "sluGetFieldDataTypes")
    sluGetFile = GetFunction(hDLL, "sluGetFile")
    sluGetHandle = GetFunction(hDLL, "sluGetHandle")
    sluGetRow = GetFunction(hDLL, "sluGetRow")
    sluGetStatus = GetFunction(hDLL, "sluGetStatus")
    sluGetTableColumnNames = GetFunction(hDLL, "sluGetTableColumnNames")
    sluGetTableNames = GetFunction(hDLL, "sluGetTableNames")
    sluIsColumnNameValid = GetFunction(hDLL, "sluIsColumnNameValid")
    sluIsDatabaseNameValid = GetFunction(hDLL, "sluIsDatabaseNameValid")
    sluIsTableNameValid = GetFunction(hDLL, "sluIsTableNameValid")
    sluOpen = GetFunction(hDLL, "sluOpen")
    sluPopDatabase = GetFunction(hDLL, "sluPopDatabase")
    sluPopSet = GetFunction(hDLL, "sluPopSet")
    sluPushDatabase = GetFunction(hDLL, "sluPushDatabase")
    sluPushSet = GetFunction(hDLL, "sluPushSet")
    sluPutFile = GetFunction(hDLL, "sluPutFile")
    sluRunProc = GetFunction(hDLL, "sluRunProc")
    sluSel = GetFunction(hDLL, "sluSel")
    sluSelBind = GetFunction(hDLL, "sluSelBind")
    sluSelStr = GetFunction(hDLL, "sluSelStr")
    sluSetProcessMods = GetFunction(hDLL, "sluSetProcessMods")
    sluSetRelNamedLocks = GetFunction(hDLL, "sluSetRelNamedLocks")
    sulGetChangeCount = GetFunction(hDLL, "sulGetChangeCount")

    ProcedureReturn hDLL
  EndIf

  ProcedureReturn #False
EndProcedure

Procedure.i SQLitening_LoadDLL()
  Protected hDLL.i

  hDLL = OpenLibrary(#PB_Any, "SQLitening.dll")
  If hDLL <> 0
    IRISDATE = GetFunction(hDLL, "IRISDATE")
    slAttach = GetFunction(hDLL, "slAttach")
    slBuildBindDat = GetFunction(hDLL, "slBuildBindDat")
    slBuildInsertOrUpdate = GetFunction(hDLL, "slBuildInsertOrUpdate")
    slClose = GetFunction(hDLL, "slClose")
    slCloseSet = GetFunction(hDLL, "slCloseSet")
    slConnect = GetFunction(hDLL, "slConnect")
    slConvertDat = GetFunction(hDLL, "slConvertDat")
    slCopyDatabase = GetFunction(hDLL, "slCopyDatabase")
    slDisconnect = GetFunction(hDLL, "slDisconnect")
    slExe = GetFunction(hDLL, "slExe")
    slExeBind = GetFunction(hDLL, "slExeBind")
    slF = GetFunction(hDLL, "slF")
    slFN = GetFunction(hDLL, "slFN")
    slFNX = GetFunction(hDLL, "slFNX")
    slFX = GetFunction(hDLL, "slFX")
    slGetChangeCount = GetFunction(hDLL, "slGetChangeCount")
    slGetColumnCount = GetFunction(hDLL, "slGetColumnCount")
    slGetColumnName = GetFunction(hDLL, "slGetColumnName")
    slGetColumnNumber = GetFunction(hDLL, "slGetColumnNumber")
    slGetDatabaseAndFileNames = GetFunction(hDLL, "slGetDatabaseAndFileNames")
    slGetError = GetFunction(hDLL, "slGetError")
    slGetErrorNumber = GetFunction(hDLL, "slGetErrorNumber")
    slGetFieldDataTypes = GetFunction(hDLL, "slGetFieldDataTypes")
    slGetFile = GetFunction(hDLL, "slGetFile")
    slGetHandle = GetFunction(hDLL, "slGetHandle")
    slGetInsertID = GetFunction(hDLL, "slGetInsertID")
    slGetRow = GetFunction(hDLL, "slGetRow")
    slGetStatus = GetFunction(hDLL, "slGetStatus")
    slGetTableColumnNames = GetFunction(hDLL, "slGetTableColumnNames")
    slGetTableNames = GetFunction(hDLL, "slGetTableNames")
    slGetUnusedSetNumber = GetFunction(hDLL, "slGetUnusedSetNumber")
    slIsColumnNameValid = GetFunction(hDLL, "slIsColumnNameValid")
    slIsColumnNumberValid = GetFunction(hDLL, "slIsColumnNumberValid")
    slIsDatabaseNameValid = GetFunction(hDLL, "slIsDatabaseNameValid")
    slIsFieldNull = GetFunction(hDLL, "slIsFieldNull")
    slIsOpen = GetFunction(hDLL, "slIsOpen")
    slIsSetNumberValid = GetFunction(hDLL, "slIsSetNumberValid")
    slIsTableNameValid = GetFunction(hDLL, "slIsTableNameValid")
    slOpen = GetFunction(hDLL, "slOpen")
    slPopDatabase = GetFunction(hDLL, "slPopDatabase")
    slPopSet = GetFunction(hDLL, "slPopSet")
    slPushDatabase = GetFunction(hDLL, "slPushDatabase")
    slPushSet = GetFunction(hDLL, "slPushSet")
    slPutFile = GetFunction(hDLL, "slPutFile")
    slRunProc = GetFunction(hDLL, "slRunProc")
    slSel = GetFunction(hDLL, "slSel")
    slSelAry = GetFunction(hDLL, "slSelAry")
    slSelBind = GetFunction(hDLL, "slSelBind")
    slSelStr = GetFunction(hDLL, "slSelStr")
    slSetProcessMods = GetFunction(hDLL, "slSetProcessMods")
    slSetRelNamedLocks = GetFunction(hDLL, "slSetRelNamedLocks")

    ProcedureReturn hDLL
  EndIf

  ProcedureReturn #False
EndProcedure

Procedure.s slGetError()
        Protected err$
        Protected len.l = 1024
        Protected buffer.i = AllocateMemory(len)
       
        sluGetError(buffer,@len)
        If len <> -1
            err$ = PeekS(buffer,-1,#PB_Ascii)
        EndIf
       
        FreeMemory(buffer)
        ProcedureReturn err$
      EndProcedure
      ;-------------------------------------------

Code: Select all

;sqliteexB.pb
XIncludeFile "SQLiteningPB.inc"
dll = SQLiteningU_LoadDLL()
dll2 = SQLitening_LoadDLL()
    If dll And dll2
      sluconnect("192.168.1.103",0,"E1")
        err = sluOpen ("pb\sample.db3")   ; laptop & desktop
        If Not err
          Debug sluSetProcessMods("")
           
          err = sluSel("Select * from Parts where rowid < 11 order by price",0,"e2")
        
            If Not err
                NumFlds = slGetColumnCount()

                While sluGetRow()
                   
                  Rec$ = ""
                    For i=1 To NumFlds 
                        buffer$ = Space(100)
                        len = Len(buffer$)
                        sluF(i, @buffer$, @len)
                        Rec$ + PeekS(@buffer$,len,#PB_Ascii) + " - "
                    Next
                    Debug rec$
                 Wend                                
            Else
                Debug slGetError()
            EndIf
            Debug "----------------------------------------------------------"  
            
            st$="create table if not exists test (field1,field2)"
            err=sluExe(st$)
            If Not err
              Debug "table created"
            Else
                Debug slGetError()
              EndIf 
            Debug "----------------------------------------------------------"  
             
            leng.l = 10000
            buffer.i = AllocateMemory(leng)
            sluSelStr("Select * from Parts where rowid <1","CQ124.92" , buffer, @leng)    ; returns only col names
            If leng = -1
              Debug "buffer too small"
            Else
              s$ = PeekS(buffer,-1,#PB_Ascii)
            EndIf
            FreeMemory(buffer)
            
            Debug s$
            s$=""
            Debug "----------------------------------------------------------"  
            len = 10000
            buffer.i = AllocateMemory(len)
            sluGetTableColumnNames("Parts", buffer, @len)
            If len = -1
              Debug slGetError()
              Debug Str(slGetErrorNumber())
            Else
               start = buffer
               Repeat
                  s$ = PeekS(start,-1,#PB_Ascii)
                  start + Len(s$) + 1
                  If s$ <> ""
                     Debug s$                   
                  EndIf
               Until s$ = ""              
            EndIf
            FreeMemory(buffer)
            Debug "-----------------------------------------------------------"
 ;----------------------------------------------------------------------------------
        Else
            Debug "can't open sample.db3 - Error code: "+Str(err)
        EndIf
        slclose()            
        CloseLibrary(dll)
        CloseLibrary(dll2)
        End
      Else
        Debug "cannot open DLL"
      EndIf
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: wrapper - dll translation

Post by Danilo »

Looks like a stack corruption. I don't have time to search the bug.

Works if compiled in ASCII mode, random crash in UNICODE mode (p-ascii convert?). Crash also with Purifier.

EDIT: Works in UNICODE mode if you change: "err=sluExe(st$)" to "err=sluExe(st$,"")"
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

Re: wrapper - dll translation

Post by t57042 »

How do I compile in ASCII mode?
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: wrapper - dll translation

Post by Danilo »

t57042 wrote:How do I compile in ASCII mode?
See compiler options.


Anyway, it's a bug: Crash with p-ascii, p-unicode, p-utf8 + default arg=0
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

Re: wrapper - dll translation

Post by t57042 »

I don' t see an option 'compile in ASCI mode' under compiler options.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: wrapper - dll translation

Post by Danilo »

t57042 wrote:I don' t see an option 'compile in ASCI mode' under compiler options.
[ ] Create unicode executable

Don't use this setting and it is compiled as ASCII. Use it and it is compiled in UNICODE mode.
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

Re: wrapper - dll translation

Post by t57042 »

I don't use the unicode setting, and still get the error.
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

Re: wrapper - dll translation

Post by t57042 »

If I understand well, when using the .lib files instead of the DLL's it works?
The code you provided to create the .lib's runs but no .lib files are created.
The code is in the same directory as the DLL's.
Richard
You can also link the DLLs directly to your executable instead loading DLLs dynamically.

Run this code to create the import libs:
(requires the DLLs in same directory)
[X] Create temporary executable in the source directory
Check that the 3 .lib files are created.

Code: Select all

    dir$ = GetPathPart(ProgramFilename())
    RunProgram(#PB_Compiler_Home+"Compilers\POLIB.exe","SQLitening.dll /MACHINE:x86 /OUT:SQLitening.lib",dir$)
    RunProgram(#PB_Compiler_Home+"Compilers\POLIB.exe","SQLiteningS.dll /MACHINE:x86 /OUT:SQLiteningS.lib",dir$)
    RunProgram(#PB_Compiler_Home+"Compilers\POLIB.exe","SQLiteningU.dll /MACHINE:x86 /OUT:SQLiteningU.lib",dir$)
thanos
Enthusiast
Enthusiast
Posts: 423
Joined: Sat Jan 12, 2008 3:25 pm
Location: Greece
Contact:

Re: wrapper - dll translation

Post by thanos »

Hi Richard.
I know it is an old post but i just found it.
Are you still working on this project?
It might be very interesting.
Regards.

Thanos
» myPersonal Banker :: Because you do not need to have a master degree in economics in order to organize your finances!
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

Re: wrapper - dll translation

Post by t57042 »

no not working on it anymore. Now trying MariaDB ( = MySQL) but open source
Richard
thanos
Enthusiast
Enthusiast
Posts: 423
Joined: Sat Jan 12, 2008 3:25 pm
Location: Greece
Contact:

Re: wrapper - dll translation

Post by thanos »

I see.
I found your post when i was ready to start trying to write a wrapper for SQLitening server.
Do you have any improvements in your wrapper?
And based on your experience what is your opinion about its performance, stability, availability etc.
Regards.

Thanos
» myPersonal Banker :: Because you do not need to have a master degree in economics in order to organize your finances!
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

Re: wrapper - dll translation

Post by t57042 »

Hi thanos
I had to stop this because of serious health problems.
It s a Pity because sqlitening looks very promising.
If you manage to produce a wrapper i will give it a serious try.
Good luck
Richard
thanos
Enthusiast
Enthusiast
Posts: 423
Joined: Sat Jan 12, 2008 3:25 pm
Location: Greece
Contact:

Re: wrapper - dll translation

Post by thanos »

t57042 wrote:Hi thanos
I had to stop this because of serious health problems.
Sorry to hear that :cry:
It s a Pity because sqlitening looks very promising.
If you manage to produce a wrapper i will give it a serious try.
Good luck
Richard
I am on the release candidate stage of one project.
When the product will circulated I probably try to produce a wrapper.
Thank you.
Regards.

Thanos
» myPersonal Banker :: Because you do not need to have a master degree in economics in order to organize your finances!
Post Reply