Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
hello again... man this seems like a neverending battle... but i'm not sure how to do this. ok, my problem now is that i'm trying to set a variable from a line in a @window.. this was suggested a lil while back (kinda)for my script but i'm not sure how to go about it. thanks to deegee for helping me get this far, but now that i'm at the point of where this is needed i'm stumped.. i'm making a personal search script for the imdb site and now i'm able to put a list of search results into a dialog list and have the url into a @window. now what i would like to do is when i select an item in the dialog it would set the variable with the url so i can use it to call my next socket to pull my info.. how can i do this?? heres what i have:
on *:sockopen:dg.imdb:{
sockwrite -n $sockname GET /find?s=all&q= $+ $replace(%movietitle,$chr(32),$(%20,))/ HTTP/1.0
sockwrite -n $sockname Host: www.imdb.com $str($lf,2)
}
on *:sockread:dg.imdb:{
sockread -f &a
bwrite imdb.txt -1 -1 &a
}
on *:sockclose:dg.imdb:p.imdb
alias p.imdb {
.fopen imdb imdb.txt
if $ferr { echo -a read error | fclose imdb | return }
.fseek -w imdb *Popular Titles*
if !$feof && !$ferr {
while $fread(imdb) != </ol> {
var %a = $v1
if *Popular Titles* iswm %a { dialog -m result result | did -a result 1 $_htmlconv($gettok(%a,5-,62)) }
else {
did -a result 1 $_htmlconv(%a)
window @imdb
[color:red]if (word isin $gettok(%a,2,34))[/color] { aline @imdb $gettok(%a,2,34) | [color:red]%newvar = $gettok(%a,2,34) }[/color]
[color:red]else { [/color]
aline @imdb $gettok(%a,2,34)
[color:red]}[/color]
}
}
}
.fclose imdb
}
dialog result {
title Results For: %movietitle
size -1 -1 261 103
option dbu
list 1, 4 11 251 60, size hsbar
button "Continue", 2, 5 89 37 9
button "Cancel", 3, 101 89 37 9, cancel
text "Please Make A Selection", 4, 40 2 58 7
}
on *:dialog:result:sclick:*: {
if ($did == 2) {
if $did($dname,1,1).sel { set %movieinfolink2 $fline(@imdb,*,1,0) }
}
}
alias movieinfo { .remove imdb.txt | sockclose dg.imdb | sockopen dg.imdb www.imdb.com 80 }
the above code connects to the site and writes the initial info to file. the allows me to pull and put my search results into the dialog and @window.
on *:sockread:movieinfo2:{
if ($sockerr) {
Halt
}
else {
var %tmptxt
sockread -f %tmptxt
if (<b class="blackcatheader"> isin %tmptxt) {
if (Directed isin %tmptxt) { set %directcatch 1 }
}
elseif (%directcatch <= 1) {
hadd $remove(%movietitle,$chr(32)) $+ .hsh Director $htmlconv(%tmptxt)
unset %directcatch
}
if (<b class="ch"> isin %tmptxt) {
if (%zinfonumber <= 8) {
if (%zinfonumber = 1) { inc %zinfonumber }
elseif (%zinfonumber = 2) {
hadd $remove(%movietitle,$chr(32)) $+ .hsh Tagline $remove($htmlconv(%tmptxt),Tagline:,(more),(view trailer))
inc %zinfonumber
}
elseif (%zinfonumber = 3) {
hadd $remove(%movietitle,$chr(32)) $+ .hsh Plot $remove($htmlconv(%tmptxt),Plot $+ $chr(32) $+ Outline:,Plot $+ $chr(32) $+ Summary:,(more),(view trailer))
inc %zinfonumber
}
elseif (%zinfonumber = 4) { inc %zinfonumber }
elseif (%zinfonumber = 5) { inc %zinfonumber }
elseif (%zinfonumber = 6) { inc %zinfonumber }
elseif (%zinfonumber = 7) { inc %zinfonumber }
elseif (%zinfonumber = 8) { replywithstuff }
}
if (Genre: isin %tmptxt) { set %genrecatch 1 }
if (Runtime: isin %tmptxt) { set %rtcatch 8 }
}
elseif (%genrecatch <= 1) {
hadd $remove(%movietitle,$chr(32)) $+ .hsh Genre $remove($htmlconv(%tmptxt),(more))
unset %genrecatch
}
elseif (%rtcatch <= 8) {
hadd $remove(%movietitle,$chr(32)) $+ .hsh runtime $remove($htmlconv(%tmptxt),runtime:)
unset %rtcatch
}
}
}
dialog my_imdb {
title "AwSuMovies IMDB Personal Search Results"
size -1 -1 243 106
option dbu
edit "", 2, 72 6 105 10
edit "", 3, 33 24 105 10
edit "", 4, 33 38 62 10
edit "", 5, 121 38 115 10
edit "", 6, 164 24 73 10
text "Search For:", 7, 40 7 28 8
text "Movie Title:", 8, 4 25 28 8
text "Genre:", 9, 103 40 17 8
text "Director:", 10, 11 40 21 7
text "Runtime:", 11, 141 25 22 8
edit "", 14, 33 53 203 10
button "Search!", 16, 180 6 37 10
text "Tag Line:", 17, 10 55 23 7
button "Done", 18, 219 6 22 10, ok
text "Movie Plot:", 15, 93 67 27 8
edit "", 1, 5 76 232 28, multi
}
on *:dialog:my_imdb:sclick:*: {
if ($did == 16) {
set %movietitle $did(2)
did -r $dname 2
if $isfile($+(imdb\,$remove(%movietitle,$chr(32)),.hsh)) {
hmake $remove(%movietitle,$chr(32)) $+ .hsh
hload $remove(%movietitle,$chr(32)) $+ .hsh $+(imdb\,$remove(%movietitle,$chr(32)),.hsh)
did -ra $dname 3 %movietitle
did -ra $dname 4 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Director)
did -ra $dname 5 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Genre)
did -ra $dname 7 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Tagline)
did -ra $dname 1 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Plot)
did -ra $dname 6 %hget($remove(%movietitle,$chr(32)) $+ .hsh,Runtime)
}
else {
hmake $remove(%movietitle,$chr(32)) $+ .hsh
movieinfo
}
}
}
alias _htmlconv {
var %x = $regsubex($1-,/(?:&#(\d*?);)/g,$chr(\t))
noop $regsub(%x,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x)
return $remove(%x,&,$chr(9))
}
alias -l dirchck { if (!isdir(imdb)) mkdir imdb }
alias -l replywithstuff {
did -ra my_imdb 3 %movietitle
did -ra my_imdb 4 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Director)
did -ra my_imdb 5 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Genre)
did -ra my_imdb 14 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Tagline)
did -ra my_imdb 1 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Plot)
did -ra my_imdb 6 $hget($remove(%movietitle,$chr(32)) $+ .hsh,Runtime)
dirchck
hsave $+($remove(%movietitle,$chr(32)),.hsh) $+(imdb\,$remove(%movietitle,$chr(32)),.hsh)
sockclose movieinfo1 | sockclose movieinfo2
hfree $remove(%movietitle,$chr(32)) $+ .hsh
}
alias mymoviesearch { dialog -m my_imdb my_imdb }
this code above is where i'm inputting the %movietitle info and also where the final in put will be being put when the second socket is triggered plus all the aliases i'm using.. now i don't think i will have to modify the code in socket 2, but for now i'm in need of setting the corrisponding url from the @imdb window when i make a selection in the dialog.. i know this was long winded.... sorry about that but wanted to let ya'll know all.. thanks in advance... you can use something like the above code to get it to work or something like %variable = $gettok(%a,$findtok(%a,word,1,32),32)
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|