mIRC Home    About    Download    Register    News    Help

Print Thread
help with setting variable needed #162303 16/10/06 04:59 PM
Joined: Aug 2004
Posts: 423
C
clutz1572 Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
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:
Code:
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 | aline @imdb $gettok(%a,2,34)
    }
  }
  .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.

Code:
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...

Re: help with setting variable needed #162304 16/10/06 07:53 PM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Quote:
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:
Code:
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.

Code:
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)


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Re: help with setting variable needed #162305 17/10/06 04:46 AM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Quote:
Code:
      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 | aline @imdb $gettok(%a,2,34)

If they are the results you want to match, the match to the dialog line would be at $line(@imdb,$did(1).sel)
Code:
on *:dialog:result:sclick:*: {
  if ($did == 2) {
    if $did($dname,1,1).sel { set %movieinfolink2 $line(@imdb,$v1) }
  }
}

Why not add the locations to another (hidden) dialog list instead of the @window? Then...
set %movieinfolink2 $did(99,$did(1).sel)
^^ assumes the new list id is "99"

Re: help with setting variable needed #162306 17/10/06 06:49 AM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
On a side note:
Quote:
alias -l dirchck { if (!isdir(imdb)) mkdir imdb }

You missed the $ in !$isdir(), which means the /mkdir command always runs, not that it matters either way, /mkdir doesn't error if the dir already exists smile

Re: help with setting variable needed #162307 18/10/06 01:12 PM
Joined: Aug 2004
Posts: 423
C
clutz1572 Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
thanks so much deegee thats what i was looking for smile. and thanks very much Lpfix5 for adding your input as well both of you guyz keep up the good fight! laugh

and also thanks for the dialog suggestion, i think i'll go with that since i have another little issue that i'm gonna fix. and the !$isdir thing, yes that was an over sight so thanks for pointing that out.....

okay now i have come across another problem... in the never ending process of trial an error i've decided to use two variables in my script they are called %searchmovie and
%movietitle,%searchmovie is for my search criteria and
%movietitle is for my selection..

this is what i'm encountering when i start my search i call the my_imdb dialog and input what i want to search for. that becomes a variable 1 of the two i mentioned, and that brings up the result dialog. when i select and click continue on the result dialog it sets the second variable which is used to actually get the information i seek. now with that said... i'm haveing two problems..
problem 1
Code:
on *:dialog:my_imdb:sclick:*: {
  if ($did == 16) {
    set %searchmovie $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 {
      if (!$hget($remove(%movietitle,$chr(32)) $+ .hsh)) hmake $remove(%movietitle,$chr(32)) $+ .hsh
      movieinfo
    } 
  }
} 
  

in this part of the code, how would i be able to check for a match in the imdb folder.. i want to not only check to see if there was a previous search but also if it matches the item being search for.. how would this be done?

problem 2
Code:
on *:dialog:result:sclick:*: {
  if ($did == 2) { 
    if $did($dname,1,1).sel { set %movieinfolink2 $line(@imdb,$v1) | set %movietitle $did(1).seltext }
    if !$hget($remove(%movietitle,$chr(32)) $+ .hsh) { hmake $remove(%movietitle,$chr(32)) $+ .hsh }
    sockopen movieinfo2 www.imdb.com 80 
 }
}
  

this part of my script is the culprit, i guess. anywho.. it sets the variable %movietitle when i make my selection, but i'm not sure how to release the item after i'm done with it... so as it stands now when i go to search, it recalls the %movietitle variable..
any suggestions and assistance would be appreciated on these..