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.

vars and inis

Old posts that have not been replied to for several years.
g
gk^
Halfop
Posts: 70
Joined: Sun Jul 28, 2002 6:23 am
Location: Stockholm, Sweden
Contact:

vars and inis

Post by gk^ »

Code: Select all

set prtt [ ini_read nfo.ini $hand foba ]
or

Code: Select all

set prtt { ini_read nfo.ini $hand foba }
I uses inidb.tcl and the line with ini_read is right.. But it doesnt start the proc of ini_read :(

What do he want to do? -> I want to set the value of foba (from nfo.ini) into the var "prtt" but it doesnt work :(
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The first quote is the most correct one, though yu should not use white space at the begining of the command (I have never tested this ti see it it's faulse, but it's the most common and standard method)

Code: Select all

set prtt [ini_read nfo.ini $hand foba]
Beyond this, what errors do you get.
g
gk^
Halfop
Posts: 70
Joined: Sun Jul 28, 2002 6:23 am
Location: Stockholm, Sweden
Contact:

Post by gk^ »

Code: Select all

bind pubm - ti.test* ini_las

proc ini_las {nick uhost hand chan arg} {
   set prtt [ini_read nfo.ini $hand foba]
   puthelp "privmsg $chan :nfo is $prtt"
}

Thats the whole code.. But I just get "[ +ti^ ] nfo is ;"
And the value of foba is 2555 in the inifile..
No error msgs, no nothing... :|
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Is the INI file formatted correctly, and are you using the correct values.

To get value from a INI file, you have to know its topic and name.

You can't simply use
item1=value1
item2=value2
INI files are formatted like
[topic1]
item1=value1
item2=value2
[topic2]
item1=value1
item2=value2
You are passing the value of the $hand variable as the topic (I presume, i have not looked at the ini parser yet). Are you sure this is what you should be passing.
g
gk^
Halfop
Posts: 70
Joined: Sun Jul 28, 2002 6:23 am
Location: Stockholm, Sweden
Contact:

Post by gk^ »

I found the problem.. It is that $hand == "*" instead of my handle...

Why is it like this.. it should know who I am couse I am the onlyone with z flag and I have that as a statement in my bind
g
gk^
Halfop
Posts: 70
Joined: Sun Jul 28, 2002 6:23 am
Location: Stockholm, Sweden
Contact:

Post by gk^ »

hmm.. wait.. I got an idea.. yeah I know it isnt that common :P

ini_read doesnt have $hand .. could it be that? Do I have to add a global in the ini_read proc or isnt this the thing?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Code: Select all

bind pubm - ti.test* ini_las 

proc ini_las {nick uhost hand chan arg} { 
   set prtt [ini_read nfo.ini $hand foba] 
   puthelp "privmsg $chan :nfo is $prtt" 
}
That is what you posted.

There is no z flag involved, and thyis can be triggered by anyone by typeing "ti.text" on a channel.

When $hand == * is true, it means that eggdrop doesn't recognise you, even if it should.

This is because, none of the hostmasks in your ".whois" matches you.
g
gk^
Halfop
Posts: 70
Joined: Sun Jul 28, 2002 6:23 am
Location: Stockholm, Sweden
Contact:

Post by gk^ »

oh.. sorry.. I didnt post my new version.. changed alot :P

But i think i found the problem.. Thanx
g
gk^
Halfop
Posts: 70
Joined: Sun Jul 28, 2002 6:23 am
Location: Stockholm, Sweden
Contact:

kind of new stuff

Post by gk^ »

Code: Select all

bind dcc z nfo dcc:nfo

proc dcc:nfo {hand text} {
   putlog "stage - done"
}
I get
Tcl error [dcc:nfo]: called "dcc:nfo" with too many arguments
But I need handle and text... Why do I get this error?
g
gk^
Halfop
Posts: 70
Joined: Sun Jul 28, 2002 6:23 am
Location: Stockholm, Sweden
Contact:

Post by gk^ »

for some reason I needed idx there too...
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

In an earlier post today, I went in depth (depth, not english :P ) into this area.

Eggdrop will pass arguments to a procedure, which you need to catch. This is done witht he first line of the proc command.

The problem with the above script, is that it expects eggdrop to understand exactly how it is programmed, and send what you want.

This is not how it works. tcl-commands.doc tells you what eggdrop will send, and you are expected to capture what it sends.

You may only need 2 of the 3 arguments sent, regardless of this, it will send all 3.
g
gk^
Halfop
Posts: 70
Joined: Sun Jul 28, 2002 6:23 am
Location: Stockholm, Sweden
Contact:

new => the real script

Post by gk^ »

Code: Select all

bind dcc z ftp dcc:ftp

proc dcc:ftp {handle idx text} {
   putlog "stage 0 - done"
   if {[string tolower [lindex $text 1]] == "update"} {
      putlog "stage 1 - done"
      if {[string tolower [lindex $text 2]] == ""}
      putlog "stage 2 - done"
      puthelp "putdcc $idx Usage of update => .ftp update <ip/user/pass/port>"
   } elseif {[string tolower [lindex $text 2]] == ""} {
      putlog "stage 3 - done"
      if {[string tolower [lindex $text 3]] == ""} {
         putlog "stage 4 - done"
         puthelp "putdcc $idx Usage of update ip => .ftp update ip <the.new.ip>"
      } elseif {[string tolower [lindex $text 3]] == "ip"} {
         putlog "stage 5 - done"
         ini_write ftpnfo.ini $hand ip [string tolower [lindex $text 3]]
      } elseif {[string tolower [lindex $text 2]] == "user"} {
         putlog "stage 6 - done"
         ini_write ftpnfo.ini $hand user [string tolower [lindex $text 3]]
      } elseif {[string tolower [lindex $text 2]] == "pass"} {
         putlog "stage 7 - done"
         ini_write ftpnfo.ini $hand pass [string tolower [lindex $text 3]]
      } elseif {[string tolower [lindex $text 2]] == "port"} {
         putlog "stage 8 - done"
         ini_write ftpnfo.ini $hand port [string tolower [lindex $text 3]]
      }
      putlog "stage 9 - done"
   }
   putlog "stage 10 - done"
}
As you see I am trying to se how faar the codes goes though using alot of putlog.. But it doesnt even come to putlog stage 0....

If I type .ftp in the telnet/dcc chat I get
[14:38] Tcl error [dcc:ftp]: wrong # args: no script following "{[string tolower [li" argument
So I really cant find out whats wrong...
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Re: new => the real script

Post by ppslim »

Code: Select all

bind dcc z ftp dcc:ftp

proc dcc:ftp {handle idx text} {
   putlog "stage 0 - done"
   if {[string tolower [lindex $text 1]] == "update"} {
      putlog "stage 1 - done"
      if {[string tolower [lindex $text 2]] == ""}
      putlog "stage 2 - done"
      puthelp "putdcc $idx Usage of update => .ftp update <ip/user/pass/port>"
   } elseif {[string tolower [lindex $text 2]] == ""} {
      putlog "stage 3 - done"
      if {[string tolower [lindex $text 3]] == ""} {
         putlog "stage 4 - done"
         puthelp "putdcc $idx Usage of update ip => .ftp update ip <the.new.ip>"
      } elseif {[string tolower [lindex $text 3]] == "ip"} {
         putlog "stage 5 - done"
         ini_write ftpnfo.ini $hand ip [string tolower [lindex $text 3]]
      } elseif {[string tolower [lindex $text 2]] == "user"} {
         putlog "stage 6 - done"
         ini_write ftpnfo.ini $hand user [string tolower [lindex $text 3]]
      } elseif {[string tolower [lindex $text 2]] == "pass"} {
         putlog "stage 7 - done"
         ini_write ftpnfo.ini $hand pass [string tolower [lindex $text 3]]
      } elseif {[string tolower [lindex $text 2]] == "port"} {
         putlog "stage 8 - done"
         ini_write ftpnfo.ini $hand port [string tolower [lindex $text 3]]
      }
      putlog "stage 9 - done"
   }
   putlog "stage 10 - done"
}

Code: Select all

if {[string tolower [lindex $text 2]] == ""}
This is the incorrect line that cuases the error

However, the logic in use is genraly flawed, unless it is due to the error above.
g
gk^
Halfop
Posts: 70
Joined: Sun Jul 28, 2002 6:23 am
Location: Stockholm, Sweden
Contact:

Post by gk^ »

I changed it.. And got a diffrent error.. so I rewrote alot of the code and it turned out to this:

Code: Select all

bind dcc z ftp dcc:ftp

proc dcc:ftp {handle idx text} {
   putlog "stage 0 - done"
   if {[string tolower [lindex $text 1]] == ""} {
      putlog "stage 2 - done"
      puthelp "putdcc $idx Usage of ftp => ftp <ip/user/pass/port> <value>"
   } elseif {[string tolower [lindex $text 1]] == "ip"} {
      if {[string tolower {lindex $text 2]] == ""} {
         puthelp "putdcc $idx Usage of .ftp => .ftp ip <the.new.ip>"
      } else {
          putlog "stage 5 - done"
          ini_write ftpnfo.ini $hand ip [string tolower [lindex $text 3]]
      }
   } elseif {[string tolower [lindex $text 1]] == "user"} {
      if {[string tolower {lindex $text 2]] == ""} {
         puthelp "putdcc $idx Usage of .ftp => .ftp user <the.new.username>"
      } else {
         putlog "stage 6 - done"
         ini_write ftpnfo.ini $hand user [string tolower [lindex $text 3]]
      }
   } elseif {[string tolower [lindex $text 1]] == "pass"} {
      if {[string tolower [lindex $text 2]] == ""} {
         puthelp "putdcc $idx Usage of .ftp => .ftp pass <the.new.password>"
      } else {
         putlog "stage 7 - done"
         ini_write ftpnfo.ini $hand pass [string tolower [lindex $text 3]]
      }
   } elseif {[string tolower [lindex $text 1]] == "port"} {
      if {[string tolower [lindex $text 2]] == ""} {
         puthelp "putdcc $idx Usage of .ftp => .ftp port <the.new.portnumber>"
      } else {
         putlog "stage 8 - done"
         ini_write ftpnfo.ini $hand port [string tolower [lindex $text 3]]
      }
   }
}
But I still got an error :( .. And I dont know how to fix it..


Error msg:
[16:04] missing close-brace
while executing
"proc dcc:ftp {handle idx text}"
(file "scripts/save.tcl" line 3)
invoked from within
"source scripts/save.tcl
"
Thanx for help
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

You need to keep reading over the script a few hundred times, to spot small mistakes like this one.

Code: Select all

if {[string tolower {lindex $text 2]] == ""} {
Locked