| View previous topic :: View next topic |
| Author |
Message |
doggo Halfop
Joined: 05 Jan 2010 Posts: 97
|
Posted: Sun Jul 04, 2010 1:53 pm Post subject: [solved]how to read a text file top to bottom ?? |
|
|
my script reads from a txt file that looks like this
| Code: | Track list for - Vertex_-_Archipelago-(TESD001)-WEB-2010-HQEM
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
01-vertex-oceanos.mp3
02-vertex-archipelago.mp3
03-vertex-hungary_dance.mp3
04-float_and_vertex-oceansphere.mp3 |
heres the script...
| Code: | # Rls: track_list.v1.0.tcl
# Date: 19/06/10
# Coded by: SaNcTuM
# Contact: #a.b.inner-sanctum@EFNET
###################################
bind PUB - -tlist SaNcTuM_tracks
set track_list "/home/eggdrop/requests/track_lists"
proc SaNcTuM_tracks {nick uhost hand chan text} {
set tracks [open $::track_list/[lindex $text 0].txt r]
set data [split [read -nonewline $tracks] \n]
close $tracks
foreach music_info $data {
utimer 3 [list putquick "NOTICE $nick :\00315$music_info"]
}
return 0
}
putlog "track_list.v1.0 LOADED" |
but it reads the .txt file from the bottom up :/
| Code: | [18:51] <@mojo> -tlist 31810
[18:51] -moopig- 04-float_and_vertex-oceansphere.mp3
[18:51] -moopig- 03-vertex-hungary_dance.mp3
[18:51] -moopig- 02-vertex-archipelago.mp3
[18:51] -moopig- 01-vertex-oceanos.mp3
[18:51] -moopig- -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
[18:51] -moopig- Track list for - Vertex_-_Archipelago-(TESD001)-WEB-2010-HQEM |
i would also like it to notice the user if there is no file to display
thanks guys..  _________________ NON geeky!! http://gotcode4u.com/
Last edited by doggo on Mon Jul 05, 2010 3:44 am; edited 1 time in total |
|
| Back to top |
|
 |
horgh Voice
Joined: 13 Feb 2010 Posts: 10
|
Posted: Sun Jul 04, 2010 8:16 pm Post subject: |
|
|
| Code: | # Rls: track_list.v1.0.tcl
# Date: 19/06/10
# Coded by: SaNcTuM
# Contact: #a.b.inner-sanctum@EFNET
###################################
bind PUB - -tlist SaNcTuM_tracks
set track_list "/home/eggdrop/requests/track_lists"
proc SaNcTuM_tracks {nick uhost hand chan text} {
set number [lindex [split $text] 0]
set filename ${::track_list}/${number}.txt
if {![file exists $filename]} {
putquick "NOTICE $nick :Track list file not found."
return
}
set tracks [open $filename]
set data [split [read -nonewline $tracks] \n]
close $tracks
foreach music_info $data {
putquick "NOTICE $nick :\00315$music_info"
}
}
putlog "track_list.v1.0 LOADED"
|
It's probably showing in reverse due to utimer. There's no need to use utimer here I think as putquick is already queued.
I made it extract argument more correctly and added the check for if file doesn't exist.
But I didn't test this so ;p |
|
| Back to top |
|
 |
doggo Halfop
Joined: 05 Jan 2010 Posts: 97
|
Posted: Mon Jul 05, 2010 3:44 am Post subject: |
|
|
thanks dude, works perfectly now
if you get on EFNET #mp3.spam to see it working  _________________ NON geeky!! http://gotcode4u.com/ |
|
| Back to top |
|
 |
|