MLStrings Plugin

From Cinemar Wiki
Jump to: navigation, search

Plugin Syntax

MLServeCmd.MLStrings|<<command>>~<<output variable name>>~<<input string>>~<<param1>>[~<<param2>>[~<<param3>>[~<<param4>>]]]


Plugin About

Performs various string-manipulation functions.

Supported commands: Left, Mid, Right, InStr, Len, UCase, LCase, Replace, RegEx, RegExPos, Extract, ItemCount

LEFT - returns <<param1>> characters from the start of the input string (up to the entire string).

MID - returns remaining characters of the input string starting from <<param1>>. If <<param2>> is specified, the result is limited to <<param2>> characters.

RIGHT - returns <<param1>> characters from the end of the input string (up to the entire string).

INSTR - returns the position of string <<param1>> in the input string. If <<param1>> is not found, it returns 0.

LEN - returns the length of the input string.

LCASE - returns the input string in all-lowercase.

UCASE - returns the input string in all-uppercase.

REPLACE - returns the input string with <<param1>> replaced by <<param2>> starting at (optional) <<param3>> for up to (optional) <<param4>> instances.

REGEX - returns the first match to regular expression <<param1>> starting at (optional) position <<param2>>.

REGEXPOS - returns the location of the first match to regular expression <<param1>> starting at (optional) position <<param2>>.

EXTRACT - returns item <<param2>> from a list of items delimited by <<param1>>. Special delimiter value ((CRLF)) specifies carriage return-line feed as the delimiter.

ITEMCOUNT - returns the number of items in the list of items delimited by <<param1>>. Special delimiter value ((CRLF)) specifies carriage return-line feed as the delimiter. Note: The first character of a string is position 1.

Verbose documentation

MLStrings

Provides string manipulation functions to MainLobby Server


Brandon S Higa - bhiga on Cinemar Forums---------------------

Important note


While strings including double-quote characters (") can be used for input, any _output_ that would normally include double-quote characters results in the process not completing. This appears to be a limitation of the architecture somehow, as

 MLServeCmd.SetVariable|Foo~"Hello World!"

also fails to set Foo. Thus,

 MLServeCmd.MLStrings|Left~Foo~Joe "B" Ten~3

sets Foo to Joe as expected, but

 MLServeCmd.MLStrings|Left~Foo~Joe "B" Ten~5

does not set Foo as the result includes a double-quote character.


Syntax

 MLServeCmd.MLStrings|<<command>>~<<output variable name>>~<<input string>>~<<param1>>[~<<param2>>]

example:

 MLServeCmd.MLStrings|LEFT~Foo~Bar_Cherry_Lemon Soda_Candy~4

will set variable Foo to Bar_

example:

 MLServeCmd.MLStrings|EXTRACT~Foo~Black|White|Gray|Blue~|~3

will set variable Foo to Gray


Implemented functions

LEFT Returns the first param1 characters from the input string Returns entire string if param1 exceeds length of string

param1: integer = number of characters to return from the beginning of the input string

VBScript equivalent: Left(input, param1)

example:

 MLServeCmd.MLStrings|Left~Foo~Bar_Cherry_Lemon Soda_Candy~4

Variable Foo is set to value Bar_


RIGHT Returns the last param1 characters from the input string Returns entire string if param1 exceeds length of string

param1: integer = number of characters to return from the end of the input string

VBScript equivalent: Right(input, param1)

example:

 MLServeCmd.MLStrings|Right~Foo~Bar_Cherry_Lemon Soda_Candy~4

Variable Foo is set to value andy


MID (param1 only) Returns remaining characters from the input string starting at position param1

param1: integer = position to start result string at (1 is first character)

VBScript equivalent: Mid(input, param1)

example:

 MLServeCmd.MLStrings|Mid~Foo~Bar_Cherry_Lemon Soda_Candy~6

Variable Foo is set to value herry_Lemon Soda_Candy


MID (param1 and param2) Returns maximum of param2 characters from the input string starting at position param1

param1: integer = position to start result string at (1 is first character) param2: integer = max number of characters to return

VBScript equivalent: Mid(input, param1, param2)

example:

 MLServeCmd.MLStrings|Mid~Foo~Bar_Cherry_Lemon Soda_Candy~6~4

Variable Foo is set to value herr


INSTR Returns the position of param1 in the input string. Returns 0 if param1 is not found in the input string.

param1: string = string to look for in the input string

VBScript equivalent: InStr(input, param1)

example:

 MLServeCmd.MLStrings|InStr~Foo~Bar_Cherry_Lemon Soda_Candy~Cherry

Variable Foo is set to value 5

example:

 MLServeCmd.MLStrings|InStr~Foo~Bar_Cherry_Lemon Soda_Candy~Orange
Variable Foo is set to value 0

LEN Returns the length of the input string

VBScript equivalent: Len(input)

example:

 MLServeCmd.MLStrings|Len~Foo~Bar_Cherry_Lemon Soda_Candy

Variable Foo is set to value 27


UCASE Returns the input string in all-uppercase

VBScript equivalent: UCase(input)

example:

 MLServeCmd.MLStrings|UCase~Foo~Bar_Cherry_Lemon Soda_Candy

Variable Foo is set to BAR_CHERRY_LEMON SODA_CANDY


LCASE Returns the input string in all-lowercase

VBScript equivalent: LCase(input)

example:

 MLServeCmd.MLStrings|LCase~Foo~Bar_Cherry_Lemon Soda_Candy

Variable Foo is set to bar_cherry_lemon soda_candy


REPLACE (param1 and param2 only) Returns the input string with all occurrences of param1 replaced by param2

VBScript equivalent: Replace(input, param1, param2)

example:

 MLServeCmd.MLStrings|Replace~Foo~Bar_Cherry_Lemon Soda_Strawberry Soda_Candy~Soda~Sherbet

Variable Foo is set to Bar_Cherry_Lemon Sherbet_Strawberry Sherbet_Candy


REPLACE (param1, param2 and param3 only) Returns the input string starting from param3 with all occurrences of param1 replaced by param2

VBScript equivalent: Replace(input, param1, param2, param3)

example:

 MLServeCmd.MLStrings|Replace~Foo~Bar_Cherry_Lemon Soda_Strawberry Soda_Candy~Soda~Sherbet~20

Variable Foo is set to da_Strawberry Sherbet_Candy Position 20 is the 'd' of the first instance of Soda, so everything before it is discarded.


REPLACE (param1, param2, param3 and param4) Returns the input string starting from param3 with param1 replaced by param2 for up to param4 occurrences

VBScript equivalent: Replace(input, param1, param2, param3, param4)

example:

 MLServeCmd.MLStrings|Replace~Foo~Bar_Cherry_Lemon Soda_Strawberry Soda_Candy~y~x~12~1

Variable Foo is set to Lemon Soda_Strawberrx Soda_Candy Position 12 is the L of Lemon, so everything before it is discarded and the replacement is limited to one occurrence, so the y of Candy is left alone.


REPLACE (param1, param2, and param4 with empty param3) Returns the input string with param1 replaced by param2 for up to param4 occurrences

VBScript equivalent: Replace(input, param1, param2, 1, param4)

example:

 MLServeCmd.MLStrings|Replace~Foo~Bar_Cherry_Lemon Soda_Strawberry Soda_Candy~y~x~~2

Variable Foo is set to Bar_Cherrx_Lemon Soda_Strawberrx Soda_Candy Only the first two y's are replaced by x.


REGEX (param1 only) Returns the first match to regular expression param1 in the specified string

example:

 MLServeCmd.MLStrings|RegEx~Foo~Hello world~\w*o

Variable Foo is set to Hello


REGEX (param1 and param2) Returns the first match to regular expression param1 in the specified string starting at position param2

example:

 MLServeCmd.MLStrings|RegEx~Foo~Hello world~\w*o~6

Variable Foo is set to wo


EXTRACT Returns the param2th parameter in the input string delimited by param1

param1: string = delimiter string (may be more than one character) The special value ((CRLF)) can be used as the delimiter to signify that carriage return/line-feed is the delimiter. param2: integer = position number for string to return

VBScript equivalent: none (variation of PHP explode function)

example:

 MLServeCmd.MLStrings|Extract~Foo~Black|White|Gray|Blue~|~3

Variable Foo is set to value Gray

example:

 MLServeCmd.MLStrings|Extract~Foo~One$$Two$$Three$$Four~$$~1

Variable Foo is set to value One


ITEMCOUNT Returns the number of items in the input string delimited by param1 Empty string input returns an item count of 1

param1: string = delimiter string (may be more than one character) The special value ((CRLF)) can be used as the delimiter to signify that carriage return/line-feed is the delimiter.

VBScript equivalent: none (variation of PHP explode function)

example:

 MLServeCmd.MLStrings|ItemCount~Foo~Black|White|Gray|Blue~|

Variable Foo is set to value 4

example:

 MLServeCmd.MLStrings|Item~Foo~One$$Two$$Three~$$

Variable Foo is set to value 3