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.

list

Old posts that have not been replied to for several years.
Locked
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

list

Post by caesar »

# binds
bind pub n .files files:list

# stuff
set ls(dir) "files"
set ls(pattern) "*.txt"

# files list
proc files:list {nick host hand chan arg} {
global ls
catch { glob $ls(dir)/$ls(pattern) } files
if {[lrange "$files" 0 4] == "no files matched glob pattern"} {
putserv "PRIVMSG $chan :Can't find any files ($ls(pattern)) in \"$ls(dir)\" dir."
return }
foreach script $files {
putserv "PRIVMSG $chan :[string range $script [expr [string length $ls(dir)]+1] end]"
}
}

How to make it look in all the dirs from the $ls(dir)? The dir files/ has a tmp/ dir in it and in the tmp/ dir is an txt file and shoud be found.
Once the game is over, the king and the pawn go back in the same box.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Or an alternative to that is to read all the dirs name then to lookin each dir for the files. Any sugestions?
Once the game is over, the king and the pawn go back in the same box.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

# binds
bind pub n .dirs dirs:list

# dirs list
proc dirs:list {nick host hand chan arg} {
global ls
catch { glob ls/* } dirs
putserv "PRIVMSG $chan :$dirs"
}

And seems to be working. the only thing I must figure out now is how to separate the files from the dirs.

Any tips, advices or something that can help me out a bit are welcomed, very apreciated and mostly needed. :)
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Please see the usage of the glob command in the Tcl manual pages.

http://www.tcl.tk/man/tcl8.4/TclCmd/glob.htm

It tells you all about how to determine between filetypes
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

With: "catch { glob -directory files/ * } dirs" I still get the files among the dirs. Tryed some alternatives but same thing.. Now I'm a bit stuck and confused. :-?
Once the game is over, the king and the pawn go back in the same box.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Pfff.. seems that I've figured out after reading more carefuly the page you've gave me. Thanks!

bind pub n .dirs dirs:list

# dirs list
proc dirs:list {nick host hand chan arg} {
global ls
catch { glob -type d files/* } dirs
foreach dr $dirs {
putserv "PRIVMSG $chan :[string range $dr [expr [string length files]+1] end]"
}
}
Once the game is over, the king and the pawn go back in the same box.
Locked