Skip to content

Mid

See Also: String Functions, Left, Pos, Right

Purpose

Mid returns a substring of specified length and position from the value of the input string.

Return Type

String

Syntax

(Mid( {string-value}, {length}, {position} ))

Where:

  • {string-value} is the string that the substring is extracted from.
  • {length} is the length in code points of the substring that is returned.
  • {position} is the number of code points from the left of {string-value} marking the beginning of the substring. The {position} of the first character (leftmost) in {string-value} is 1 (position is 1-based).

What It Does

Move (Mid("Data Access Corporation", 3, 6)) To sWord

In this example, the characters "Acc" are moved to the variable sWord.

Notes

  • If {length} is less than 1, the function will return an empty string.
  • If {length} is greater than the length of {string-value} to the right of {position}, all of {string-value} to the right of {position} will be returned.
  • If {position} is less than 1, the function will return an empty string.
  • If {position} is greater than the length of {string-value}, the function will return an empty string.
  • This function returns a value of type string. If the result of this function is moved to a variable of type other than string, its value is converted to the destination type.
  • If {string-value} is of type other than string, its value will be converted to a string for output.