Mid$

Takes two parameters, Source, Values

Description:

Returns a substring of Source. The Values parameter is two numbers, space separated, Start and Length. e.g. "5 3" is a Start position of 5 and a Length of 3.

When these values are positive, Start will be counted from the left with the 1 being the first byte, and Length will be absolute.

When Start is negative, it is counted from the right side, with -2 being the second last byte.

When Length is negative, it will be the length of Source less Length, e.g. if Source is 10 bytes long and Length is -3, the effective Length will be 7.

Note: Moxie.Build is configured for all pages / data to be in UTF-8. The Len$, Right$Left$, and Mid$ functions reference byte counts, not character counts. All non-accented Latin characters, as is normal in English, are one byte per character. However, accented characters and non-Latin characters will be multiple bytes per character. Consideration of these limits should always be used when designing code that uses Len$, Right$, Left$, and Mid$.

Examples:

[New] source    = "1234567890"
[New] result1 = Mid$ source, "3 2"
[New] result2 = Mid$ source, "-3 2"
[New] result3 = Mid$ source, "3 -5"
[New] result4 = Mid$ source, "-7 -5"

Html result1 'result1 is equal to "34"
Html result2 'result2 is equal to "89"
Html result3 'result3 is equal to "34567"
Html result4 'result4 is equal to "45678"