Is there a possibility to check if UseSQLiteDatabase() was called? I want to activate or deactivate some features in my libs depending of UseSQLiteDatabase was called.
CompilerIf Defined(UseSQLiteDatabase, #PB_Use)
Debug "cool"
CompilerElse
Debug "uncool" ; Should be called
CompilerEndIf
UseSQLiteDatabase()
CompilerIf Defined(UseSQLiteDatabase, #PB_Use)
Debug "cool" ; Should be called
CompilerElse
Debug "uncool"
CompilerEndIf
I wrote my own Module for saving informations. This Module is used by a lot of my tools and programs. Mostly my tools don't use a database. This is fine. So I don't want to compile the sqlite-lib into these tools. ATM I use the Defined and a constant like you do for solving this. BUT!!! It's not cool, cause I use a constant in all my tools only for enabling a feature of my module. So I hoped I can do this without declare a extra constant. And NO, I don't want to write 2 different Modules for that.
#PB_Use is only for the reason, cause I don't know if there is a other constant for that.
I think the use of a constants is the better way, but...
Maybe you can write a tool for PB that executed each time the code is compiled and by reading the source code you can determine if SQLite is used or not and take the needed actions
@Caronte3D: I thought so... But I hoped there were some PB-Functions to solve this
@infratec: No, that's still not good. It's cross project and it's not good to declare hundreds of global variables or constants in all of the projects, just to use different kinds of Modules and libs
@mk-soft: I thought about a extreme dirty way. something like this:
And adding the Module in every project, which uses UseSQLiteDatabase(). But I don't like this... I don't want to create empty modules for every "Use*"-Methode in PB.
just my 2 cents, probably not what you are looking for......
Explanation: I use the compiler permission that you can define constants as often as you want, as long as they are assigned the same value.
; need a different name to avoid recursive calls
;
Macro UseSQLiteDatabaseEx()
UseSQLiteDatabase() : #SQLite_Enabled = #True : Debug "Do SQLite....."
EndMacro
If UseSQLiteDatabaseEx()
Debug "Yes "
EndIf
CompilerIf Defined(SQLite_Enabled, #PB_Constant)
Debug "#SQLite_Enabled is defined (and true) "
CompilerElse
Debug "#SQLite_Enabled is not defined "
CompilerEndIf
Just because it worked doesn't mean it works. PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
@Axolotl: Yes... I know... But this means I have to do this in every program.
My Problem is, there are a Lot of "Use*" Libs, not only Database, but Image, Cypher and others, too.
To Make for every "Use*" Lib a Macro, Constant, Module... or other Solutions is to much. And then you have write Differences. "#SQLite_Enabled", "#SQLiteEnabled", "SQLite_DB"... what ever. And then I give my Libs or Modules to others and the First thing is to say: "Declare 50 Constants, which feature of PB you are using". This is not really good.
Before I compile various apps, I have to configure them. So why not force the issue with settable constants?
Here is example to force the use of USESQLITE