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.

Odd little error

Old posts that have not been replied to for several years.
Locked
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Odd little error

Post by Weirdo »

Hello

Well, i decided to use the looping and file picking up code i learnt, thanks to you guys whilst making my rules script, and use it to replace the hard coded variables in my url storage and favourites scripts. But...
[00:04:46] <Natsuki-Chan> [00:04] Tcl error [pub:stars]: can not find channel named "text/stars.file"
"text/stars.file" is equal to stars(path) in the script, so what is wrong? Is it just my typoing syntax again?

Code: Select all

bind pub - !stars pub:stars
proc pub:stars {nick host hand chan text} {
	global runchan stars
	if {$chan == $runchan} {
		if {[file exists $stars(path)]} {
			putlog "File Exists, loading"
			set stars(file) [open $stars(path) r]
				while {![eof $stars(path)]} {
				catch {set stars(text) [gets $stars(file)]}
				puthelp "Notice $nick :$stars(text)"
				}
			catch {close $stars(file)}
			putlog "!$nick - $hand! Stars url List"
		} {
			putlog "Unable to Open $stars(path), file does not exist"
			puthelp "Notice $nick :An Error has occured, please contact the Administrator"
		}
	} {
		putlog "Unable to run !stars trigger, incorrect channel"
		puthelp "Notice $nick :This command is not avaliable on this channel"
	}
}
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Before you can use file functions like eof, gets, close, etc, you have to open the file. Use the 'open' command. It gives you a handle to the open file. Then you use that handle for the file functions.
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

set stars(file) [open $stars(path) r]

i thou8ght that line loadfed it
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Yes, you are correct, it does open the file.

However, it then remains that you are passing the wrong arguments to other functions.

Look at the "eof" command you have used.

You are passing it the file name, not the channel name (Tcl calls then channel names. This is due to the fact, it's a channel through which a Tcl script can talk to a file).
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

set rulefile [open $rulepath r]
while {![eof $rulefile]} {

Thats the code i was basing it off, looks like it misread it completely :P

thanks as always ppslim
Locked