Firetron’s FormatBoolean

1 38 Views 1 Comment 1 week ago
  • Formats a boolean to a string so it can be logged.

    HaasScript Code
    --  ==========================================================================================================
    --    Firetron's FormatBoolean
    --
    --    Formats a boolean to a string so it can be logged.
    --
    --    Discord:  @FiretronP75
    --    BTC Tips: 14WLDZsrhshcP6qvBarKW8ABACv3iUXEro
    --    ETH Tips: 0xfaaac99fbf11f8f4abc4b3bf079cb2c7a43b5f87
    --  ==========================================================================================================
    
    --  ==============
    --    Definition
    --  ==============
    
    DefineCommand('FormatBoolean', 'Formats a boolean to a string so it can be logged.')
    
    --  ==============
    --    Parameters
    --  ==============
    
    local input = DefineParameter(BooleanType, 'Input', 'The boolean to format', true, false)
    
    --  ==========
    --    Output
    --  ==========
    
    local output = ''
    
    if input then
      output = 'true'
    else
      output = 'false'
    end
    
    DefineOutput(StringType, output, 'Formatted Value')
    • #1106

      HaasScript errors if you try to log a boolean like

      Log('Is Open: '..isOpen)

      You can do it by itself like

      Log(isOpen)

      But then you have to put its label on an extra log output before it.

      Is Open: true
      

      is much nicer to see in the log than

      Is Open:
      true
      
      • This reply was modified 1 week, 3 days ago by Firetron.
Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free