Mid (Function)

Returns a substring of a string

Syntax
	KeyPgDeclareDeclare KeyPgFunctionFunction Mid ( KeyPgByrefByRef str as KeyPgConstQualifierConst KeyPgStringString, KeyPgByvalByVal start as integer 
	) as KeyPgStringString
	KeyPgDeclareDeclare KeyPgFunctionFunction Mid ( KeyPgByvalByVal str as KeyPgConstQualifierConst KeyPgWstringWString KeyPgPtrPtr, KeyPgByvalByVal start as 
	integer ) as KeyPgWstringWString
	KeyPgDeclareDeclare KeyPgFunctionFunction Mid ( KeyPgByrefByRef str as KeyPgConstQualifierConst KeyPgStringString, KeyPgByvalByVal start as 
	integer, KeyPgByvalByVal n as integer ) as KeyPgStringString
	KeyPgDeclareDeclare KeyPgFunctionFunction Mid ( KeyPgByvalByVal str as KeyPgConstQualifierConst KeyPgWstringWString KeyPgPtrPtr, KeyPgByvalByVal start as 
	integer, KeyPgByvalByVal n as integer ) as KeyPgWstringWString

Usage
	result = Mid[$]( str, start [, n ] )

Parameters
	str
		The source string.
	start
		The start position in str of the substring. The first character 
		starts at position 1.
	n
		The substring length, in characters.

Description
	Returns a substring starting from start in str. If str is empty then the 
	null string ("") is returned. If start <= 0 or start > len(str) then the 
	null string ("") is returned.

	In the first form of Mid, all of the remaining characters are returned. 
	In the second form, if n < 0 or n > len(str) - start then all of the 
	remaining characters are returned.

Example
	Print Mid("abcdefg", 3, 2)
	Print Mid("abcdefg", 3)
	Print Mid("abcdefg", 2, 1)

	will produce the output:
	cd
	cdefg
	b

A Unicode example:
	Wiki: code rendered this way to allow display of the Unicode characters.

dim text as wstring * 20
	text = "&#1055;&#1088;&#1080;&#1074;&#1077;&#1090;, 
	&#1084;&#1080;&#1088;!"
	print mid(text, 6, 4) ' displays "&#1090;, &#1084;"

Platform Differences
	* DOS does not support the wide-character string versions of Mid.

Dialect Differences
	* The string type suffix "$" is required in the CompilerOptlang-lang qb dialect.
	* The string type suffix "$" is optional in the CompilerOptlang-lang fblite dialect.
	* The string type suffix "$" is ignored in the CompilerOptlang-lang fb dialect, warn 
	  only with the CompilerOptw-w suffix compile option (or CompilerOptw-w pedantic compile 
	  option).

Differences from QB
	* QB does not support Unicode.

See also
	* KeyPgInstrInStr
	* KeyPgMidstatementMid (Statement)
	* KeyPgLeftLeft
	* KeyPgRightRight
	* KeyPgAscAsc

