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.

Argument Separation

Help for those learning Tcl or writing their own scripts.
Post Reply
g
ghostscript
Voice
Posts: 13
Joined: Wed Feb 08, 2006 4:08 pm
Location: unknown
Contact:

Argument Separation

Post by ghostscript »

I am running Eggdrop 1.4 and am trying to design a simple script that takes the input "!taken abcde edcba" and serparates it into varibles equal abcde and edcba respectively.

Code: Select all


        set $i [string first " " $args 0]
        set $j [string length $args]
        set $tfirst [string range $args 0 [$i-1]]
        set $tsecond [string range $args [$i+1] $j]

Any help would be most appicated.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

you need to learn about using Tcl lists (what you want is usually done using [lindex])
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
g
ghostscript
Voice
Posts: 13
Joined: Wed Feb 08, 2006 4:08 pm
Location: unknown
Contact:

Post by ghostscript »

Tried changing to using lindex. Looks like it should work but i get empty returns now. Is there something I'm doing wrong here?

Code: Select all

        set tfirst [lindex $args 0]
        set tsecond [lindex $args 1]
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

make sure you are getting in $args what you expect to get and use [split] on it
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
g
ghostscript
Voice
Posts: 13
Joined: Wed Feb 08, 2006 4:08 pm
Location: unknown
Contact:

Really, Thanks!

Post by ghostscript »

That worked wonders. Thank you very much. ~bows~
Post Reply