Right

Syntax:

    output = Right(source, count)

Command Availability:

Available on all microcontrollers.

Explanation:

The Right function extracts the rightmost 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_BLOCKING

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

    'Display the rightmost 6 characters
    'Will display "world!"
    HSerPrint Right(TestData, 6)          ' <<< the Right instruction
    HSerPrintCRLF

Key line: Right(TestData, 6) — returns the last 6 characters of TestData, giving "world!".

See Also:

  • Left — extracting characters from the start of a string instead
  • Mid — extracting characters from an arbitrary position