mIRC Homepage
Posted By: AaronL partial shaked text - 05/01/06 12:22 PM
Hi all.
I'm not sure its possible so here's my question:

i like to shake each word ik type but leaving the first and last letter where it is. Example:

i type: hello people and goodmorning
shown must be: hlelo polple and godoromning

first and last letter of hello is tesame and this goes for each word. Its not necessary to exact change it to hlelo but may be hlleo aswel thus changing random letters but not the first and last.

thanxs for reactions..
Aaron
Posted By: schaefer31 Re: partial shaked text - 05/01/06 01:51 PM
Give this a try...

Code:
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*
  }
}


Useage: /scramble message
Posted By: AaronL Re: partial shaked text - 05/01/06 06:51 PM
wow, i'm truly impressed.

This is exactly what i ment. Thank you so much schaefer31

if i had a hat i took it off.

greetz
Aaron
Posted By: FiberOPtics Re: partial shaked text - 05/01/06 07:28 PM
There's no reason whatsoever to be writing to a file, it's simply not needed.

I didn't make this code because I don't have time, neither have I checked it out but it should work, it's from a fella named zef:

Code:
alias dez {
  tokenize 32 $strip($1-)
  var %dez
  while ($1) {
    var %a $len($1), %b 2, %w, %d, %c
    while (%b < %a) {
      %c = $r(2,$calc(%a - 1))
      while ($findtok(%d,%c,32)) %c = $r(2,$calc(%a - 1))
      %d = %d %c
      %w = $+(%w,$mid($1,%c,1))
      inc %b
    }
    %dez = %dez $+($left($1,1),%w,$iif(%a > 1,$right($1,1)))
    tokenize 32 $2-
  }
  return %dez
}


; $dez(does this work?) --> deos this wrko?
© mIRC Discussion Forums