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.

Two scripts work seperately but not together

Help for those learning Tcl or writing their own scripts.
Locked
a
anon
Voice
Posts: 2
Joined: Sun Dec 09, 2007 3:42 pm

Two scripts work seperately but not together

Post by anon »

I have these two scripts, both work fine when only 1 is loaded. When both are loaded only the last one loaded works. Any ideas?
pre.tcl

Code: Select all

package require mysqltcl

set db_handle [mysqlconnect -host localhost -user root -password pass -db pre]

bind pub - !NEW pre_proc

set _version 0.2

proc insert {section name timestamp} {
	global db_handle
	set sql "INSERT INTO releases VALUES (null, '$section', '$name', '$timestamp', null, null, '0', null)"
	
	set result [mysqlexec $db_handle $sql]

	if {$result == 1} {
		return 1
	} else {
		putlog "FAILURE - $sql"
		return 0
	}
}

proc pre_proc { nick host handle channel text } {
	set section [lindex [split $text] 1]
	set release [lindex [split $text] 3]
	set timestamp "[lindex [split $text] 4] "
	append timestamp [lindex [split $text] 5]
	putlog "PRE $release"
	set result [insert $section $release $timestamp]
	if {$result == 1} {
		puthelp "PRIVMSG #lfs-pre :PRE in $section :: $release $timestamp"
	}

}

putlog "pre.tcl v$_version loaded."
fix.tcl

Code: Select all

package require mysqltcl
set db_handle [mysqlconnect -host localhost -user root -password pass -db pre]
bind pub - !FIX fix_proc

set _version 0.2

proc fix_size {name size files} {
	global db_handle
	set sql "UPDATE releases SET size='$size', files='$files' WHERE name='$name'"
	set result [mysqlexec $db_handle $sql]
	
	if {$result == 1} {
		return 1
	} else {
		putlog "SIZE FAILURE - $sql"
		return 0
	}
}

proc fix_proc { nick host handle channel text } {
	putlog "FIX [lindex [split $text] 1]" 
	set fixtype [lindex [split $text] 0]
	if {$fixtype == "size"} {
		fix_size [lindex [split $text] 1] [lindex [split $text] 2] [lindex [split $text] 3]
	} 
}
putlog "fix.tcl v$_version loaded."
I have also tried putting them in the same file and that doesn't work either.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Maybe try namespace?
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Looks like a warez script..
a
anon
Voice
Posts: 2
Joined: Sun Dec 09, 2007 3:42 pm

Post by anon »

Alchera wrote:Maybe try namespace?
Creating a namespace around each existing script produced the same results.

EDIT: I have simplified it as much as possible and this still won't trigger both. Only the last one. Both putlogs are outputted so it is going though all of it.

Code: Select all

bind pub - !FIX fix::fix_proc
bind pub - !NEW pre::pre_proc

namespace eval fix {
	namespace export fix_proc
	set _version 0.3
	proc fix_proc { nick host handle channel text } {
		putlog "FIX" 
	}
	
	putlog "fix v$_version loaded."
}

namespace eval pre {
	namespace export pre_proc
	set _version 0.1

	proc pre_proc { nick host handle channel text } {
		putlog "PRE"
	}

	putlog "pre v$_version loaded."
}
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Warez is not supported on this forum.
Locked