From WikiChip
$~ Identifier - mIRC
< mirc‎ | identifiers
Revision as of 23:09, 1 February 2020 by Maroonbells (talk | contribs) (Created page with "{{mirc title|$~ Identifier}}'''$~''' is a construct which allows you to call a built-in identifier while both bypassing custom identifier in their absence, and avoiding the id...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

$~ is a construct which allows you to call a built-in identifier while both bypassing custom identifier in their absence, and avoiding the identifier warning. Returns $null in versions where the name doesn't exist as a built-in identifier.

Note: This is recommended on the optimization page to enhance speed of scripts.

Synopsis

$~

Parameters

None

Examples

Using $~ has no change in behavior in versions where the build-in $rands identifier exists. However, in prior versions the usage of $~ prevents calling a custom identifier, as would happen for the 2nd identifier call:
//echo -a $~rands(1,6) vs $rands(1,6)
 
The $~ avoids the script being halted due to an identifier warning:
//echo -a $~no_such_identifier

Note: While this has been known about and used for over 15 years, only recently has it been stated that this is intended for internal mIRC use and should not be used in scripts. For that reason, it's not likely that the bug related to spaces handling would be fixed.

1. You MUST avoid having spaces inside the parameters area. In this example, the spaces causes the strings not touching the $~ to be displayed:

//echo -a $~null(abc, def , ghi)
returns: def , ghi)
//echo -a string: $~null(abc,def,ghi)
returns: $null

2. The spaces also determines whether identifiers used as parameters are evaluated. In this example, repeating this command shows that $regml(foo,2) executes even when it's inside an identifier that doesn't execute, $regml(foo,1) does not get updated until inserting a space preceding $ of the first $regex. Removing all internal spaces avoids both $regex from evaluating:

//echo -a foo1: $regml(foo1,1) foo2: $regml(foo2,1) | echo -a text: $~nosuchidentifier( $regex(foo1,$r(a,z),/(.)/) , $regex(foo2,$r(a,z),/(.)/) ) foo1: $regml(foo1,1) foo2: $regml(foo2,1)

Compatibility

Version added: TBD

See Also

optimization