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.

Please look at this tcl-script

Old posts that have not been replied to for several years.
Locked
j
jagg

Please look at this tcl-script

Post by jagg »

Hi,

here is the code i have made:

Code: Select all

proc pub:pivot {nick host hand chan arg} {

if {[llength $arg]==0} {

putserv "PRIVMSG $channel :\0035 Ein Symbol musst Du schon eingeben :-)\003"

} else {

set stock [string toupper [lindex $arg 0]]
set tok [http::geturl http://quotes.barchart.com/quote.asp?sym=$stock&code=BHTDR]
set data [http::data $tok]
set high [lindex [split $data \n] 127]
set low [lindex [split $data \n] 128]
set close [lindex [split $data \n] 129]
set pivot [expr {([string map {{color="#000000">} {} {</FONT></TD>} {}} [lindex $high 7]] + [string map {{color="#000000">} {} {</FONT></TD>} {}} [lindex $low 7]] + [string map {{color="#000000">} {} {</FONT></TD>} {}} [lindex $close 7]]) / 3}]
set r1 [expr {(2 * $pivot) - [string map {{color="#000000">} {} {</FONT></TD>} {}} [lindex $low 7]]}]
set r2 [expr {$pivot + ([string map {{color="#000000">} {} {</FONT></TD>} {}} [lindex $high 7]] - [string map {{color="#000000">} {} {</FONT></TD>} {}} [lindex $low 7]])}]
set s1 [expr {(2 * $pivot) - [string map {{color="#000000">} {} {</FONT></TD>} {}} [lindex $high 7]]}]
set s2 [expr {$pivot - ([string map {{color="#000000">} {} {</FONT></TD>} {}} [lindex $high 7]] - [string map {{color="#000000">} {} {</FONT></TD>} {}} [lindex $low 7]])}]

putserv "PRIVMSG $chan :\0030,14 Pivots for $stock -> \0038,14[format %.2f $r2] \0035,14(R2) \0038,14[format %.2f $r1] \0035,14(R1) \0038,14[format %.2f $pivot] \0035,14(Pivot) \0038,14[format %.2f $s1] \0035,14(S1) \0038,14[format %.2f $s2] \0035,14(S2) \003"

}
}
This script reads different lines from e.g. http://quotes.barchart.com/quote.asp?sy ... code=BHTDR and calculates pivot points.

Until now I look for the line nr. in the source to fetch the high, low and the close stockquote from yesterday (see the picture)

BUT

this won't work for the most of the time because the line nr. in the source code change VERY OFFEN :-?

How could I fetch the needed stockquotes (high, low and the close from yesterday) in a better way (so that it doesnt care what line nr the needed stockquotes have)?

THANKS
jagg

I need these stockquotes
Image

P.S.: The formula for calculate the pivot points can be see e.g. here
http://www.technical-investor.de/conten ... 2&hl=pivot
d
darko``
Op
Posts: 121
Joined: Sun Sep 08, 2002 5:33 pm
Location: Malta

Post by darko`` »

I would suggest using regexp to find which lines are the ones containing info you seek and then proceede with the original script. Shouldn't be a problem really, cause the lines themselves are most probably are templates filled with data.
Ignorant and lazy people will save 30 minutes by chosing simple config file. Smart ones will save 3000 minutes of *everyone's* time by opting for complete config file.
d
darko``
Op
Posts: 121
Joined: Sun Sep 08, 2002 5:33 pm
Location: Malta

Post by darko`` »

I would suggest using regexp to find which lines are the ones containing info you seek and then proceede with the original script. Shouldn't be a problem really, cause the lines themselves are most probably are templates filled with data.
Ignorant and lazy people will save 30 minutes by chosing simple config file. Smart ones will save 3000 minutes of *everyone's* time by opting for complete config file.
d
darko``
Op
Posts: 121
Joined: Sun Sep 08, 2002 5:33 pm
Location: Malta

Post by darko`` »

Umm, offtopic, but someone check why my reply to this msg shows twice, while i tought it wouldn't show even once... There was some error: General error - couldn't find template email-notify :/
Ignorant and lazy people will save 30 minutes by chosing simple config file. Smart ones will save 3000 minutes of *everyone's* time by opting for complete config file.
j
jagg

Post by jagg »

@darko

Could you please explain how this regexp lines must look like?
(please paste the whole script again with your changes)

THANKS
jagg
User avatar
slennox
Owner
Posts: 593
Joined: Sat Sep 22, 2001 8:00 pm
Contact:

Post by slennox »

darko, I think it's related to the old error discussed here:

http://forum.egghelp.org/viewtopic.php? ... ight=#8690
User avatar
slennox
Owner
Posts: 593
Joined: Sat Sep 22, 2001 8:00 pm
Contact:

Post by slennox »

Yep, I just got the error too, so it is. Unfortunately, this thread is going to spit that out of every reply now (I think). It happens :(
Locked