Token Simplifier [v1.2]

By jonesy44 on Apr 09, 2009

What does this do? For anyone who's a fairly good scripter, you will have used tokens ($gettok, etc.). This script simply takes a string and seperates it using the delimiter which is a character or ascii value. the results are then listed in a list box for you to view.

Helpful for? Sockets, "finding" information withing a string. Any other script which requires picking out sections of information

How to use it Simply run the command /gtk [string ascii/chrval]. The parts in [] are not required, but will add the string and val into the dialog once loaded. check screenshot for more information

Updates v1.0

  • Script released v1.1
  • Added command addon to start using script instantly
  • Bugfix with gtk.compile alias
  • Bugfix with gtk alias v1.2
  • Fixed scrollbar

Screenshot Image

; ===============
; Token Simplifier
; By:Jonesy44
; Version:1.2
; ===============
alias -l gtk.version return 1.2
alias gtk { 
  dialog $iif($dialog(gtk),-v,-m) gtk gtk
  if ($regex($1-,/^(.*) (\d{1,3}|.{1})$/)) { did -ra gtk 201 $regml(1) | did -ra gtk 202 $regml(2) | did -c gtk $iif($regml(2) isnum,302,301) | did -u gtk $iif($regml(2) isnum,301,302) | gtk.checksep | gtk.compile }
}
dialog gtk {
  size -1 -1 500 235
  title Token Simplifier $+([,Version,$chr(32),$gtk.version,])
  option pixels
  box ".:: INPUT ::.", 1, 5 5 490 70
  box ".:: OUTPUT ::.", 2, 5 85 490 145
  text "String:", 101, 15 27 60 13
  text "Seperator:", 102, 15 52 60 13
  text "Tokens:", 103, 15 108 60 13
  text "Ident:", 104, 15 203 60 13
  edit "", 201, 70 25 395 20, autohs
  edit "", 202, 188 49 40 20, autohs
  button "?", 203, 230 48 20 21
  button "?", 204, 467 24 20 21
  radio "ASCII", 301, 70 49 50 20
  radio "CharVal", 302, 125 49 60 20
  list 401, 70 105 415 100, hsbar
  edit "", 402, 70 201 385 20, read
  button "Cb.", 403, 455 200 30 21
}
on *:dialog:gtk:sclick:*: {
  if ($did == 203) { noop $input(The seperator defines the seperation between "tokens" only one character is required here. Either an ASCII Character or Character value $crlf $+ $crlf $+ ASCII: 1 character $chr(9) Any keyboard character $crlf $+ CharV: 1-3 digits $chr(9) Any number from 1 to 255,io,Token - Seperator Information) }
  if ($did == 204) { noop $input(The string stands for the line of text which is to be evaluated using the seperator,io,Token - String Information) }
  if ($did isnum 301-302) { gtk.checksep }
  if ($did == 401) { if ($did(401).seltext) { did -ra $dname 402 $+($chr(36),gettok,$chr(40),$did(201),$chr(44),$remove($gettok($did(401).seltext,1,32),[,]),$chr(44),$iif($did(gtk,301).state,$asc($did(gtk,202)),$did(gtk,202)),$chr(41)) } }
  if ($did == 403) { if ($did(402)) { clipboard $v1 | did -b $dname 403 | .timer 1 1 did -e $dname 403 } | else { noop $input(No text to copy. Please select a token from the list,wo,Token - Error) } }
}
on *:dialog:gtk:edit:*: {
  if ($did == 201) { if ($did(202)) { gtk.compile | did -ra $dname 402 $+($chr(36),gettok,$chr(40),$did(201),$chr(44),$remove($gettok($did(401).seltext,1,32),[,]),$chr(44),$iif($did(gtk,301).state,$asc($did(gtk,202)),$did(gtk,202)),$chr(41)) } }
  if ($did == 202) { gtk.checksep | if ($did(201)) { gtk.compile | did -ra $dname 402 $+($chr(36),gettok,$chr(40),$did(201),$chr(44),$remove($gettok($did(401).seltext,1,32),[,]),$chr(44),$iif($did(gtk,301).state,$asc($did(gtk,202)),$did(gtk,202)),$chr(41)) } }
}
alias -l gtk.checksep {
  if ($did(gtk,301).state) { if ($len($did(gtk,202)) > 1) { did -ra gtk 202 $left($did(gtk,202),1) } }
  elseif ($did(gtk,302).state) { if ($did(gtk,202) !isnum 1-255 || $len($did(gtk,202)) > 3) { did -ra gtk 202 $left($did(gtk,202),$calc($len($did(gtk,202)) - 1)) } }
  else { did -r $dname 202 }
}
alias -l gtk.compile {
  var %x = 1, %nt = $numtok($did(gtk,201),$iif($did(gtk,301).state,$asc($did(gtk,202)),$did(gtk,202))) | did -r gtk 401
  if (%nt) { while (%x <= %nt) { did -a gtk 401 $+([,%x,]) $gettok($did(gtk,201),%x,$iif($did(gtk,301).state,$asc($did(gtk,202)),$did(gtk,202))) | inc %x } }
  did -z gtk 401
}
Sign in to comment.
jonesy44   -  Dec 10, 2009

Haha yeah, it's quite noticable! lol. Hawkee has helped me along a lot has to be said! .NET is brilliant if you're not a Windows-hater, too many people pass on it because they are so single minded. I use .net in class so it's great for practice. PHP skills i developed on my own because i was into webdesign at the time.

If you need any help drop me an email sometime, be happy to help :)

 Respond  
Silo   -  Dec 10, 2009

You're very welcome. I especially like how you can actually see your skill evolve in a short time, going from sloppy basic stuff to beautiful complex scripts. I thought about making the shift to .net or PHP mainly because they seem quite similar to mIRC.

 Respond  
jonesy44   -  Dec 10, 2009

Two very kind comments indeed. Thank you Silo & Jethro_. I've moved on a bit since mIRC, onto VB.NET & PHP mainly these days though ;)

 Respond  
Jethro   -  Dec 10, 2009

Yes indeed, Jonesy44's work is praiseworthy. :-)

 Respond  
Silo   -  Dec 10, 2009

Hi, just joined the site, and noticed your name coming up a fair bit so I've just spent the last couple of hours reading your work.

Just wanted to say I think you do great work and I like your style of coding. Very clean and youo have some great ideas.

Keep up the good work!!

 Respond  
jonesy44   -  Aug 14, 2009

Thanks, glad it was helpful :)

 Respond  
HeatedHeart   -  Aug 12, 2009

Excellent, i was about to write something like this myself till i found yours, Great tutorial tool. +1 like and 9/10

 Respond  
jonesy44   -  May 08, 2009

thank you (:

 Respond  
eyiezinc   -  May 08, 2009

9/10 from me.

 Respond  
jonesy44   -  Apr 13, 2009

v1.2 fixed scrollbars

 Respond  
^Neptune   -  Apr 10, 2009

Just a thought, why not put a combo box, say, to the right of the radio boxes for like $addtok $deltok $findtok etc.

Then you could use it with all token identifiers. B)

 Respond  
jonesy44   -  Apr 10, 2009

Thanks (:

 Respond  
Kirby   -  Apr 09, 2009

Cool jonesy. :)

 Respond  
^Neptune   -  Apr 09, 2009

Good script for beginners and experts alike :)

Gets a thumbs up and an 8/10 from me.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.