mIRC Home    About    Download    Register    News    Help

Print Thread
#44550 28/08/03 01:16 AM
Joined: Aug 2003
Posts: 29
2
2big Offline OP
Ameglian cow
OP Offline
Ameglian cow
2
Joined: Aug 2003
Posts: 29
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

#44551 28/08/03 01:23 AM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
Code:
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(",") frown


new username: tidy_trax
#44552 28/08/03 01:37 AM
Joined: Aug 2003
Posts: 29
2
2big Offline OP
Ameglian cow
OP Offline
Ameglian cow
2
Joined: Aug 2003
Posts: 29
Thank you so much, it works great.

#44553 28/08/03 01:40 AM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
np smile


new username: tidy_trax
#44554 28/08/03 01:47 AM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
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


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#44555 28/08/03 01:55 AM
Joined: Aug 2003
Posts: 29
2
2big Offline OP
Ameglian cow
OP Offline
Ameglian cow
2
Joined: Aug 2003
Posts: 29
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?

#44556 28/08/03 02:10 AM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
if ur using my one:
Code:
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)))
}


new username: tidy_trax
#44557 28/08/03 02:46 AM
Joined: Aug 2003
Posts: 29
2
2big Offline OP
Ameglian cow
OP Offline
Ameglian cow
2
Joined: Aug 2003
Posts: 29
That still didn't get rid of the numbers that show up with the codes.

#44558 28/08/03 02:58 AM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
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.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#44559 28/08/03 09:03 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
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:

Code:
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.

#44560 29/08/03 01:35 PM
Joined: Jan 2003
Posts: 45
R
Ameglian cow
Offline
Ameglian cow
R
Joined: Jan 2003
Posts: 45
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)


@#botwars @Kreynet
#44561 29/08/03 01:43 PM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
His script works without replacing space with anything, although personally I would $strip first..

#44562 29/08/03 08:04 PM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
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.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#44563 30/08/03 12:29 PM
Joined: Dec 2002
Posts: 295
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Dec 2002
Posts: 295
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

Code:
; 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 &lt;text&gt; returns &lt;echo | say&gt; 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 &gt; 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 "&amp;Copy reversed words",4,5 36 60 12, default
  button "E&amp;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) &amp;&amp; (%d == 2) { did -o %n 3 1 $rev($did(2)) } 
  if (%e == sclick) &amp;&amp; (%d == 4) { clipboard $did(3) }
}


Checked and tested on mIRC V6.1 (it works)

To Parabrat and/or Hammer or other moderators
I 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 wink

ShadowDemon


Never argue with an idiot...they'll drag you down to their level and beat you up with experience
#44564 31/08/03 12:11 PM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
I think we've already concluded that there are MUCH faster, cleaner, better methods than the one you just posted. crazy


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#44565 31/08/03 11:23 PM
Joined: Jan 2003
Posts: 154
B
Vogon poet
Offline
Vogon poet
B
Joined: Jan 2003
Posts: 154
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:
Code:
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.


- Wherever you go there you are.[color:lightgreen]
#44566 01/09/03 11:32 PM
Joined: Dec 2002
Posts: 295
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Dec 2002
Posts: 295
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.


Never argue with an idiot...they'll drag you down to their level and beat you up with experience

Link Copied to Clipboard