mIRC Home    About    Download    Register    News    Help

Topic Options
#242420 - 12/07/13 03:18 PM $v1 not filled in popups
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3475
Loc: France
Quote:
menu * {
$iif(%toggle,$style(1)) POPUPS ( $v1 ) :{ echo -a > $v1 | set %toggle $iif($v1,$false,$true) }
}
I was expecting this to work, but $v1 is $null when executing the commands. Why would $v1 be $null here? Seems like a bug to me.
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#242422 - 12/07/13 07:35 PM Re: $v1 not filled in popups [Re: Wims]
Sat Offline
Hoopy frood

Registered: 19/04/04
Posts: 832
Loc: The Netherlands
Perhaps because the left side is evaluated when loading (showing) the popup and the right side is evaluated when you actually click on something?
_________________________
Saturn, QuakeNet staff

Top
#242425 - 12/07/13 08:50 PM Re: $v1 not filled in popups [Re: Sat]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3475
Loc: France
That's for sure Sat smile , it's similar to others inconsistencies:
$v1 with filter -k and $regml() with filter -kg

The reason it's not working are obvious now, $v1 works outside a scope but it's not working if the call chain is broken (filter breaking the call chain is another topic)

Yet it would make it consistent to re-fill $v1 in those specific situations, it's really about refilling $v1 in a popups menu, after the popups has been displayed and refilling it when filter -k is used (making it consistent by changing $v1 not to work outside statements doesn't make sense and is not an option). This is a logical follow up imo, I would like $v1 to work whenever it can in a logic way, regardless of the technical issue.

It's not something difficult to add, it wouldn't break any script, and as far as filter and $regml are concerned, it would make things working as intended, one typically use filter for the speed, if you use a regular expression and you call an alias (-kg), if you have to remake a $regex call inside the callback alias to fill $regml, it looks wrong..

Really, things are working as they meant to be, they just were meant to be working in a way that can be seen as incorrect, or incomplete, leading to inconsistencies, this is also true for things like $1- being used inside $regsubex, how would one know, how many people have to report the problem so it gets added to the help file? I might be the only one making it a big deal but anyone could face the situation.

A note in the help file "$v1 won't work in some specific situations" wouldn't make much sense, but the actual situation is also a problem, scripters should be able to know about inconsistencies when they exist, even if 99% of scripters has no idea about them.


Edited by Wims (12/07/13 11:52 PM)
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#242438 - 13/07/13 05:11 PM Re: $v1 not filled in popups [Re: Wims]
Wiz126 Offline
Babel fish

Registered: 22/03/10
Posts: 57
There is no certainly no bug in there; it's a well understood behavior that the code associated with the menu item only gets evaluated when you click on that item. Because of that, you can think of your code as being placed in virtual aliases that get invoked.

Originally Posted By: Wims
The reason it's not working are obvious now, $v1 works outside a scope but it's not working if the call chain is broken (filter breaking the call chain is another topic)


By 'call chain' I assume we mean mIRC is executing the code from it internally from the same root function that executed the original code that created $v1. While that's true in general, it's not really true for /filter since the call chain is not broken. Note that in the menu scenario, it does happen.

Originally Posted By: Wims
It's not something difficult to add,...


No need to quote the rest of the statement however in the case of the menu it's actually not possible to implement it in a sane way, that would require keeping all kind of strange states. Imagine the following code:

Code:
menu * {
  $iif(1,1):echo -a $v1
  $iif(2,2):echo -a $v1
  $iif(3,3):echo -a $v1
}


If I click 1, will echo print 1 as well? What happens when I click 2? The most logical thing to do is what mIRC currently does - start from blank and execute the code associated with that item. To make it print 1/2/3 for the three menu items respectability requires a hell lot of work with little to no gain and mIRC will now have to keep individual states for each menu item code segment. You have to remember that the code in the item's name gets evaluated first. I.E. $iif(1,1) then $iif(2,2) then $iif(3,3) way before code associated with a specific item gets executed - if it even gets executed.


Edited by Wiz126 (13/07/13 05:16 PM)

Top
#242439 - 13/07/13 05:28 PM Re: $v1 not filled in popups [Re: Wiz126]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3475
Loc: France
You missed a bit my point, I only want mIRC to re-fill $v1, after it finished evaluating the content of what will be displayed for the popups, $v1 would be always 3 when clicking on an item in your example
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#242446 - 15/07/13 10:33 PM Re: $v1 not filled in popups [Re: Wims]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
Code:
alias hack {
  set %v1 $1
  return $1
}

menu * {
$iif(%toggle,$style(1)) POPUPS ( $hack($v1) ) :{ echo -a > %v1 | set %toggle $iif(%v1,$false,$true) }
}

Top
#242447 - 15/07/13 10:48 PM Re: $v1 not filled in popups [Re: hixxy]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3475
Loc: France
A terrible idea indeed, hixxy laugh
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#242448 - 15/07/13 10:51 PM Re: $v1 not filled in popups [Re: Wims]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
Hey it works! :p

Top
#242458 - 17/07/13 01:07 PM Re: $v1 not filled in popups [Re: Wims]
Khaled Offline


Planetary brain

Registered: 04/12/02
Posts: 4375
Loc: London, UK
The creation of the popup menu item is completely independent of the command that it calls. There is no way to pass state values (of which there are many - not just $v1) from one identifier evaluation into another separate identifier evaluation. The solution that hixxy provided is the only way to do what you want, as far as I can see.

Top
#242461 - 17/07/13 03:54 PM Re: $v1 not filled in popups [Re: Khaled]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3475
Loc: France
I know the creation is independent of the command called, but could you please elaborate on why you think there is no way to pass $v1 there (I'm not talking about others states)? The workaround hixxy provided works but it's what it is, a workaround to a problem, not a proper solution I overlooked.

What is your opinion on the $regml issue with /filter? Is the correct usage to make a new $regex call in the callback alias to fill $regml even though the regex match has already been made? Is there no way to change that too? If so, why?
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#242462 - 17/07/13 04:04 PM Re: $v1 not filled in popups [Re: Wims]
Khaled Offline


Planetary brain

Registered: 04/12/02
Posts: 4375
Loc: London, UK
There is no way to pass $v1 across independent calls to the script parser because the script parser was not designed to do that and for good reason. The $v1 value is part of the evaluation of a particular script call. It has no connection to any subsequent calls, so it would make no sense to make it persistent across calls. You will need to do what hixxy has suggested.

If I remember correctly, the /filter and $regml discussion is in a different thread. Please do not mix topics in the same thread, it makes it very difficult to keep track of discussions and bug reports.

Top