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.

up & down - green & red

Old posts that have not been replied to for several years.
Locked
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

up & down - green & red

Post by NewzUK »

Hi

After previous help on this forum (for which Im very gratefull!), here's another question!

I use a stockquote script for my business channel, and I'm wondering how to go about adding some code that will make the quotes display green if it returns a + (up) amount and red if it returns a - (down) amount...

I have a mIRC script which does this, but I'm just wondering how it might work for TCL...

let me know if I should post a piece of the script here...

thanks in advance!
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

It's very simple to determine between a + or -, so therw would be no issue converting it.

Code: Select all

set test [string map [list + \00309 - \00304]
That will amp the up and down to red and green.

My gueess is though you want more information than this?
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

thanks - so would I just insert that somewhere in the proc?

proc pub:quote { nick uhost handle channel arg } {
set [lindex [info args pub:quote] 4] [string trimleft [subst $[lindex [info args pub:quote] 4]] !]
foreach _IG [uplevel #0 {set IGwords}] { if {[string equal -nocase $_IG [lindex [split $arg] 0]]} { return } }
if {[llength $arg]==0} {
putserv "NOTICE $nick :0,2 please type \002!news\002 for options "
} else {
set stock [string toupper [lindex $arg 0]]
set query "http://finance.yahoo.com/d/quotes.csv?s ... 4mv&e=.csv"
set token [http::geturl $query]
set all [http::data $token]
regsub -all \" $all "" all
set all [split $all ","]
if {[lindex $all 2]!="0.00"} {
putserv "PRIVMSG $channel :\0037» [lindex $all 0]:\003 [lindex $all 2] \002[lindex $all 3]\002 ([lindex $all 4]) \0037 Time:\003 [lindex $all 1] USET \0037 Low-High:\003 [lindex $all 5] \0037 Volume:\003 [lindex $all 6]"
} else {
putserv "PRIVMSG $channel :\002 [lindex $all 0]\002 symbol not found"

also, if it's a 0 number (unchanged) and I want to make that blue, would I just add another one for \0032 ?

thanks again!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

\003color number. As I can see blue is 12 and 2 is navy :)
Once the game is over, the king and the pawn go back in the same box.
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

yep thanks - I know the numbers, just need to know where & what to insert ;)

the value that goes + and - is [lindex $all 3] so I guess thats in the string somewhere...
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

you have to make a variable out of [lindex $all 3], then check if that var is + , - or 0, when you've done the cheking just append whatever color you want
Elen sila lúmenn' omentielvo
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

...thanks...will try to figure it out from other bits of the script :-?
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

the things ive tried so far havn't worked properly :( if anyone could possibly show me what to put in the script to make this work - thanks!

:-?
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

proc pub:quote { nick uhost handle channel arg } { 
set [lindex [info args pub:quote] 4] [string trimleft [subst $[lindex [info args pub:quote] 4]] !] 
foreach _IG [uplevel #0 {set IGwords}] { if {[string equal -nocase $_IG [lindex [split $arg] 0]]} { return } } 
if {[llength $arg]==0} { 
putserv "NOTICE $nick :0,2 please type \002!news\002 for options " 
} else { 
set stock [string toupper [lindex $arg 0]] 
set query "http://finance.yahoo.com/d/quotes.csv?s=$stock&f=st5l9c6p4mv&e=.csv" 
set token [http::geturl $query] 
set all [http::data $token] 
regsub -all \" $all "" all 
set all [split $all ","]
set test [string map [list + \00309+ - \00304-]
if {[lindex $all 2]!="0.00"} { 
putserv "PRIVMSG $channel :\0037» [lindex $all 0]:\003 [lindex $all 2] \002$test\003\002 ([lindex $all 4]) \0037 Time:\003 [lindex $all 1] USET \0037 Low-High:\003 [lindex $all 5] \0037 Volume:\003 [lindex $all 6]" 
} else { 
putserv "PRIVMSG $channel :\002 [lindex $all 0]\002 symbol not found"
this will just work if there is an actual + or - infront of the number...
Elen sila lúmenn' omentielvo
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

that dosn't work - bot sends nothing to the channel - not even the normal quote.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

ummm my fult ... didn't check the code :oops:
ah well :)... change this line

Code: Select all

set test [string map [list + \00309+ - \00304-] 
with this

Code: Select all

set test [string map [list + \00309+ - \00304-] [lindex $all 3]]
Elen sila lúmenn' omentielvo
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

still dosn't work - puts the quote in ok but dosn't change the color

*sigh*

oh well
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

this will just work if there is an actual + or - infront of the number...
^^.... and did you change the output?

Code: Select all

putserv "PRIVMSG $channel :\0037» [lindex $all 0]:\003 [lindex $all 2] \002$test\003\002 ([lindex $all 4]) \0037 Time:\003 [lindex $all 1] USET \0037 Low-High:\003 [lindex $all 5] \0037 Volume:\003 [lindex $all 6]"
if there is no + or - infront of the number you have to do something like this instead:

Code: Select all

if {[lindex $all 3] > 0} { set test "\0039 [lindex $all 3]"
} elseif {[lindex $all 3] < 0} { set test "\0034 [lindex $all 3]"
} else { set test "\00312 [lindex $all 3]" }
Elen sila lúmenn' omentielvo
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

great - thanks so much - all working now!

thanks for your persistance!

:)
Locked