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.

split text

Old posts that have not been replied to for several years.
Locked
m
mdnkia
Voice
Posts: 2
Joined: Fri Feb 04, 2005 2:16 pm

split text

Post by mdnkia »

hello i have this code

Code: Select all

set f [open $file] 
seek $f $pos 
if {[gets $f line]>-1} { 
putserv "privmsg $chan :$line" 
it will read line by line from the file.txt the problem is i have long sentence in 1 line is there any way to split it? when the script read . [dot] it will do new privmsg and continue the story.
anyone know it please i really stuck on it
thx
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

if you want it to output to a newline you can use

Code: Select all

\n
ie

Code: Select all

this is the line i want to display on the first line.\nThis will be displayed on the secondline.\nAnd this the third etc etc etc
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
m
mdnkia
Voice
Posts: 2
Joined: Fri Feb 04, 2005 2:16 pm

Post by mdnkia »

hmmm... thx for the reply but i know this code already i got much lines on file.txt and it will be so hard to edit all the text... :(
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

ok if you want to split up the text via a full stop you could use something like this.

Code: Select all

proc output { nick channel msg } {

    # Build string
    set strPrepend "PRIVMSG $channel :"
        
    # Send it out
    set line_array [split $msg "."]
    foreach line $line_array { putserv "$strPrepend$line" }

}
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Tip: You need to open the file in a way, so check this out.
Once the game is over, the king and the pawn go back in the same box.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: split text

Post by user »

mdnkia wrote:

Code: Select all

set f [open $file]
Have you ever read "The Manual"?
Locked