Firetron’s FormatTwoDigit

1 32 Views No Comments 4 weeks ago
  • Formats a number to have two digits like 04.

    HaasScript Code
    --  ==========================================================================================================
    --    Firetron's FormatTwoDigit
    --
    --    Formats a number to have two digits like 04.
    --
    --    Discord:  @FiretronP75
    --    BTC Tips: 14WLDZsrhshcP6qvBarKW8ABACv3iUXEro
    --    ETH Tips: 0xfaaac99fbf11f8f4abc4b3bf079cb2c7a43b5f87
    --  ==========================================================================================================
    
    --  ==============
    --    Definition
    --  ==============
    
    DefineCommand('FormatTwoDigit', 'Formats a number to have two digits like 04.')
    
    --  ==============
    --    Parameters
    --  ==============
    
    local input = DefineParameter(NumberType, 'Input', 'The number to format', true, 0)
    
    --  ==========
    --    Output
    --  ==========
    
    local output = ''..input
    
    if input < 10 then
      output = '0'..input
    end
    
    DefineOutput(StringType, output, 'Formatted Value')
Login or Register to Comment

Unlock your crypto trading potential

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

Join for Free