mIRC Homepage

input question

Posted By: pouncer

input question - 21/10/06 10:18 AM

var %email = $input(Enter email, qe, email, email), %p = $input(password, pqe, enter password)

if i click the cance button on email, how do i get it to shop showing the input for password
Posted By: FiberOPtics

Re: input question - 21/10/06 10:31 AM

Code:
var %email = $input(...)
if (* iswm %email) {
  ; verify if entered email has correct syntax 
  ; ask for password
  var %p = $input(...)
}
else {
  ; no email was entered, take necessary steps
}

Posted By: pouncer

Re: input question - 21/10/06 10:47 AM

thanks, didn't work though, when i click cancel it still goes to the password box

the email input box has a default value of 'email' in it

i thought i might need to use $true or $false to show the cancel button has been clicked
Posted By: FiberOPtics

Re: input question - 21/10/06 10:59 AM

There is no way that it asked for the password if you used my code exactly as it is above.

It will only ask your password if you clicked OK, not if you click Cancel, because when you click cancel, the input like you have it returns nothing ($null) so the if (* iswm %email) check is $false, which means it jumps to the else part where I didn't put any code.

Code:
alias test {
  var %email = $input(Enter email, qe, email, email)
  if (* iswm %email) {
    ; verify if entered email has correct syntax 
    ; ask for password
    var %p = $input(password, pqe, enter password)
    echo -a Email: %email -- Password: %p
  }
  else {
    ; no email was entered, take necessary steps
    echo -a No email was entered
  }
}

/test

Using mIRC 6.2 btw.
Posted By: pouncer

Re: input question - 21/10/06 11:45 AM

ok, sorted it, thanks alot.
Posted By: Lpfix5

Re: input question - 21/10/06 07:19 PM

you can also use $?*="Title" to have it return ******* for your password
Posted By: hixxy

Re: input question - 21/10/06 07:23 PM

It already works like that. The 'p' flag in $input() enables the password chars.
Posted By: Mardeg

Re: input question - 22/10/06 10:25 AM

Code:
var %email =  [color:red]$[/color]$input(Enter email, qe, email, email), %p = $input(password, pqe, enter password) 
Posted By: FiberOPtics

Re: input question - 22/10/06 11:33 AM

That would not only stop the current code without warning, but also any other code where his alias was called from, in case cancel was pressed (or nothing entered).

In other words, hardly good advice.
Posted By: hixxy

Re: input question - 22/10/06 01:35 PM

Agreed. I'd take a large script that reports errors to me over a small script that gives me no feedback any day.
Posted By: Mardeg

Re: input question - 23/10/06 10:06 AM

Sorry, I didn't check that pressing cancel on an $$input doesn't cause code after an :error in the alias to be executed. Is there a reason why it shouldn't?
Posted By: FiberOPtics

Re: input question - 23/10/06 04:55 PM

I don't think you understand the usage of $$.

When an identifier starts with $$ rather than $, it means the running script (and any higher level code from which this script is called) will halt completely if the identifier returns $null. If you press cancel on the $$input that asks for an email, the identifier returns $null, so this code stops immediately (think of it like a /halt is inserted at the code where you have the indentifier with $$)

To answer your question: why doesn't it jump to the :error label? Well why should it? No mIRC error occured, so there's no reason to jump to the error label.

$$ has its usages, though in a case like this, it's clearly a better option to let the script handle it when an email was not supplied (like echoing a message about missing email, and taking some other steps) than to simply have the entire script halted without a warning whatsoever from the script.
Posted By: Mardeg

Re: input question - 24/10/06 08:13 AM

Thank you for that explanation. The /halt analogy works for me smile
© 2021 mIRC Discussion Forums