egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[solved]how to read a text file top to bottom ??

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Sun Jul 04, 2010 1:53 pm    Post subject: [solved]how to read a text file top to bottom ?? Reply with quote

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 Smile

thanks guys.. Smile
_________________
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
View user's profile Send private message Visit poster's website
horgh
Voice


Joined: 13 Feb 2010
Posts: 10

PostPosted: Sun Jul 04, 2010 8:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Mon Jul 05, 2010 3:44 am    Post subject: Reply with quote

thanks dude, works perfectly now Smile


if you get on EFNET #mp3.spam to see it working Very Happy
_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber