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.

Splitting into lines

Help for those learning Tcl or writing their own scripts.
Post Reply
s
skenmy
Voice
Posts: 2
Joined: Sat May 27, 2006 10:12 am

Splitting into lines

Post by skenmy »

Hi all,

I'm busy modifying a quotescript for eggdrop - and I need a way of being able to record multiple-line quotes.

I figured that splitting it with a "|" character will suffice - but now I need a way of getting my Tcl script to split the line by the | and print out a new line for each "line" in the quote. An example of a code that could do this would be much appreciated.

Thanks!
User avatar
avilon
Halfop
Posts: 64
Joined: Tue Jul 13, 2004 6:58 am
Location: Germany

Post by avilon »

Code: Select all

set fs [open QUOTES.txt]
set data [read $fs]
close $fs

foreach Quote [split $data \n] {
	foreach Line [split $Quote "|"] {
		puthelp "PRIVMSG #CHANNEL :$Line"
	}
}
s
skenmy
Voice
Posts: 2
Joined: Sat May 27, 2006 10:12 am

Post by skenmy »

Looks pretty good - I'm running out of a database but I'm pretty sure I could adapt that quite easily.

Many Thanks!
Post Reply