From WikiChip
$min identifier - mIRC
< mirc‎ | identifiers

$min returns the minimum from a list of tokens. $min and $max are effectively a short-cut to returning either the first or last token from a $sorttok list, and uses different .prop settings to replicate the different switches used by $sorttok. By default, $min and $max sort the tokens with the same rules used by the $sorttok 'n' switch.

Synopsis[edit]

$min(<space delimited tokens>)
$min(<comma,delimited,tokens>)

Parameters[edit]

  • <list> - If only 1 parameter is used, the list of tokens is space delimited. Otherwise with multiple parameters it becomes a comma-delimited list of tokens.

Properties[edit]

  • .text - sorts tokens using the same text sorting rules used by $sorttok 'a' switch
  • .textcs - sorts tokens using the same text sorting rules used by $sorttokcs 'a' switch
  • .nick - sorts tokens using the same text sorting rules used by $sorttok 'c' switch

Examples[edit]

  • See $sorttok for more details of how text and number tokens are handled. Briefly, non-numerics trailing the tokens in a numeric sort do not affect the sort order. Numeric tokens evaluating to the same number, and text tokens evaluating to the same string returns the leftmost of those tokens. The only difference caused by .textcs vs .text is whether the a-z and A-Z ranges are treated as equivalents.

Tokens can only be space- or comma- delimited. To have any other delimiter you must use $sorttok.

//echo -a $min(11 2 3 5 8 13) $min(11,2,3,5,8,13)

For a comma to be a delimiter, it must be a literal comma, so a comma contained within a variable or a $chr(44) are not delimiters. These return a comma character as the minimum because its codepoint is lower:

//var %a 1 $chr(44) 2 | echo -a $min(1 $chr(44) 2) vs $min(%a)

Because default is the numerical sort, and all non-numerics evaluate as zero, the leftmost token in this list is returned.

//echo -a $max(b B a A c C) vs $min(b B a A c C)
//echo -a $min(c C).text vs $min(c C).textcs

Returns "c vs C" because, as case-insensitive text, 'C' and 'c' are the same, so the leftmost of the pair is returned. Sorting is done by codepoint, so accented vowels are sorted by their codepoint location, with no effect on whether their symbol represents a variant of a/e/i/o/u.

Numeric sorting rules recognize exponential, so $min(1e2 99) handles both 1e2 and 1d2 the same as 100.

Trailing non-numerics do not affect the result of numeric sorts

//echo -a $min( 1:black 02:blue 14:grey 3:green 13:magenta 5:maroon 6:purple 04:red 7:tan 8:yellow 0:white)

result: 0:white

Using the .nick property is the same as using the 'c' switch with $sorttok, where the sorting alphabet is altered to place the ranks to the minimum in the order they appear in the $prefix output, which can possibly be a different result in windows attached to different networks:

//echo -a $asc(@) $asc(%) $asc(+) $min(@nick % $+ nick +nick).nick vs $min(@nick % $+ nick +nick).text

Compatibility[edit]

Added: mIRC v7.62
Added on: 29 Jul 2020
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.

See also[edit]