mIRC Home    About    Download    Register    News    Help

Print Thread
Script breakout and return? #205501 24/10/08 03:44 PM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
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>
}

Last edited by ots654685; 24/10/08 03:45 PM.
Re: Script breakout and return? [Re: ots654685] #205502 24/10/08 04:08 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
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).


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Script breakout and return? [Re: starbucks_mafia] #205503 24/10/08 04:19 PM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
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)

Last edited by ots654685; 24/10/08 04:20 PM.
Re: Script breakout and return? [Re: ots654685] #205504 24/10/08 04:28 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
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).


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Script breakout and return? [Re: starbucks_mafia] #206940 29/11/08 02:40 PM
Joined: Nov 2008
Posts: 3
B
bandrulle Offline
Self-satisified door
Offline
Self-satisified door
B
Joined: Nov 2008
Posts: 3
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?

Re: Script breakout and return? [Re: bandrulle] #206945 29/11/08 06:59 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
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.

Re: Script breakout and return? [Re: DJ_Sol] #207023 02/12/08 06:06 PM
Joined: Nov 2008
Posts: 3
B
bandrulle Offline
Self-satisified door
Offline
Self-satisified door
B
Joined: Nov 2008
Posts: 3
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?

Re: Script breakout and return? [Re: bandrulle] #207025 02/12/08 06:14 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
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.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Script breakout and return? [Re: starbucks_mafia] #207027 02/12/08 06:34 PM
Joined: Nov 2008
Posts: 3
B
bandrulle Offline
Self-satisified door
Offline
Self-satisified door
B
Joined: Nov 2008
Posts: 3
Works good =) thnx