I am working on the example i found for the winaqlite3.dll
I figured it i could get this to work I would look at the regular sqlite.
a lot of the work on it is done or close, i am learning as i go.
The little bit i have below is my starting point.
I have changed the types to get it so i can step through it.
my question is about function openDB(
one of the params is the openDB im pretty sure that is a file handle for the database file.
> file handles are just a reference id so that i can refer to it later i think <
that is what i am asking. is if i am right about that.
I will show what i have figured out below the first code. it pretty ugly.
so im just askin about the file handle.
the pointer stuff is ugle but i think i got it mostly right.
I do have another question, now that i mentioned the pointers.
some of the function return a pounter, i have no idea how to get a function to return a pointer with varptr or codeptr.
could i use a type ?
thanks for looking at this.
Fred.
'==================================================
declare ptrSafe function sqlite3_open lib "winsqlite3.dll" ( _
byVal zFilename as string , _
byRef ppDB as longPtr _
) as longPtr ' }
'==================================================
function openDB(fileName as string) as longPtr ' {
dim res as longPtr
res = sqlite3_open(fileName, openDB)
if res <> SQLITE_OK then
err.raise 1000, "openDB", "sqlite_open failed, res = " & res
end if
debug.print("SQLite db opened, db = " & openDB)
end function ' }
'==================================================
sub main() ' {
dim db as longPtr
db = openDB(environ("temp") & "\test.db")
****************************************************************
****************************************************************
function openDB( fileName as string) as long ' {
dim res as long
'----
local varptr2 as long
local varptr2_ as long value 2
varptr2 = varptr(varptr2_)
local n as long value peek(varptr2)
res = sqlite3_open(fileName, varptr2)
if res <> %SQLITE_OK then
err.raise 1000, "openDB", "sqlite_open failed, res = " & res
end if
debug.print("SQLite db opened, db = " & openDB)
end function ' }
'===========
sub tbmain() ' {
'dim db as dword 'longPtr
dim db_ as long 'dim db as long value VarPtr(db_)
dim filenamePTR_ as asciiz
filenamePTR_ = ".\mytest.db"
dim filenamePTR = varptr(filenamePTR_)
'[breakpoint] <Any note here. Breakpoint will be set to line following this statement>
'db = openDB(environ("temp") & "\test.db")
'db = openDB(".\test.db")
'call openDB(".\test.db") to varptr(db) ' ->-> db = openDB(".\test.db")
call openDB( filenamePTR_ ) to varptr(db)
'[book] <openDB(>
'===========
'[book] <' sqlite3_open {
declare function sqlite3_open lib "winsqlite3.dll" ALIAS "sqlite3_open" ( _
byVal zFilename as string , _
byRef ppDB as long'Ptr _
) as long'Ptr ' }
Bookmarks