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.

variable to lines

Old posts that have not been replied to for several years.
Locked
w
woffer

Post by woffer »

Hi again, more problems :)
set test "some text | some more text | and even more text"

putserv "PRIVMSG #somechan :$test"

is it possible to make a new line after every | ? while thingy or something
S
Searchig

Post by Searchig »

Simplest/quickest way I can think of is this:

set test "some text | some more text | and even more text |"
set test [cleanarg $test]
set oga ""
foreach t $test {
if {$t != "|"} {
if {$oga == ""} {
set oga $t
} else {
set oga "$t $oga"
}
} else {
putserv "privMSG #somechan :$oga"
set oga ""
}
}
proc cleanarg {arg} {
set temp ""
for {set i 0} {$i < [string length $arg]} {incr i} {
set char [string index $arg $i]
if {($char != "12") && ($char != "15")} {
append temp $char
}
}
set temp [string trimright $temp "}"]
set temp [string trimleft $temp "{"]
return $temp
}

The cleanup proc seperates each word.

_________________
Searchig
One clueless user

<font size=-1>[ This Message was edited by: Searchig on 2002-06-02 18:42 ]</font>
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

thats a very convoluted way of doing it. personally I'd just split it into a list using | as the seperator, and run a for loop through it
something like
set blah [split $instring |]
for {set x 0} {$x == [llength $blah]} {incr x} {
putserv "PRIVMSG $chan :[lindex $blah $x]"
}

w
woffer

Post by woffer »

thanks guys
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

actually, i dunno wtf i was thinking when i wrote that - there is a much simpler solution >>

set blah [split $instring |]
foreach a $blah {putserv "PRIVMSG $chan :$a"}
Locked