alias randletter {
[color:#006600]
; Make sure the first character of each of the inputs are letters.
; [/color]
if $$1 !isletter || $$2 !isletter {
[color:#006600]
; Echo an appropriate error message patterned after mIRC's own error messages.
; [/color]
echo $color(info) -esti * Invalid parameters: $randletter
[color:#006600]
; Halt the script in the error condition
; [/color]
halt
}
[color:#006600]
; Start with a known non-letter.
; [/color]
var %rand = 33
[color:#006600]
; Repeatedly pick random characters until one is in the range specified and a letter.
; [/color]
while $chr(%rand) !isletter {
[color:#006600]
; Find a random value in the range specified (plus one for error correction).
; [/color]
var %rand = $rand($asc($1), $calc($asc($2) + 1)) }
[color:#006600]
; Correct for the $rand error, if necessary, if $2 is overshot by 1.
; [/color]
if %rand == $calc($asc($2) + 1) {
[color:#006600]
; Return the first character of the range if we overshoot.
; [/color]
return $1
}
[color:#006600]
; Repeat until a valid letter is found. [/color]
}
[color:#006600]
; Return the character found.
; [/color]
return $chr(%rand)
}