RandomCoder Well-Known Member Licensed User Longtime User Jan 3, 2014 #1 It's been a while since I last looked at the beginners guide and so I'm currently rereading it to catch up on some of the new features that have been added, that's when I came across this... Ignoring warnings You, as the developer, can choose to ignore any warning. Adding an "ignore" comment will remove all the warnings for that specific line: Code: Copy Sub UnusedSub(a As Int) 'ignore Click to expand... That's when I thought wouldn't it be nice to have a similar option of debug code. I regularly add lots of lines such as... Code: Copy Log("Some useful information") 'DEBUG Then when I'm done I search for the word DEBUG and delete all those lines. This means that all the once useful debug comments are gone for good in the finished app. It would be nice to leave them in but have the final released code ignore lines commented as DEBUG, this is my wish I've seen code where the programmer sets debug code within conditional statements and then uses a flag to enable the debug statements as required, which is another way of doing it without needing to actually delete any debug lines of code. I suppose its all down to personal preference. Kind regards, RandomCoder
It's been a while since I last looked at the beginners guide and so I'm currently rereading it to catch up on some of the new features that have been added, that's when I came across this... Ignoring warnings You, as the developer, can choose to ignore any warning. Adding an "ignore" comment will remove all the warnings for that specific line: Code: Copy Sub UnusedSub(a As Int) 'ignore Click to expand... That's when I thought wouldn't it be nice to have a similar option of debug code. I regularly add lots of lines such as... Code: Copy Log("Some useful information") 'DEBUG Then when I'm done I search for the word DEBUG and delete all those lines. This means that all the once useful debug comments are gone for good in the finished app. It would be nice to leave them in but have the final released code ignore lines commented as DEBUG, this is my wish I've seen code where the programmer sets debug code within conditional statements and then uses a flag to enable the debug statements as required, which is another way of doing it without needing to actually delete any debug lines of code. I suppose its all down to personal preference. Kind regards, RandomCoder
S sorex Expert Licensed User Longtime User Jan 4, 2014 #3 I'd rather go for conditional compilation. in process globals use dim debug as int=1 ' or 0 for release build dim versiontype as string="pro" then you can use .if debug=1 then log ("your stuff") notice the . before the if, this means it's conditional compilation which should allow you to create a pro and limited version in 1 file too so no messing up due to forgetting to update code parts in 2 different projects .if versiontype<>"pro" then showprolink() showAds() .endif not sure if it already supports something simular tho
I'd rather go for conditional compilation. in process globals use dim debug as int=1 ' or 0 for release build dim versiontype as string="pro" then you can use .if debug=1 then log ("your stuff") notice the . before the if, this means it's conditional compilation which should allow you to create a pro and limited version in 1 file too so no messing up due to forgetting to update code parts in 2 different projects .if versiontype<>"pro" then showprolink() showAds() .endif not sure if it already supports something simular tho
JakeBullet70 Well-Known Member Licensed User Longtime User Jan 5, 2014 #4 Actually, here is what i do now. This code is in a bass module: debugModeSet is called one time when the program starts '--- and then I use this debugLog("Prints only if debugger is attatched") Code: Copy Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Public debugMode As Boolean End Sub Public Sub debugModeSet() As Boolean Dim r As Reflector debugMode = r.GetStaticField("anywheresoftware.b4a.BA", "debugMode") Return debugMode End Sub Public Sub debugLog(s As String) If debugMode Then Log(s) End Sub
Actually, here is what i do now. This code is in a bass module: debugModeSet is called one time when the program starts '--- and then I use this debugLog("Prints only if debugger is attatched") Code: Copy Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Public debugMode As Boolean End Sub Public Sub debugModeSet() As Boolean Dim r As Reflector debugMode = r.GetStaticField("anywheresoftware.b4a.BA", "debugMode") Return debugMode End Sub Public Sub debugLog(s As String) If debugMode Then Log(s) End Sub
S sorex Expert Licensed User Longtime User Jan 5, 2014 #5 yes, that's an option just for debug output. with the conditional compile you can output to the logfile or onto the screen, sd card, smb share whatever. if you disable it all that code is not being inserted at all. same goes for pro features etc, if it's not needed it's not included either. so you work in 1 app for both versions (free & pro/paid) and just compile with 1 variable that has a different value
yes, that's an option just for debug output. with the conditional compile you can output to the logfile or onto the screen, sd card, smb share whatever. if you disable it all that code is not being inserted at all. same goes for pro features etc, if it's not needed it's not included either. so you work in 1 app for both versions (free & pro/paid) and just compile with 1 variable that has a different value
JakeBullet70 Well-Known Member Licensed User Longtime User Jan 6, 2014 #6 I agree about conditional compiling, would be nice.