B4J Question Marking code for changes before Release

Chris2

Active Member
Licensed User
Longtime User
I was recently debugging a routine that was within a Try..Catch block. In order to find the error I commented the Try..Catch to let the program crash fully.
I want to leave the Try..Catch commented for a while while I let things run to see if my bug fix works, but I'm afraid that I'll move on the other things, get distracted, and forget to uncomment the Try..Catch before building the next Release version of this app.

I though that doing the following might serve as a good reminder and prevent me from compiling in Release mode while still letting me run in Debug to test other things:
B4X:
'Try    'commented for testing only - NEEDS PUTTING BACK BEFORE NEXT RELEASE!!!!!!
#If RELEASE
Put the Try above back!
#End If

'...code that is now hopefully fixed goes here.....

'    Catch
'    Log(LastException)
#If RELEASE
Put these back too
#End If
'    End Try
And it works in that I can run in Debug to test the app, but am prevented from building in Release mode.
But, even in Debug the IDE complains that something is wrong:
1753800731230.png
1753800759024.png


Is there any way I can prevent the IDE from marking the unused text/code as being in error when I have Debug mode selected?
Or, does anyone have a better way of marking code to prevent running in Release mode while allowing running in Debug?

Thanks in advance.

Update: adding 'ignore doesn't help
Update: The "'catch' is missing" warning is just because of the word 'Try' in the text 'Put the Try above back', so that can be ignored here.
 
Last edited:
Solution
could it be that the Put lines should be comments or maybe change to
B4X:
#If Release
Try    
#End If

'...code that is now hopefully fixed goes here.....

#if Release
    Catch
    Log(LastException)
    End Try
#End If

Daestrum

Expert
Licensed User
Longtime User
could it be that the Put lines should be comments or maybe change to
B4X:
#If Release
Try    
#End If

'...code that is now hopefully fixed goes here.....

#if Release
    Catch
    Log(LastException)
    End Try
#End If
 
Upvote 0
Solution

Chris2

Active Member
Licensed User
Longtime User
the Put lines should be comments
If I do that, then it won't prevent me from building in Release mode by mistake.


maybe change to
B4X:
#If Release
Try
#End If

'...code that is now hopefully fixed goes here.....

#if Release
Catch
Log(LastException)
End Try
#End If
That looks like it might do exactly what I want though!
Thanks. I'll try it tomorrow.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
You can use the same schema and create your own "labels" in Project>Build Configurations
1753820861983.png
 
Upvote 0

Chris2

Active Member
Licensed User
Longtime User
You can use the same schema and create your own "labels" in Project>Build Configurations
Thanks @Cableguy. I'm familiar with the Build Configurations and Conditional Symbols. But here I was looking for something to specifically prevent me from running in release mode or (as per @Daestrum's second suggestion), to make sure that the try..catch was put back in on Release.
 
Upvote 0
Top