mIRC Homepage
Posted By: Indefinate Reverse Alphabet Script - 24/11/03 09:04 AM
Hey all, just a quickie...

I'm looking for a script, or to make one, that reverses the alphabet with an alias.

Example:

/lang abdefg

will create zyxwvu.

I tried this with no success:

code { return $replace($upper($1-),a,z,b,y,c,x,d,w,e,v,f,u,g,t,h,s,i,r,j,q,k,p,l,o,m,n,n,m,o,l,p,k,q,j,r,i,s,h,t,g,u,f,v,e,w,d,x,c,y,b,z,a) }

/lang //say $code($1-)

Any ideas? All that creates is abcdefg again frown

andy
Posted By: maffew Re: Reverse Alphabet Script - 24/11/03 02:38 PM
I think this is what you want

Example 1: //echo -s $reverse(r zn blfi mvd tlw olo)
Example 2: //echo -s $reverse(gsrh rh z xizkkb vcznkov)

Code:
/reverse {
  var %alpha = a;b;c;d;e;f;g;h;i;j;k;l;m;n;o;p;q;r;s;t;u;v;w;x;y;z
  var %n = 1,%m = $len($1-),%final.string,%mid,%letter
  while (%n <= %m) {
    %mid = $mid($1-,%n,1)
    if (%mid == $chr(32)) { %final.string = %final.string $+ $cr }
    elseif (%mid isletter) {
      %letter = $gettok(%alpha,$abs($calc($findtok(%alpha,%mid,1,59) - 27)),59)
      %final.string = %final.string $+ $iif(%mid isupper,$upper(%letter),%letter)
    }
    else { %final.string = %final.string $+ %mid }
    inc %n
  }
  return $replace(%final.string,$cr,$chr(32))
}
Posted By: Indefinate Re: Reverse Alphabet Script - 24/11/03 02:43 PM
I just tried it then... gave me this error:

* Invalid format: $mid (line 6083, aliases.nns)

andy
Posted By: Indefinate Re: Reverse Alphabet Script - 24/11/03 02:50 PM
Ok, just made it look like how you put it in the code quotes, and now it's giving me no error at all, but also isn't working frown

andy
Posted By: Indefinate Re: Reverse Alphabet Script - 24/11/03 03:09 PM
Yay! I got it...

I totally ignored the first part :tongue:

Now the next part... dialog to reverse it :tongue:

Edit: To reverse it, by that I mean, paste the reversed text into an input box, hit the button, and it spits out the real english in the other input box.

andy
Posted By: maffew Re: Reverse Alphabet Script - 25/11/03 04:12 AM
To use the script you will need the alias from my last post.

Type in the top editbox and click the reverse button your reversed text will appear in the bottom editbox.
You can have your text reversed in realtime just check the checkbox and type in the top editbox.
You can copy your results from the bottom editbox by clicking the copy button.

Code:
dialog reverse {
  title "Reverse Text by Maffew"
  size -1 -1 370 87
  option pixels
  edit "",1,5 5 360 23,autohs
  edit "",2,5 33 360 23,read,autohs
  button "&Close",100,315 63 50 20,ok
  button "&Reverse",101,195 63 60 20,default,disabled
  check "R&ealtime Reverse",102,5 65 110 20
  button "C&opy",103,260 63 50 20,disabled
}
on *:dialog:reverse:edit:1:{
  if ($did(102).state) { 
    did -b $dname 101
    if ($did(1,1) != $null) { 
      did -o $dname 2 1 $reverse($did(1,1))
      did -c $dname 2 1 $len($did(2,1)) $len($did(2,1))
      did -e $dname 103
    }
    else { 
      did -r $dname 2 
      did -b $dname 103
    }
    return
  }
  elseif ($did(1,1) != $null) { did -e $dname 101 }
  else { did -b $dname 101 }
}

on *:dialog:reverse:sclick:101:{
  if ($did(1,1) != $null) {
    did -o $dname 2 1 $reverse($did(1,1))
    did -e $dname 103
  }
  else { did -b $dname 101,103 }
}
on *:dialog:reverse:sclick:102:{
  if ($did(102).state) { did -b $dname 101 }
  elseif ($did(1,1) != $null) { did -e $dname 101,103 }
  else { did -b $dname 101 }
}
on *:dialog:reverse:sclick:103:{
  if ($did(2,1) != $null) { clipboard $ifmatch }
  else { did -b $dname 103 }
}

menu status,channel,menubar {
  -
  $iif($dialog(reverse),$style(2)) Reverse Text:{ dialog -m reverse reverse }
  -
}
© mIRC Discussion Forums