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.

character limit

Help for those learning Tcl or writing their own scripts.
Post Reply
t
tersayang
Voice
Posts: 3
Joined: Wed Apr 18, 2007 7:03 am

character limit

Post by tersayang »

Can someone help me with my code, 1st this code is get a head line from news website and than parsing to channel. the codes is bellow
regexp -nocase {<font class="tgl">(.+?)</font><br>} $html - rtanggal
regexp -nocase {<a href=\"(.+?)\" class="judul">(.+?)</a><br>} $html - rurl rjudul
regexp -nocase {<font class="deskripsi">(.+?)</font><br>} $html - risi


if {![info exists risi]} {
putlog "\[NEWS\] Republika ErroR!!"
return 0
}

set rurl1 "http://www.republika.co.id/${rurl}"

set output " \[Republika\]4,2 ${rtanggal}8,2 ${judul}0,2 ${risi}11,2 ${rurl1}"

foreach ruang $channels {
putserv "PRIVMSG $ruang :$output"
}
return 0
}

My question is how to limit the ${isi} into 50 characters only ?

thanks
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I'd suggest you have a look at the 'string' command, or more speciffically, 'string range'. Manpages should be available on your system, otherwize look here for documentation.

Also, it's considdered good practise to put your code within "code-blocks" when posting here.
NML_375
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

You might also want to look at the word wrap proc created by 'user' instead of cutting off headlines at arbitrary spots.

http://forum.egghelp.org/viewtopic.php?t=6690#33031

Search the forum for 'wordwrap' to find other discussion/variations of the same basic proc.
Post Reply