From WikiChip
$ord Identifier - mIRC
Commands & Identifiers
Basics
Events
Matching Tools
Data Storage
Control Structures
GUI Scripting
Sockets
Advanced Scripting
Additional Resources
Security
Other
$ord appends "st", "nd", "rd", or "th" as appropriate, to the number N.
Synopsis
$ord(N)
Parameters
- N - The number
Properties
None
Example
//echo -a $ord(3)
Rules:
- If number ends with 11 12 or 13, suffix is th
- If number ends with 1 the suffix is st
- If number ends with 2 the suffix is nd
- If number ends with 3 the suffix is rd
- All other numbers end with th, including zero.
This code shows that following these 5 rules produces the same output as letting mIRC calculate the Ordinal. It repeatedly hashes a string consisting of the previous hash combined with the $ord of the next number, and both methods produce the identical hash:
//var %a , %a2 , %i 0 | while (%i isnum 0-999) { if ($istok(11 12 13,$right(%i,2),32)) var %ord th | elseif ($findtok(1 2 3,$right(%i,1),1,32)) var %ord $gettok(st nd rd,$v1,32) | else var %ord th | var %a $sha1(%a %i $+ %ord) , %a2 $sha1(%a2 $ord(%i)) | inc %i } | echo -a %a , %a2
For fractions, the $ord uses the last 1 or 2 digits of the fraction.
//echo -a $ord(2.1) and $ord($pi)
Compatibility
Added: mIRC v5.61
Added on: 23 Sep 1999
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.