alias scramble {
[color:green]; Since we will be writing to files, remove these characters if they exist: \ / : * ? " < > |[/color]
var %s = $remove($1-,$chr(34),$chr(42),$chr(47),$chr(58),$chr(60),$chr(62),$chr(63),$chr(92),$chr(124))
var %i = 1
[color:green]; Pass each word onto scramble.write[/color]
while (%i <= $numtok(%s,32)) {
if (%i == $numtok(%s,32)) {
set %scramble.end $true
}
scramble.write $gettok(%s,%i,32)
inc %i
}
}
alias scramble.write {
[color:green]; Get the middle characters of the current word[/color]
var %mid = $mid($1,2,$calc($len($1)-2))
var %i = 1
var %scrambled
[color:green]; Write the middle characters of the current word to a file[/color]
while (%i <= $len(%mid)) {
write $+(scramble,$1,.txt) $mid(%mid,%i,1)
inc %i
}
[color:green]; Randomly read the charcters back from the file and remove them after use[/color]
while ($lines($+(scramble,$1,.txt)) > 0) {
%scrambled = %scrambled $+ $read($+(scramble,$1,.txt))
write -dl $+ $readn $+(scramble,$1,.txt)
}
[color:green]; Remove the temp file for the current word[/color]
.remove $+(scramble,$1,.txt)
[color:green]; After scrambling the current word, store it in a variable, continue adding subsequent words separated by a period[/color]
%scramble = %scramble $+ $chr(46) $+ $+($left($1,1),%scrambled,$right($1,1))
[color:green]; Once the last word has been scrambled, send the entire scrambled message to the active window.
; The period separator from the previous line is replaced with a space.[/color]
if (%scramble.end) {
msg $active $replace(%scramble,$chr(46),$chr(32))
unset %scramble*
}
}