P.S. If you wonder where that would be useful: think for example sharing code, open-source projects, etc.[/quote]
As Ashot said, you can check the presence of plugin files. It works the same in the three platform. Where it becomes more of an issue is that conditional compilation requires a constant. Then I do not quite see how to implement it in the program. Maybe through an IDE Script that checks for the plugins, and sets the constant before compiling ?
There are at least a few issues I can think of off the top of my head with such a request
whether the plugin uses the same name from one release to another
For instance , if in one release it’s CurlMBS and in another its Curl_mbs
Most authors would not do this but it’s possible and your code would break
This is however unlikely with most authors
the version of the plugin required (say you have version 10 but the code expects version 15)
The plugin api doesn’t REQUIRE providing a version number at all - only what SDK it uses
the #if syntax requires a constant or constant expression - no calls to methods, subs etc since this is evaluated at compile time not runtime
So you could have #if true and false (a constant expression) but not #if CurlsMBS.isPresent
It’d have to be … something else … which could conflict with a method in the plugin etc
we’d have to scan ALL your code to find all the #if’s and see if any of them used whatever special name we came up with to know what to set consts TO
They’d HAVE to exist somewhere (whether the IDE automagically inserted them or you did)
You will get compile errors if they dont (so something has to create them somewhere along the line)
For the sake of sharing code (open source, etc.) I believe this is not an issue.
Since you are providing the code, you can just let the developer to decide if he wants to use MBS or not.
After all, is not said that if a developer has MBS plugins he wants to use them in all cases.
If you really want to make the life easier to a developer, just put conditional compilation for MBS and native code and define a constant the developer can set to change the behavior.
Is this still the case? I wanted to publish code that uses the MBS plugin if exists but if it doesn’t I want to provide a fallback solution.
In my case I don’t want to run a build step that copies support files if MBS is present, but I’m not sure how to handle that (even if there is a “useMBS” module constant.
[quote=402749:@Christian Schmitz]See MBS module in our plugins.
So you can write
#if MBS.HasCURLPlugin then
MsgBox "CURL Plugin is installed."
#endif
And check if a certain MBS Plugin is installed.[/quote]
Ah. It’s great that MBS has this. I guess this means the individual plugin has to have the routines, but there isn’t something in Xojo itself that can be used for any other plugin. Ok.
Can this be used in build scripts as well to not include some resources if the plug in is installed?
Would be great if someone has an hour to add something to preprocessor to check if identifiers exist.
Or if needed, just include condition as text in intermediate representation and later kick the code segment out if conditions turns out false.