Left

Syntax:

    output = Left(source, count)

Command Availability:

Available on all microcontrollers.

Explanation:

The Left function extracts the leftmost count characters from the input string source, and returns them in a new string.

Example:

    'Set chip model
    #chip 16F1936

    'Set up hardware serial connection
    #define USART_BAUD_RATE 9600
    #define USART_TX_BLOCKING


    'Fill a string with a message
    Dim TestData As String
    TestData = "Hello, world!"

    'Display the leftmost 5 characters
    'Will display "Hello"
    HSerPrint Left(TestData, 5)          ' <<< the Left instruction
    HSerPrintCRLF

Key line: Left(TestData, 5) — returns the first 5 characters of TestData, giving "Hello".

See Also:

  • Right — extracting characters from the end of a string instead
  • Mid — extracting characters from an arbitrary position