Daestrum Expert Licensed User Longtime User Dec 13, 2018 #1 Is there a simple way for a library to check if it is being run against a debug (IDE) run version of an app or a release version (ie java -jar xxx). The reason I ask is I have noticed the method signatures vary in a Class module depending on release or debug (extra parameter in debug). Sorted - completely forgot about #if DEBUG Sorry... Not sorted, I need to know if app is running from IDE or jar file. Last edited: Dec 13, 2018
Is there a simple way for a library to check if it is being run against a debug (IDE) run version of an app or a release version (ie java -jar xxx). The reason I ask is I have noticed the method signatures vary in a Class module depending on release or debug (extra parameter in debug). Sorted - completely forgot about #if DEBUG Sorry... Not sorted, I need to know if app is running from IDE or jar file.
R Roycefer Well-Known Member Licensed User Longtime User Dec 14, 2018 #2 Code: Copy #CommandLineArgs: inide Sub AppStart(Args() As String) If Args(0)=="inide" Then ..... Upvote 0
LucaMs Expert Licensed User Longtime User Dec 14, 2018 #3 Roycefer said: Code: Copy #CommandLineArgs: inide Sub AppStart(Args() As String) If Args(0)=="inide" Then ..... Click to expand... Running the jar the project crashes (and not for the little mistake about the double equal sign, corrected, of course) Upvote 0
Roycefer said: Code: Copy #CommandLineArgs: inide Sub AppStart(Args() As String) If Args(0)=="inide" Then ..... Click to expand... Running the jar the project crashes (and not for the little mistake about the double equal sign, corrected, of course)
R Roycefer Well-Known Member Licensed User Longtime User Dec 14, 2018 #4 The double equal sign isn't a mistake. Quite the contrary, not using it is a mistake. It crashes because there is no bounds checking. Shall I demonstrate that for you? Upvote 0
The double equal sign isn't a mistake. Quite the contrary, not using it is a mistake. It crashes because there is no bounds checking. Shall I demonstrate that for you?
LucaMs Expert Licensed User Longtime User Dec 14, 2018 #5 As far as I know it does not work in b4x (although I have not tried) Upvote 0
Daestrum Expert Licensed User Longtime User Dec 14, 2018 #6 That works for what I want. I used Code: Copy 'set debugging flag in class module ocm.debugging = Args(0)="inide" Upvote 0
That works for what I want. I used Code: Copy 'set debugging flag in class module ocm.debugging = Args(0)="inide"
Erel B4X founder Staff member Licensed User Longtime User Dec 16, 2018 #7 Code: Copy ocm.debugging = Args.Length > 0 AND Args(0) = "inide" Upvote 0
Daestrum Expert Licensed User Longtime User Dec 17, 2018 #8 Thanks for the suggestions, eventually I had to go a different code route as there were differences between release and debug in the IDE runs. In case anyone else needs to call a b4j Class module sub from a java library I found the simplest way was to add a dummy sub to the class module. Code: Copy Public Sub semaphore() ' Dummy method End Sub I then just check the number of parameters it expects, if none , then I call other subs as normal. If it needs 1 parameter I call them with the class instance as the first parameter. Upvote 0
Thanks for the suggestions, eventually I had to go a different code route as there were differences between release and debug in the IDE runs. In case anyone else needs to call a b4j Class module sub from a java library I found the simplest way was to add a dummy sub to the class module. Code: Copy Public Sub semaphore() ' Dummy method End Sub I then just check the number of parameters it expects, if none , then I call other subs as normal. If it needs 1 parameter I call them with the class instance as the first parameter.
Erel B4X founder Staff member Licensed User Longtime User Dec 17, 2018 #9 Daestrum said: In case anyone else needs to call a b4j Class module sub from a java library I found the simplest way was to add a dummy sub to the class module. Click to expand... Why not raise an event with BA.raiseEvent? This is the correct way to call a B4X sub. Upvote 0
Daestrum said: In case anyone else needs to call a b4j Class module sub from a java library I found the simplest way was to add a dummy sub to the class module. Click to expand... Why not raise an event with BA.raiseEvent? This is the correct way to call a B4X sub.
Daestrum Expert Licensed User Longtime User Dec 17, 2018 #10 It was more a case of 'Can I?" as opposed to "Should I?". I sometimes use more than one instance of a code module and needed a way to call a sub in a particular instance (not a problem with a Class module). Upvote 0
It was more a case of 'Can I?" as opposed to "Should I?". I sometimes use more than one instance of a code module and needed a way to call a sub in a particular instance (not a problem with a Class module).
Erel B4X founder Staff member Licensed User Longtime User Dec 17, 2018 #11 Daestrum said: I sometimes use more than one instance of a code module Click to expand... It is not possible to create more than one instance of a static code module. Static code modules = singletons. Upvote 0
Daestrum said: I sometimes use more than one instance of a code module Click to expand... It is not possible to create more than one instance of a static code module. Static code modules = singletons.
Daestrum Expert Licensed User Longtime User Dec 17, 2018 #12 I just initialize a new instance. That way a thread has its own copy to use. (othercodemodule) b4j.example.othercodemodule@29a2db4d (othercodemodule) b4j.example.othercodemodule@673c97ed Upvote 0
I just initialize a new instance. That way a thread has its own copy to use. (othercodemodule) b4j.example.othercodemodule@29a2db4d (othercodemodule) b4j.example.othercodemodule@673c97ed
Erel B4X founder Staff member Licensed User Longtime User Dec 17, 2018 #13 This cannot be done from B4J and is a mistake to do if it is done in your Java code. Use classes instead. Upvote 0
This cannot be done from B4J and is a mistake to do if it is done in your Java code. Use classes instead.