Wish "Not in Reelease" keyword

Discussion in 'Bugs & wishlist' started by Cableguy, Jul 20, 2015.

  1. Cableguy

    Cableguy Expert Licensed User

    Hi EREL,

    I know we already can exclude/condition code Blocks from compiling...

    But a keyword that would render the inline code NOT to compile into release would be very useful.

    I am one of those who like to place many LOG messages just to make sure things are what I need them to be, but then when compiling into release I need to go through all my code just to delete them.
     
  2. DonManfred

    DonManfred Expert Licensed User

    You can use a code module with a custom logger... You can use conditional compiling in this sub to noch include the log-commands in release mode

    Code:
    Type=StaticCode
    Version=
    3.82
    B4A=
    true
    @EndOfDesignText@
    'Code module
    'Subs in this code module will be accessible from all modules.
    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'These variables can be accessed from all modules.
       
        
    'Log(DateTime.Date(DateTime.Now))
        'Log(DateTime.Time(DateTime.Now))

        
    Public logError = 1
        
    Public logWarning = 2
        
    Public logNotice = 4
        
    Public logDebug = 8
        
    Public logSub = 16

    End Sub
    Sub MyLog(LogType As Int, text As String)
        
    Select LogType
        
    Case logError
            LogColor(
    "  Error: "&text,Colors.Red)
        
    Case logWarning
            LogColor(
    "Warning: "&text,Colors.ARGB(255,255,140,0))
        
    Case logNotice
            LogColor(
    " Notice: "&text,Colors.Blue)
        
    Case logDebug
            LogColor(
    "  Debug: "&text,Colors.ARGB(255,139,0,0))
        
    Case logSub
            LogColor(
    "    Sub: "&text,Colors.ARGB(255,139,0,0))
        
    End Select   
    End Sub
     
    ArminKH and lemonisdead like this.
  3. lemonisdead

    lemonisdead Well-Known Member Licensed User

    I do personally use
    Code:
    #If Debug
    Log("something")
    #End If
    Perhaps it could help ?
     
    Cableguy and DonManfred like this.
  4. Cableguy

    Cableguy Expert Licensed User

    That takes 3 lines to do one log...
    Maybe a inline "#Debug" feature could be implemented
     
    Last edited: Jul 21, 2015
    Vader likes this.
Loading...