mIRC Home    About    Download    Register    News    Help

Print Thread
Issue with set variable in version 7.67 #269468 10/10/21 04:50 PM
Joined: Oct 2009
Posts: 11
E
err0r007 Offline OP
Pikka bird
OP Offline
Pikka bird
E
Joined: Oct 2009
Posts: 11
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.
Re: Issue with set variable in version 7.67 [Re: err0r007] #269470 10/10/21 09:31 PM
Joined: Jul 2014
Posts: 242
TECO Offline
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2014
Posts: 242
Try it this way:
Code
alias testfail {
  if (!%bleh) { set -e %bleh 1 }
  else { echo -a is set }
}


TECO
irc.PTirc.org (Co-Admin)
Re: Issue with set variable in version 7.67 [Re: TECO] #269471 10/10/21 09:49 PM
Joined: Oct 2009
Posts: 11
E
err0r007 Offline OP
Pikka bird
OP Offline
Pikka bird
E
Joined: Oct 2009
Posts: 11
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.

Re: Issue with set variable in version 7.67 [Re: err0r007] #269472 10/10/21 09:59 PM
Joined: Jul 2006
Posts: 3,827
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,827
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


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Issue with set variable in version 7.67 [Re: err0r007] #269473 11/10/21 12:56 AM
Joined: Jan 2004
Posts: 1,637
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,637
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.

Re: Issue with set variable in version 7.67 [Re: maroon] #269497 16/10/21 02:07 PM
Joined: Oct 2009
Posts: 11
E
err0r007 Offline OP
Pikka bird
OP Offline
Pikka bird
E
Joined: Oct 2009
Posts: 11
Thank you for the information.