| | 
| 
| 
|  |  
| 
2big
 |  
| 2big | 
Well, I've been trying very hard to figure out how to reverse the text someone says using the  on *:text:  command, along with tokens, text identifiers, etc.
 But I still can't seem to figure it out.  What I mean is, I'm trying to write a script to reverse what anybody says.  Anyway, any help would be appreciated. Thanks in advance.
 
 Example of what I'm talking about:
 
 <JohnSmith> Hey guys, how are you
 <ReverserScript> uoy era woh ,syug yeH
 |  |  |  
| 
| 
|  |  
| 
pheonix
 |  
| pheonix | 
alias reverse {
  var %x,%i = $len($1-)
  while (%i) {
    %x = %x $+ $replace($mid($1-,%i,1),$chr(32),_)
    dec %i
  }
  return $replace(%x,_,$chr(32))
}
//echo -a $reverse(text) however that will strip comma's(",")    |  |  |  
| 
| 
|  |  
| 
2big
 |  
| 2big | 
Thank you so much, it works great.  |  |  |  
| 
| 
|  |  
| 
pheonix
 |  
| pheonix | 
np    |  |  |  
| 
| 
|  |  
| 
Joined:  Feb 2003 Posts: 2,737 Hoopy frood |  
|   Hoopy frood Joined:  Feb 2003 Posts: 2,737 | 
Try this thread  for a related discussion about "reverse text" some examples if nicer/ faster methods. It's worth a read if you're interested in learning different scripting styles. - Raccoon  |  |  |  
| 
| 
|  |  
| 
2big
 |  
| 2big | 
Thanks for the link.  I just realized that whenever I reverse the text of someone, it keeps the control codes.  How would I incorperate the $strip identifier in there?  |  |  |  
| 
| 
|  |  
| 
pheonix
 |  
| pheonix | 
if ur using my one: 
alias reverse {  
  var %x,%i = $len($1-)  
  while (%i) {    
    %x = %x $+ $replace($mid($1-,%i,1),$chr(32),_)    
    dec %i  
  } 
  return $strip($replace(%x,_,$chr(32)))
}
 |  |  |  
| 
| 
|  |  
| 
2big
 |  
| 2big | 
That still didn't get rid of the numbers that show up with the codes.  |  |  |  
| 
| 
|  |  
| 
Joined:  Feb 2003 Posts: 2,737 Hoopy frood |  
|   Hoopy frood Joined:  Feb 2003 Posts: 2,737 | 
You'll want to $reverse($strip($1-)) instead, so it removes the control codes before reversing them... then it will remove the numbers associated with color codes too.  |  |  |  
| 
| 
|  |  
| 
codemastr
 |  
| codemastr | 
replacing a space with an _ is a bad idea. What if I want to reverse "this_is_a_test" you've just changed all those _ to spaces giving a result of "tset a si siht" which is incorrect. Instead, you should take advantage of the fact that mIRC does allow you to have a space at the beginning of a variable, just not at the end and therefore you can use: 
alias reverse { 
  var %x,%i = 1 
  while ($mid($1-,%i,1)) {
    %x = $ifmatch $+ %x
    inc %i 
  }  
  return $strip(%x)
}
That is obviously going to be much faster since there are no $replace's involved.   |  |  |  
| 
| 
|  |  
| 
rela
 |  
| rela | 
If you don't replace the space by another character it will leave the space out in the resersed text, I always replace space with $chr(1)   |  |  |  
| 
| 
|  |  
| 
Joined:  Dec 2002 Posts: 3,015 Hoopy frood |  
|   Hoopy frood Joined:  Dec 2002 Posts: 3,015 | 
His script works without replacing space with anything, although personally I would $strip first.. |  |  |  
| 
| 
|  |  
| 
Joined:  Feb 2003 Posts: 2,737 Hoopy frood |  
|   Hoopy frood Joined:  Feb 2003 Posts: 2,737 | 
Yes, you will $strip first, but the trick behind the space retention is the fact that you're adding to the beginning of the variable.. not the end.  (demonstrates for rela)
 var %s = $chr(32) $+ %s  (works)
 var %s = %s $+ $chr(32)  (does not)
 
 THAT is the trick behind this method.
 Me personally, I prefer binvars.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Dec 2002 Posts: 292 Fjord artisan |  
|   Fjord artisan Joined:  Dec 2002 Posts: 292 | 
Hi, i read this thread some days ago, and i remember seeing a reverse text script somewhere, been trying for days to remember where, anyways i didnt find the site, but i found the script on one of my CD's, so i must of saved it ages ago.  To the origainal poster, you could always use this code instead, if you havent got anywhere else 
; Reversing words?
; It started when my friend and I decided to talk backward.
; I found it annoying to rephrase my words manually so I wrote this.
; It's not new but I never say it will never work! :)
; Perhaps the way I handle it may not be the best, but oh well, I tried.
; Author: xiao-wen-zi
; Email: smallmoskito@yahoo.com
; Date: 1st January 2002
;
; Usage
;
; /rev <text> returns <echo | say> result
;
; Example
; Input: /rev hi?
; Output: ?ih
;
; $rev(text) returns result
;
;/revd brings up the GUI
alias rev { 
  ;declare variables
  ;%c stores the total number of words found
  var %c $calc($iif($count($$1-,$chr(32)),$ifmatch,0) +1) , %v, %f
  ;words loop - begining from the last word of the sentence to the first
  while ( %c > 0) {
    %f = $gettok($$1-,%c,32) | var %i $len(%f) , %t 
    ;letters loop - begining from the last letter of the word to the first (obviously)
    while (%i) { %t = $+(%t,$right($left(%f,%i),1)) | dec %i }
;adds the reconstructed words to the end of the the rest
    dec %c | %v = %v %t
  }
  ;if is ident., it'll return the result
  if ($isid) { return %v }
  ;if connected to a server it'll say the result
  $iif($server,say,echo) %v
}
;
; Dialog
;
alias revd return $dialog(rev,rev,-1)
dialog rev {
  size -1 -1 200 50
  option dbu
  title "Reverse words?"
  edit "Insert text here",2,5 5 192 12, autohs
  edit "",3,5 20 192 12, read autohs
  button "&Copy reversed words",4,5 36 60 12, default
  button "E&xit",1,166 36 30 12, okay default
}
on *:dialog:rev:*:*: {
  var %e $devent , %n $dname , %d $did
  if (%e == init) { did -fa %n 2 $chr(32) }
  if (%e == edit) && (%d == 2) { did -o %n 3 1 $rev($did(2)) } 
  if (%e == sclick) && (%d == 4) { clipboard $did(3) }
}
Checked and tested on mIRC V6.1 (it works) To Parabrat and/or Hammer or other moderatorsI hope you dont mind me pasting the whole code, but i think it was a scriptlet i downlaoded, and just kept on my harddrive and backed up to a cd later    /me gives Parabrat a whole bag of choccy chips cookies  or whatever is yer favorite kind    ShadowDemon    |  |  |  
| 
| 
|  |  
| 
Joined:  Feb 2003 Posts: 2,737 Hoopy frood |  
|   Hoopy frood Joined:  Feb 2003 Posts: 2,737 | 
I think we've already concluded that there are MUCH faster, cleaner, better methods than the one you just posted.     |  |  |  
| 
| 
|  |  
| 
BoredNL
 |  
| BoredNL | 
although faster, this solution is buggy the way it is. The text needs to be stripped before being processed, not after, otherwise you'll be left with the color code numbers in the result or loss of text if the color code has numbers behind it.   Here's the fix: 
alias reverse { var %x,%i = 1,%s = $strip($1-)
  while ($mid(%s,%i,1)) { %x = $ifmatch $+ %x |  inc %i }
  return %x }
This script is still not perfect though, as it will shorten multiple spaces to 1 space and all white space before and after the text will be eliminated.  |  |  |  
| 
| 
|  |  
| 
Joined:  Dec 2002 Posts: 292 Fjord artisan |  
|   Fjord artisan Joined:  Dec 2002 Posts: 292 | 
yeah i know, it was a few days too late, but i thought you never know, there maybe someone else wanting a reverse text script, who doesnt know where to begin, and this might give them an idea.   |  |  |  | 
 |