mIRC Home    About    Download    Register    News    Help

Print Thread
#187324 03/10/07 03:21 PM
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
I was hoping to halt the script and to wait for my command to go onto the next part of the script.
This code here don't seem to work, can anyone help?
Code:
line 137 : var %question $?!="Shall I continue?"
line 138 : if (%question == $false) { halt }
line 139 : else { /msg $nick Now processing the rest of the script }
I'm trying to write a script which works fine but not that popup question as I'm getting error saying
Quote:
* $?: cannot use in an event (line 138, script1.mrc)


Hope I have an answer soon.

TIA.

colt45 #187325 03/10/07 05:02 PM
Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
At first you should use a = sign in a var statement, like this:
Code:
  var %question = $?!="Shall I continue?"


But if that doesn't work you could try

Code:
  var %question = $input(etcetera) 


See help $input for the right format.

According to the helpfile both $? and $input cannot be used in script events. One way around this is to use a /timer to initiate an input request after the script ends, but that doesn't halt your script.

However, I do use $input in an on connect event and that does work, it halts the script until I've entered something. Just try it.....

noMen #187328 03/10/07 06:24 PM
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Yes, the $input don't work either :S

Any suggestion?

colt45 #187330 03/10/07 07:59 PM
Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
Question: in what kind of event are you trying to use this?

Suggestion: use a timer and an on signal event to continue.

colt45 #187331 03/10/07 08:29 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
As stated, you cannot use inputs that pause processing of events ($?="" and $input) in events that pausing the processing of the event would be detrimental. Some events, they work in, many they do not. I can't list all events that work or don't work, but it's easy to just check and see if it lets you do so by testing it in the event. If you get the error, then you can't use it there.

Also, as stated, the workaround is to use a timer...
Code:
.timer 1 0 var %question = $?!="Shall I continue?"


That said, a much better solution for what you're trying to do would probably be to use aliases. Stick the var line into an alias and put the processing information in the alias as well. Then just call that alias from the main script. Besides being nicer than a timer, this also helps organize your script. You would now know that the alias handles the processing of the script after the question is asked.


Invision Support
#Invision on irc.irchighway.net
noMen #187332 03/10/07 08:33 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Originally Posted By: noMen
Question: in what kind of event are you trying to use this?

Suggestion: use a timer and an on signal event to continue.


Listen, your using a variable to store an evaluation why even use the variable at all do this........


if ($input(Question?,y) == $false) { do stuff }
else { do other stuff }

you see you dont even need to store a variable. Using the $input event within an if statement works.

Btw by adding a y switch in the input event it makes it yes,no read the manual on other switch possibles, has n switch will make yes no cancel buttons

Also using the input event in the if statement will allow the time allowment to perform the command.



Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Riamus2 #187336 03/10/07 08:50 PM
Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
Originally Posted By: Riamus2

That said, a much better solution for what you're trying to do would probably be to use aliases.

Lol, that's indeed the easiest way. I thought I had found a useful application of on signal. Why does that exist anyhow? But that's off topic here ...

Lpfix5 #187337 03/10/07 08:52 PM
Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
You're right Lpfix5, a variablke is not needed in this case, but I doubt whether $input in an if statement will work in any event ... why isn't this mentioned in the helpfile?

noMen #187341 03/10/07 09:17 PM
Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Originally Posted By: /help $?
Note: This identifier cannot be used in a script event. One way around this is to use a /timer to initiate an input request after the script ends.

The same note is in the help for $input.

As for using signals, they are extremely useful for cross-script actions. For instance, I use a timer calling 'signal maketitle'. So any script file can have a 'maketitle' ON SIGNAL, and will be triggered when the timer hits.

noMen #187354 03/10/07 11:14 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Originally Posted By: noMen
You're right Lpfix5, a variablke is not needed in this case, but I doubt whether $input in an if statement will work in any event ... why isn't this mentioned in the helpfile?


Alot of things are not in the help file, lol... You should really know this by now and instead of doubting you should try it. The input event is called in the if statement and waits for the equal too response, if theres no match has stated then it would be false, else it's true :P


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
noMen #187364 04/10/07 02:03 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: noMen
Originally Posted By: Riamus2

That said, a much better solution for what you're trying to do would probably be to use aliases.

Lol, that's indeed the easiest way. I thought I had found a useful application of on signal. Why does that exist anyhow? But that's off topic here ...


Signals would be another option, yes. But I've never had a need for them and I think it's more effort to do that for this situation than just using aliases. They are a good option for other situations, though.


Invision Support
#Invision on irc.irchighway.net
Lpfix5 #187366 04/10/07 02:05 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: Lpfix5
Originally Posted By: noMen
You're right Lpfix5, a variablke is not needed in this case, but I doubt whether $input in an if statement will work in any event ... why isn't this mentioned in the helpfile?


Alot of things are not in the help file, lol... You should really know this by now and instead of doubting you should try it. The input event is called in the if statement and waits for the equal too response, if theres no match has stated then it would be false, else it's true :P


His point is that $input/$?="" do NOT work in certain events except through a timer. Using an IF statement doesn't change that. And I'm sure he knows what the IF statement does.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard