01-23-2019, 15:34 +0100
thommey  03-31-2005, 12:33   | [EGG] Random line from a file Jabber
Member since 03/2004
62 Posts
# Returns a random line out of $file (error if it doesnt exist)
proc randline {file} {
    set fs [open $file r]
    set data [read $fs]
    close $fs
    # Now we have the complete content of $file stored in $data
    set data [split $data \n]
    # Now it's a list of lines, and we use eggdrop's "rand" function to get a random element from it (and return it)
    return [lindex $data [rand [llength $data]]]

This post was edited 1 times, last on 08-12-2009, 22:11 by thommey
nazeeb  04-13-2011, 11:59   | Regarding Line extraction
Member since 04/2011
1 Post
Location: India
what if I need to extract a specific line from the file
that is my file contains lines starting from $$, $#, $. and so on......
However there are some other lines where in am interested to extract and put into another file......
heartbroken  01-11-2012, 19:21   | re
Member since 01/2012
5 Posts

thommey i've seen these kinda random reader codes before but i wonder how a code read within a txt file line by line .not random...

can you show an example code for about this please.
for an example if i want my bot posts a poem in poems.txt,bot should be post this line by line on channel how its possible to creat a code for that.
This post was edited 1 times, last on 01-11-2012, 19:23 by heartbroken
CyBex  01-12-2012, 00:27   Jabber  ICQ  AOL IM  Yahoo IM  MSN  Homepage
nie da


Member since 01/2004
260 Posts
Location: Berlin

mfG CyBex @ QuakeNet, UnderNet, EFNet, Freenode, euIRC, GameSurge & ShadowWorld - Files
heartbroken  01-15-2012, 13:39   | hey
Member since 01/2012
5 Posts

/me Thanks to you CyBex :)
Advanced options for this topic:

Ignore this topic (Do not list this topic in the "unread topics" search. You are currently not ignoring this topic.)
Hide this topic (Hidden topics are not displayed in the topics list. This topic is currently not hidden.)
Go to forum

Unclassified NewsBoard 1.5.3-d | © 2003-4 by Yves Goergen | Time: 2196.3 msec, CPU time: 84.1 msec, 41 Database queries in 157.9 msec | 4.1 kB (18.4 kB) | Timezone: +0100