From WikiChip
Editing mirc/identifiers/$~
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | {{mirc title|$~ Identifier}}'''$~''' is a construct which allows you to call built-in | + | {{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 identifier warning. Returns $null in versions where the name doesn't exist as a built-in identifier. |
+ | |||
+ | Note: This is recommended on the {{mirc|optimization}} page to enhance speed of scripts. | ||
== Synopsis == | == Synopsis == | ||
− | <pre>$~ | + | <pre>$~</pre> |
== Parameters == | == Parameters == | ||
None | None | ||
− | == | + | == Examples == |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<source lang="mIRC"> | <source lang="mIRC"> | ||
− | + | 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) | //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 | |
</source> | </source> | ||
− | + | 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. | |
− | |||
− | |||
− | <source lang="mIRC"> | + | 1. You MUST avoid having spaces inside the parameters area. In this example, the spaces causes the strings not touching the $~ to be displayed: |
− | + | <source lang="mIRC">//echo -a $~null(abc, def , ghi) | |
− | + | returns: def , ghi) | |
− | + | //echo -a string: $~null(abc,def,ghi) | |
− | + | returns: $null | |
− | |||
− | |||
</source> | </source> | ||
− | + | 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: | |
− | |||
− | |||
− | |||
<source lang="mIRC"> | <source lang="mIRC"> | ||
− | echo - | + | //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) |
− | |||
</source> | </source> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Compatibility == | == Compatibility == | ||
− | Version added: | + | Version added: TBD |
== See Also == | == See Also == | ||
+ | {{mirc|optimization}} |