mIRC Homepage

Script breakout and return?

Posted By: ots654685

Script breakout and return? - 24/10/08 03:44 PM

I made some script that uses some small tvrage thing in it but at some point in script it brakes out but doesn't return to finish it.

Code:
on *:TEXT:*:#:{
  tokenize 32 $strip($1-)
  if (*tvrage* iswm $1-) {
    /tvrage $2
    if ( %show_class != Scripted ) { halt }
    <rest of code>
  }
}

alias tvrage { 
<tvrage stuff>
}
I thought adding { return } at the end of alias tvrage would make it work but it doesn't.
Does this mean i have to split the ontext event in something like this?
Code:
on *:TEXT:*:#:{
  tokenize 32 $strip($1-)
  if (*tvrage* iswm $1-) {
    /tvrage $2
  }
}

alias tvrage { 
<tvrage stuff>
alias restofcode
}

alias restofcode {
  if ( %show_class != Scripted ) { halt }
  <rest of code>
}
Posted By: starbucks_mafia

Re: Script breakout and return? - 24/10/08 04:08 PM

Where exactly is it halting? You've got a halt command right after the call to the tvrage alias so it seems likely that the condition is true and that's where the script is stopping.

If it's definitely stopping within the alias itself then you need to show the relevant code since there must be either a halt command inside the alias or an identifier using two $ signs which will automatically halt if the identifier evaluates to $null (eg. if your alias is using something like $$3 and there's no third parameter then it will halt the script).
Posted By: ots654685

Re: Script breakout and return? - 24/10/08 04:19 PM

I know it runs tvrage because it gives me output to an @window (@ just for test)
And i know that % items are created but for some reason it wont perform !=
Code:
alias tvrage { 
  unset %tvrage*
  unset %tv.*
  unset %show*
  %tvrage = $replace($1,$chr(46),% $+ 20)
  %tv.rel = $replace($1,$chr(46),$chr(32))
  set %tv.release $2
  set %tv.section $3
  sockopen tvrage http://www.tvrage.com 80
}

on *:sockopen:tvrage:{
  sockwrite tvrage GET $+(http://www.tvrage.com/quickinfo.php?show=, %tvrage,$crlf) HTTP/1.1
  sockwrite -n tvrage Host: $+(www.tvrage.com,$crlf,$crlf)
}
on *:sockread:tvrage:{
  if ($sockerr) { return }
  var %tvdata
  sockread %tvdata
  if (show name isin %tvdata) { set %show_name $gettok(%tvdata,2,64) }
  if (show url isin %tvdata) { set %show_url $gettok(%tvdata,2,64) }
  if (premiered isin %tvdata) { set %show_premiered $gettok(%tvdata,2,64) }
  if (latest episode isin %tvdata) { set %show_late_ep $gettok(%tvdata,2,64) }
  if (next episode isin %tvdata) { set %show_next_ep $gettok(%tvdata,2,64) }
  if (country isin %tvdata) { set %show_country $gettok(%tvdata,2,64) }
  if (status isin %tvdata) { set %show_status $gettok(%tvdata,2,64) }
  if (classification isin %tvdata) { set %show_class $gettok(%tvdata,2,64) }   
  if (genres isin %tvdata) { set %show_genre $gettok(%tvdata,2,64) } 
  if (network isin %tvdata) { set %show_network $gettok(%tvdata,2,64) } 
  if (airtime isin %tvdata) { set %show_airtime $gettok(%tvdata,2,64) } 
  if (runtime isin %tvdata) { set %show_runtime $gettok(%tvdata,2,64) } 
  if (!sockbr) { return } 
}
on *:sockclose:tvrage:{
  window -kze @TV
  .aline @TV $timestamp [TV-INFO] :: Show: %show_name   Url: %show_url   Premiered: %show_premiered   Latest: %show_late_ep
  .aline @TV $timestamp [TV-INFO] :: Next: %show_next_ep   Country: %show_country   Status: %show_status   Classification: %show_class  Genre: %show_genre
  .aline @TV $timestamp [TV-INFO] :: Network: %show_network  Airtime: %show_airtime  Runtime: %show_runtime
}


I added several echo's in it to see where it stopped and it always stopped before !=
(that halt was an echo in the first place also)
Posted By: starbucks_mafia

Re: Script breakout and return? - 24/10/08 04:28 PM

The socket events will not be triggered immediately so any code that relies on the data obtained from sockets must be called when appropriate from a socket event (ie. on SOCKCLOSE).
Posted By: bandrulle

Re: Script breakout and return? - 29/11/08 02:40 PM

Hi

is there a way to use this script in a chan whith trigger !ep "SHOW" ?
And it will show episode info in that chan?
Posted By: DJ_Sol

Re: Script breakout and return? - 29/11/08 06:59 PM

Create a text event that senses a command like !tv. The person needs to provide the proper information. You may need to include channel for the message. You can sockmark it to have that info when you need it. In the text event take that info and send it to the tvrage alias.


Instead of aline to the window, msg $chan them.
Posted By: bandrulle

Re: Script breakout and return? - 02/12/08 06:06 PM

Only gets error when i use $chan:
Code:
on *:TEXT:*:#:{
  tokenize 32 $strip($1-)
  if (*!ep* iswm $1-) {
    /tvrage $2
    if ( %show_class != Scripted ) { halt }
    <rest of code>
  }
}

alias tvrage { 
  unset %tvrage*
  unset %tv.*
  unset %show*
  %tvrage = $replace($1,$chr(46),% $+ 20)
  %tv.rel = $replace($1,$chr(46),$chr(32))
  set %tv.release $2
  set %tv.section $3
  sockopen tvrage http://www.tvrage.com 80
}

on *:sockopen:tvrage:{
  sockwrite tvrage GET $+(http://www.tvrage.com/quickinfo.php?show=, %tvrage,$crlf) HTTP/1.1
  sockwrite -n tvrage Host: $+(www.tvrage.com,$crlf,$crlf)
}
on *:sockread:tvrage:{
  if ($sockerr) { return }
  var %tvdata
  sockread %tvdata
  if (show name isin %tvdata) { set %show_name $gettok(%tvdata,2,64) }
  if (show url isin %tvdata) { set %show_url $gettok(%tvdata,2,64) }
  if (premiered isin %tvdata) { set %show_premiered $gettok(%tvdata,2,64) }
  if (latest episode isin %tvdata) { set %show_late_ep $gettok(%tvdata,2,64) }
  if (next episode isin %tvdata) { set %show_next_ep $gettok(%tvdata,2,64) }
  if (country isin %tvdata) { set %show_country $gettok(%tvdata,2,64) }
  if (status isin %tvdata) { set %show_status $gettok(%tvdata,2,64) }
  if (classification isin %tvdata) { set %show_class $gettok(%tvdata,2,64) }   
  if (genres isin %tvdata) { set %show_genre $gettok(%tvdata,2,64) } 
  if (network isin %tvdata) { set %show_network $gettok(%tvdata,2,64) } 
  if (airtime isin %tvdata) { set %show_airtime $gettok(%tvdata,2,64) } 
  if (runtime isin %tvdata) { set %show_runtime $gettok(%tvdata,2,64) } 
  if (!sockbr) { return } 
}
on *:sockclose:tvrage:{
  msg $chan Show: %show_name  Genre: %show_genre  Premiered: %show_premiered  Latest: %show_late_ep   Next: %show_next_ep  Status: %show_status
}

And when i do "!ep lost" etc in chan, its try to msg show..
Code:
[02:18:52] -> *Show:* Lost  Genre: Action | Adventure | Drama | Mystery  Premiered: 2004  Latest: 04x14^There's No Place Like Home (3)^May/29/2008  Next: 05x00^Season 5 Recap Special^Jan/21/2009  Status: Returning Series
-
Show: No such nick/channel
-


Any idea?
Posted By: starbucks_mafia

Re: Script breakout and return? - 02/12/08 06:14 PM

That's because there's no channel associated with a socket event. You should store the channel information somewhere so it can be associated with the socket and retrieved when you need it. A simple way to do this is with the sockmark command.

Code:
alias tvrage { 
  unset %tvrage*
  unset %tv.*
  unset %show*
  %tvrage = $replace($1,$chr(46),% $+ 20)
  %tv.rel = $replace($1,$chr(46),$chr(32))
  set %tv.release $2
  set %tv.section $3
  sockopen tvrage http://www.tvrage.com 80
  sockmark tvrage $chan
}


Then use $sock($sockname).mark in your socket events to retrieve the channel name.
Posted By: bandrulle

Re: Script breakout and return? - 02/12/08 06:34 PM

Works good =) thnx
© 2022 mIRC Discussion Forums