I`m trying to write a library to access the sqlite3.dll.
So far I managed to get the version number:
CONST SQLITE3_DLL = "sqlite3.dll"
DECLARE dll_sqlite3_libversion_number AS "sqlite3_libversion_number" OF SQLITE3_DLL
DIM RESULT AS INTEGER
END DECLARE
FUNCTION sqlite3_libversion_number() AS INTEGER
dll_sqlite3_libversion_number
RESULT=dll_sqlite3_libversion_number.RESULT
END FUNCTION
` Shows the version of the SQLITE DBMS as message.
SUB ShowDbVersion()
ShowMessage "SQLite Version: "+STR$(sqlite3_libversion_number())
END SUB
But trying to open an existing database fails and crashes the whole app:
`int sqlite3_open
DECLARE dll_sqlite3_open AS "sqlite3_open" OF SQLITE3_DLL
`const char *filename, /* Database filename (UTF-8) */
DIM filename AS STRING
`sqlite3 **ppDb /* OUT: SQLite db handle */
DIM ppDb AS LONG BYADDRESS
` Result
DIM RESULT AS INTEGER
END DECLARE
FUNCTION sqlite3_open(filename AS STRING, ppDb AS LONG BYADDRESS) AS INTEGER
dll_sqlite3_open.filename=filename
dll_sqlite3_open.ppDb=ppDb
dll_sqlite3_open
RESULT=dll_sqlite3_open.RESULT
END FUNCTION
DIM ppDB AS LONG ` global db handler
` Should open a SQLITE database but crashes the app.
SUB DbOpen()
ShowMessage "SQLite Open: "+STR$(sqlite3_open("c:midgard_import.db3", ppDB))
END SUB
I doubt that I set the parameter types for the dll call correctly.
So how should I declare them?
SQLite library
SQLite library
Maybe I didn`t make my question clear enough ...
How should I write my DECLARE-statement if the underlying C-function expects an argument like "sqlite3 **ppDb"?
I wrote "DIM ppDb AS LONG BYADDRESS", but are quite sure that this is wrong. Calling the so defined function crashes my app.
How should I write my DECLARE-statement if the underlying C-function expects an argument like "sqlite3 **ppDb"?
I wrote "DIM ppDb AS LONG BYADDRESS", but are quite sure that this is wrong. Calling the so defined function crashes my app.
SQLite library
For LPCTSTR lpExistingFileName (CopyFile function) see how i used it here http://fnxbasic.com/yabb/YaBB.pl?num=1250272046
Perhaps you have to declare it like: DIM filename AS STRING byaddress
Long is the same type as Integer, signed 4 byte, 32 bit.
I`m not sure if your declaration of ppDb is wrong or good...
Perhaps i can look in one of the sqlite wrappers.
Perhaps you have to declare it like: DIM filename AS STRING byaddress
Long is the same type as Integer, signed 4 byte, 32 bit.
I`m not sure if your declaration of ppDb is wrong or good...
Perhaps i can look in one of the sqlite wrappers.
SQLite library
Defining filename as BYADDRESS is smart! In C its a pointer and might be modified, IIRC, so passing it by reference might be better.
But I fear that ppDb is declared wrongly.
EDIT:
I declared filename byaddress as you suggested but calling this function still crashes my app. :(
But I fear that ppDb is declared wrongly.
EDIT:
I declared filename byaddress as you suggested but calling this function still crashes my app. :(