Mid

Syntax:

    output = Mid(source, start, count)

Command Availability:

Available on all microcontrollers

Explanation:

The Mid function is used to extract characters from the middle of a string variable. source is the variable to extract from, start is the position of the first character to extract, and count is the number of characters to extract. If count is not specified, all characters from start to the end of the source string will be returned.

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 = "The cat sat on the mat"

    'Extract "cat". The c is at position 5, and 3 letters are needed
    HSerPrint "The animal is a "
    HSerPrint Mid(TestData, 5, 3)

    'Extract the action. "sat" starts at position 9.
    HSerPrint "The animal "
    HSerPrint Mid(TestData, 9)
    HSerPrintCRLF

See Also Left, Right