This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

$gettok

Old posts that have not been replied to for several years.
Locked
J
Jag
Halfop
Posts: 90
Joined: Fri Sep 19, 2003 10:06 am

$gettok

Post by Jag »

how can i use $gettok in TCL?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

You can't, that's a mirc command.

http://www.tcl.tk/man/tcl8.3/TclCmd/contents.htm
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

what's gettok supposed to do ?
XplaiN but think of me as stupid
c
cerberus_gr
Halfop
Posts: 97
Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1

Post by cerberus_gr »

From the help file of the mIRC:

$gettok(text,N,C)
Returns the Nth token in text.

$gettok(a.b.c.d.e,3,46) returns c
$gettok(a.b.c.d.e,9,46) returns $null

You can also specify a range of tokens:

$gettok(a.b.c.d.e,2-,46) returns 2nd token onwards b.c.d.e
$gettok(a.b.c.d.e,2-4,46) returns tokens 2 through 4 b.c.d

You can specify a negative value for N.

Any help?
(I want both for 8.0 and 8.4 versions of tcl if anyone could help)
Thx
User avatar
CrazyCat
Revered One
Posts: 1286
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

seems to be [string] and
  • commands
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Use 'split' first, then 'lindex' or 'lrange' and 'join'.

Or you could try this proc

Code: Select all

proc gettok {txt n c} {
	set c [format %c $c]
	set txt [split $txt $c]
	if {[string match *- $n]} {
		scan $n[llength $txt] %i-%i a b
	} elseif {[string match -* $n]} {
		set b [llength $txt]
		set a [expr $b$n]
	} elseif {[string match *-* $n]} {
		scan $n %i-%i a b
	} {
		set a [set b $n]
	}
	join [lrange $txt $a $b] $c
}
A couple of things that are different from the mirc version:
n is zero-based (the first token is 0)
the proc returns an empty string when the mirc thing would return "$null"
Have you ever read "The Manual"?
c
cerberus_gr
Halfop
Posts: 97
Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1

Post by cerberus_gr »

I wanted to paste my code here, but now I'll feel bad, after your post user :oops: Thx :lol:
User avatar
CrazyCat
Revered One
Posts: 1286
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

he's a good scripter, isn't he?
c
cerberus_gr
Halfop
Posts: 97
Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1

Post by cerberus_gr »

He is the best. :P

CrazyCat thx for your help too. I wrote a code in this format, but it had some bugs :P :)
Last edited by cerberus_gr on Tue Dec 09, 2003 3:36 pm, edited 1 time in total.
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

CrazyCat wrote:he's a good scripter, isn't he?
indeed. user, wanna take a look at a 93kb voting script? :)
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

cerberus_gr wrote:I wanted to paste my code here, but now I'll feel bad, after your post user :oops: Thx :lol:
Don't be shy :) I didn't mean to make you feel bad. Sorry for that. Here's a proc to make it up to you.
A somewhat compressed version that does almost the same as the above proc, only twice as slow (due to uncompiled if statements) and more like mirc (i misunderstood the "A negative value" part of the mirc manual it seems):

Code: Select all

proc gettok {txt n c} {
	set c [format %c $c]
	set txt [split $txt $c]
	set i [llength $txt]
	if {[scan $n %i-%i a b]==2 ||\
	    [scan $n[expr {$i-1}] %i-%i a b]==2 ||\
	   ([scan $n %i a]&&[set b $a]!="")} {
		join [lrange $txt [expr {$a%$i}] [expr {$b%$i}]] $c
	}
}
...seriously though, posting your code would probably do you more good than harm. Very few of the people here bite coders that try their best. You might get some useful tips :)

I don't recommend using any of my two procs. Doing a little list/calculation/other text formatting work wouldn't hurt your coding skills, and it'd be alot faster. (depending on how you code, of course)
arcane wrote:wanna take a look at a 93kb voting script?
Compress it to about 20k first and I'll have a look :wink: (and use extremely short variable names or english words or I will hate reading your code :P)
Have you ever read "The Manual"?
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

user wrote:
arcane wrote:wanna take a look at a 93kb voting script?
Compress it to about 20k first and I'll have a look :wink: (and use extremely short variable names or english words or I will hate reading your code :P)
hehe... its 16kb zipped and i used english variable names :)
please? :mrgreen:
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Whew 93k! What is it, a voting script plus an operating system? Where is the link?
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

hehe... it's voting script, operating system and you can hack microsoft with it :)
give me your email and ill send it to you.
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
Locked