mIRC Homepage

Issue with set variable in version 7.67

Posted By: err0r007

Issue with set variable in version 7.67 - 10/10/21 04:50 PM

I noticed one of the updates included: Fixed how /set/unset/inc/dec/timer/sockread %vars are evaluated in some contexts.

Now setting a variable inside $iif statement isn't working for me.

ie:
alias testfail { $iif(!%bleh,set -e %bleh 1,echo -a is set) }

gives error * /set: invalid parameters

Are the changes intended to have this outcome?
Posted By: TECO

Re: Issue with set variable in version 7.67 - 10/10/21 09:31 PM

Try it this way:
Code
alias testfail {
  if (!%bleh) { set -e %bleh 1 }
  else { echo -a is set }
}
Posted By: err0r007

Re: Issue with set variable in version 7.67 - 10/10/21 09:49 PM

My post isn't meant to find an alternative but rather to figure out if this is the intended result now or if this is a bug. But I do appreciate you posting to offer a solution.
Posted By: Wims

Re: Issue with set variable in version 7.67 - 10/10/21 09:59 PM

For me it is intended. the true part of the $iif is evaluated and %bleh gets evaluated to nothing if it's not set, giving a set error once the parser is done evaluating the command line and execute your set command
Posted By: maroon

Re: Issue with set variable in version 7.67 - 11/10/21 12:56 AM

It looks like you were trying to take advantage of bug behavior which has now been fixed. A summary of commands that worked wrong before but work correctly now are in:
https://forums.mirc.com/ubbthreads....-in-an-identifier-breaks-vars#Post269305

While you can create the command string inside the $iif, it should not be evaluated inside there. What's you're seeing now is that the string inside the $iif is being created as it should be, including evaluating the %variable into its contents, and the error is that when the string is being evaluated there is no %word like there should be.

The correct syntax you should have been using is in testfail2.

Code
alias testfail {
  unset %bleh
  $iif(!%bleh,set -su1 %bleh $scriptline,echo -a is set) 
}
alias testfail2 {
  unset %bleh
  $iif(!%bleh,set -su1 % $+ bleh $scriptline,echo -a is set) 
}
alias testfail3 {
  unset %bleh
  var %bleh 1 | echo -a test1 = $iif(!%bleh,set -su1 %bleh $scriptline,echo -a %bleh is set)
  unset %bleh | echo -a test2 = $iif(!%bleh,set -su1 %bleh $scriptline,echo -a %bleh is set) 
  echo -a result: %bleh
}


I added the -s switch to more easily see when the variable is being set, and use the -u1 switch to ensure the variable doesn't get written to disk as part of a normal save of variables to disk, with the risk that mIRC crashes before the ON EXIT event can do cleanup.
Posted By: err0r007

Re: Issue with set variable in version 7.67 - 16/10/21 02:07 PM

Thank you for the information.
© 2021 mIRC Discussion Forums