mIRC Homepage

* $input: cannot use in an event

Posted By: westor

* $input: cannot use in an event - 02/03/11 09:54 PM

Hello,

How can i use the $input identifier on an event?

- Thanks!
Posted By: Riamus2

Re: * $input: cannot use in an event - 02/03/11 10:10 PM

$input is not meant for an event. Events are things that are going to happen whether or not you are there and aren't going to sit around and wait for you to type something. That said, there are ways around this. For example, using a timer...

Code:
.timer 1 1 echo -a This is my input: $!input(Press OK or Cancel)


Note that you do need the ! in there to prefer $input() from being done until after the timer triggers.
Posted By: Tomao

Re: * $input: cannot use in an event - 02/03/11 10:14 PM

The $$input(Press OK or Cancel) or $$?"Press OK or Cancel" is good for your own use, not other people who trigger it anyway. The $ should be made double so it won't trigger if no string is supplied.
Posted By: westor

Re: * $input: cannot use in an event - 02/03/11 10:20 PM

if i wanna do this?

var %t = $input(lalala,oid,test)

does not work on sockclose event!
Posted By: Tomao

Re: * $input: cannot use in an event - 02/03/11 10:21 PM

You can also do is as:
Code:
//.timer 1 1 noop $input(Press OK or Cancel) | echo -a This is my input: $!
Posted By: Tomao

Re: * $input: cannot use in an event - 02/03/11 10:25 PM

Pardon me, Riamus2, your example does work. I didn't mean to prove your wrong otherwise.
Posted By: westor

Re: * $input: cannot use in an event - 02/03/11 10:26 PM

Yes but i have an var , check my code

ON *:SOCKCLOSE:mysock: {
var %ask = $input(Test,yidb,Asking)
if (%ask == $true) { .. }
elseif (%ask == $false) { .. }
}

* $input: cannot use in an event
Posted By: Tomao

Re: * $input: cannot use in an event - 02/03/11 10:28 PM

Did you place a
Code:
sockclose $sockname
under your sockread event? If the socket has been closed already, the sockclose event won't get triggered.
Posted By: westor

Re: * $input: cannot use in an event - 02/03/11 10:32 PM

no i haven't put an /sockclose command into the sockread just /sockmark
Posted By: westor

Re: * $input: cannot use in an event - 02/03/11 10:37 PM

how can i make it work the sockclose event with the /var, ?
Posted By: Tomao

Re: * $input: cannot use in an event - 02/03/11 10:54 PM

Code:
on *:sockclose:mysock: { 
  .timer 1 1 echo -a $!iif($input(Test,yidb,Asking),$!,$!)
}
As Riamus said, you need to use a timer like as shown below. If the yes button is pressed, it'll return $true, else it returns $false
Posted By: Tomao

Re: * $input: cannot use in an event - 02/03/11 10:59 PM

Code:
.timer 1 1 echo -a $!iif($input(Test,yidb,Asking),This will be true when yes button is pressed,This will be false when no button is pressed)
Now, all you have to do is replace 'This will be true...' and 'false' with the command you want to trigger.

Of course, replace echo -a with the command.
Posted By: westor

Re: * $input: cannot use in an event - 02/03/11 11:01 PM

i changed the echo with var and not working
Code:
    .timer 1 1 var %ask $!iif($input(%m,yidb,Information),$!,$!)


%m = my message
Posted By: Tomao

Re: * $input: cannot use in an event - 02/03/11 11:08 PM

Code:
//.timer 1 1 echo -a $!iif($input(%m,yidb,Information),$!,$!)


Well, I don't know why a variable has to be used...
Posted By: westor

Re: * $input: cannot use in an event - 02/03/11 11:15 PM

* Invalid format: $iif
Posted By: westor

Re: * $input: cannot use in an event - 02/03/11 11:21 PM

I had asked for this before and someone has gave me an $safe alias code or something like this. but i can't find his post!
Posted By: Tomao

Re: * $input: cannot use in an event - 02/03/11 11:27 PM

Code:
on *:sockclose:mysock: {
  var %ask $!iif($input(%m,yidb,Information),$!,$!)
  .timer 1 1 echo -a %ask
}
Why do you need a safe alias? I mean, the $input is self-triggered, not like any one is going to exploit it.
Posted By: DJ_Sol

Re: * $input: cannot use in an event - 03/03/11 01:42 PM

I don't see why you need an input box to pop up when the sock closes. It will close regardless. If I want to have it automatically reconnect I have a switch for reconnect. If switch is true it will reconnect, otherwise it wont.

For messages there is the $tip function that works nicely. Or you can create a dialog for messages.
Posted By: Riamus2

Re: * $input: cannot use in an event - 03/03/11 02:08 PM

@Tomao: I can't test it right now, but I'm pretty sure what you have in your most recent post won't work. $input cannot be used in an event. You can put the $input on a timer to get around that issue, but you haven't done so. You put the timer on the echo line instead.

Also, you are echoing within 1 second of displaying the $input (even if it did work) and it's unlikely anyone will click touch that input box within that time period.

This should work fine if you want the value set as a variable (use whatever params you need). Though you cannot use echo (even on a timer) with this method because you don't know how long it will take before someone presses something.
Code:
.timer 1 1 var %input = $!input(Please click something)


Instead, you could use an alias...
Code:
.timer 1 1 $!iif($input(Please click something),clickedok,clickedcancel)
alias clickedok { echo -a clicked ok }
alias clickedcancel { echo -a clicked cancel }


I believe that's what Tomao was doing with $! in the $iif().

@westor: Please explain why you think you need an $input box here. It is almost guaranteed that $input isn't what you should really be using regardless of any workarounds that can be used to make it work. What exactly are you trying to accomplish with $input ? As mentioned, you can easily include a real dialog, or a $tip or some other method of communication here instead of $input and it would be better.
Posted By: westor

Re: * $input: cannot use in an event - 03/03/11 02:20 PM

Originally Posted By: Riamus2
@Tomao: I can't test it right now, but I'm pretty sure what you have in your most recent post won't work. $input cannot be used in an event. You can put the $input on a timer to get around that issue, but you haven't done so. You put the timer on the echo line instead.

Also, you are echoing within 1 second of displaying the $input (even if it did work) and it's unlikely anyone will click touch that input box within that time period.

And, I'm just wondering... why are you using $iif() there? You true/false are exactly the same, so it doesn't do anything that I can see.

This should work fine if you want the value set as a variable (use whatever params you need). Though you cannot use echo (even on a timer) with this method because you don't know how long it will take before someone presses something.
Code:
.timer 1 1 var %input = $!input(Please click something)


Instead, you could use an alias...
Code:
.timer 1 1 $!iif($input(Please click something),clickedok,clickedcancel)
alias clickedok { echo -a clicked ok }
alias clickedcancel { echo -a clicked cancel }


@westor: Please explain why you think you need an $input box here. It is almost guaranteed that $input isn't what you should really be using regardless of any workarounds that can be used to make it work. What exactly are you trying to accomplish with $input ? As mentioned, you can easily include a real dialog, or a $tip or some other method of communication here instead of $input and it would be better.


man i have built an auto-update script and putted an $input identifier on the SOCKCLOSE event so when the download file completes then ask for updating or not that i wanna make and i thing the $input identifier.

also this code does not working

Code:
.timer 1 1 var %input = $!input(Please click something)
Posted By: Riamus2

Re: * $input: cannot use in an event - 03/03/11 02:32 PM

What isn't working with it? Does it pop up the $input?

As for your update script, you should do this instead...

Code:
on *:sockclose:mysock: {
  .timer 1 1 CheckUpdate
}
alias CheckUpdate {
  if ($input(Do you want to update?,y)) {
    ; whatever commands to do the update
  }
  else {
    ; whatever commands if you don't want the update
  }
}


* You can, of course, rename the alias and adjust the input text.
Posted By: westor

Re: * $input: cannot use in an event - 03/03/11 02:42 PM

I tryied but return the same error * $input cannot use in an event
Posted By: DJ_Sol

Re: * $input: cannot use in an event - 03/03/11 02:44 PM

Yeah using an alias would be much better.

I personally have a dialog for my updates. I have a list with checkboxes for each file. When the update is finished it removes the updated files from the list so you can check more updates or close the dialog.
Posted By: Riamus2

Re: * $input: cannot use in an event - 03/03/11 02:44 PM

See the edit. I missed a character. That should work now. I can't test right now.
Posted By: Riamus2

Re: * $input: cannot use in an event - 03/03/11 02:47 PM

Yeah, a real dialog is a very good option. $input is useful for really minor things, but using a real dialog gives you far greater control and customization. And dialogs can be used anywhere. $input halts everything that follows it, which is why it cannot be used in an event. Dialogs don't halt anything, so they can be used in events without a problem.
Posted By: westor

Re: * $input: cannot use in an event - 03/03/11 02:54 PM

Any way i will change it with a dialog option, the code still not working! the input does not opening to select yes or no!
Posted By: jaytea

Re: * $input: cannot use in an event - 03/03/11 03:16 PM

Sat wrote an article that highlights the difference between these types of events:

http://www.xise.nl/mirc/wiki/doku.php?id=critical_events

there are cases where it is much more convenient to circumvent mIRC's detection of $input in a 'critical' event (and it is actually possible to do so in mIRC script) but this isn't one of those cases :P using a split second timer to call an alias containing the appropriate segment of code is easy here.
Posted By: DJ_Sol

Re: * $input: cannot use in an event - 03/03/11 03:20 PM

If you really want to use $input just use a timer for the alias.

on *:sockclose:mysock: {
timer -m 1 500 CheckUpdate
}
Posted By: Riamus2

Re: * $input: cannot use in an event - 03/03/11 03:34 PM

Yeah, I forgot the timer. Oops. wink
Posted By: westor

Re: * $input: cannot use in an event - 03/03/11 04:26 PM

Any way i have change my code removing the update confirmation whistle
Posted By: westor

Re: * $input: cannot use in an event - 03/03/11 04:27 PM

Thanks all for the help!
© 2019 mIRC Discussion Forums