Keil Logo

SUBSTR Function

The SUBSTR MPL function returns a substring of the specified text argument. The SUBSTR function takes three arguments: a character string to be divided, and two numeric arguments. The syntax for the SUBSTR function is:

%SUBSTR (balanced-text,expression1,expression2)

Where

balanced-text is a text argument possibly containing macro calls. This is the string from which a substring is returned.
expression1 specifies the substring's starting position in balanced-text. If expression1 is zero or is greater than the length of the balanced-text, SUBSTR returns a null string. The index of the first character of balanced-text is 1.
expression2 specifies the number of the characters to expand from balanced-text. If expression2 is zero SUBSTR returns a null string. If expression2 is greater than the remaining length of the string all characters from the expression1th character to the end of the string are included.

Source Text

%DEFINE (STRING) (abcdefgh)
%SUBSTR (%string, 1, 2)
%SUBSTR (%(1,2,3,4,5), 3, 20)

Output Text

ab
2,3,4,5
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.