Is there a trick to determine if UseSQLiteDatabase() has already been called?
I have a module that uses sqlite internally, and I don't want to re-issue UseSQLiteDatabase() again if the main code has already called it.
detect if usesqlitedatabase() has been issued?
Re: detect if usesqlitedatabase() has been issued?
Isn't that just a directive to link it?
but if it causes any odd side effects you could use a macro
but if it causes any odd side effects you could use a macro
Code: Select all
Global usesqlite
Procedure _UseSQLiteDatabase()
If Not usesqlite
usesqlite = UseSQLiteDatabase()
Else
Debug "in use"
EndIf
EndProcedure
Macro UseSQLiteDatabase()
_UseSQLiteDatabase()
EndMacro
UseSQLiteDatabase()
UseSQLiteDatabase()
Re: detect if usesqlitedatabase() has been issued?
I had the same question
https://www.purebasic.fr/english/viewtopic.php?p=619675
Short answer: no you can't
https://www.purebasic.fr/english/viewtopic.php?p=619675
Short answer: no you can't
Re: detect if usesqlitedatabase() has been issued?
Why not calling it again ? If it's already called, it just does nothing.
Re: detect if usesqlitedatabase() has been issued?
In my case I want to activate features which is only needed if there is UseSQLiteDatabase() called. But most the time it is not necessary.
Re: detect if usesqlitedatabase() has been issued?
You need a different version of sqlite's DLLFred wrote: Tue May 21, 2024 1:28 pm Why not calling it again ? If it's already called, it just does nothing.
Code: Select all
UseSQLiteDatabase("c:\pbincludes\sqlite3.dll")
h2=OpenDatabase(-1,":memory:","","")
If DatabaseQuery(h2,"select sqlite_version();")
If NextDatabaseRow(h2)
Debug GetDatabaseString(h2,0)
EndIf
FinishDatabaseQuery(h2)
EndIf
UseSQLiteDatabase()
h1=OpenDatabase(-1,":memory:","","")
If DatabaseQuery(h1,"select sqlite_version();")
If NextDatabaseRow(h1)
Debug GetDatabaseString(h1,0)
EndIf
FinishDatabaseQuery(h1)
EndIf
Or more simply:
Code: Select all
UseSQLiteDatabase("c:\pbincludes\sqlite3.dll")
h2=OpenDatabase(-1,":memory:","","")
If DatabaseQuery(h2,"select sqlite_version();")
If NextDatabaseRow(h2)
Debug GetDatabaseString(h2,0)
EndIf
FinishDatabaseQuery(h2)
EndIf
UseSQLiteDatabase()
If DatabaseQuery(h2,"select sqlite_version();")
If NextDatabaseRow(h2)
Debug GetDatabaseString(h2,0)
EndIf
FinishDatabaseQuery(h2)
EndIf
Would be nice if any of the "use...()" resulted in a corresponding subsystem() query...
Re: detect if usesqlitedatabase() has been issued?
I will take a closer look, a second call should do nothing.
Re: detect if usesqlitedatabase() has been issued?
This is why I would like to use use..() appear as results of subsystem() or somethings similar.Cyllceaux wrote: Tue May 21, 2024 6:18 pm In my case I want to activate features which is only needed if there is UseSQLiteDatabase() called. But most the time it is not necessary.
While FAR from ideal..
Code: Select all
If OpenDatabase(0,":memory:","","",#PB_Database_SQLite)
MessageRequester("test","Used")
Else
MessageRequester("test","not Used")
EndIfIn a compiled exe or w/o debugger, it works as expected.
I've had the same sort of need for which image formats to save (jpg,png) based on if the use...() was issued.
Last edited by jassing on Tue May 21, 2024 8:15 pm, edited 1 time in total.



