mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2009
Posts: 12
E
Pikka bird
OP Offline
Pikka bird
E
Joined: Oct 2009
Posts: 12
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?

Last edited by err0r007; 10/10/21 09:17 PM.
Joined: Jul 2014
Posts: 308
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jul 2014
Posts: 308
Try it this way:
Code
alias testfail {
  if (!%bleh) { set -e %bleh 1 }
  else { echo -a is set }
}


TECO
irc.PTirc.org (Co-Admin)
Joined: Oct 2009
Posts: 12
E
Pikka bird
OP Offline
Pikka bird
E
Joined: Oct 2009
Posts: 12
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.

Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
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


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
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.

Joined: Oct 2009
Posts: 12
E
Pikka bird
OP Offline
Pikka bird
E
Joined: Oct 2009
Posts: 12
Thank you for the information.


Link Copied to Clipboard