mIRC Home    About    Download    Register    News    Help

Topic Options
#142642 - 18/02/06 07:12 PM /unset not accepting forced evaluation of variable
BlueGhost Offline
Nutrimatic drinks dispenser

Registered: 17/02/04
Posts: 8
It's an old problem that I'd hoped had been fixed by now, but it's still here:

ex.:
/set %test %test2
/set %test2 proof-of-concept
Here %test2 will return "proof-of-concept"

Now I can reset %test2 by forcing an evaluation in a script:
/set [ [ %test ] ] success
And from now on %test2 will return "success"

HOWEVER:
Should I want to delete %test2 this way it will fail:
/unset [ [ %test ] ] will not unset %test2, it will ignore the forced evaluation and unset %test instead.

The bug is reproducible and has been encountered by me frequently.
Is it a known problem ?

Top
#142643 - 18/02/06 07:17 PM Re: /unset not accepting forced evaluation of vari
Limerick Offline
Ameglian cow

Registered: 27/10/03
Posts: 18
Confirmed, sorry, I don't have a solution for you however ;p

Top
#142644 - 18/02/06 07:18 PM Re: /unset not accepting forced evaluation of vari
BlueGhost Offline
Nutrimatic drinks dispenser

Registered: 17/02/04
Posts: 8
Oh well, I usually make due with setting the variable to another value (such as "unset", "no", etc...) depending on the situation.

Just thought I'd let you guys know just in case...

Top
#142645 - 18/02/06 07:22 PM Re: /unset not accepting forced evaluation of variable
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
If you need a workaround, just use //unset $(%test)
_________________________
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Top
#142646 - 18/02/06 07:31 PM Re: /unset not accepting forced evaluation of vari
Limerick Offline
Ameglian cow

Registered: 27/10/03
Posts: 18
Interesting, from the help file:

$(...)
This identifier can only be used in the text match section of an event definition.

So I would have assumed it wouldn't work in an /unset.

Top
#142647 - 18/02/06 07:33 PM Re: /unset not accepting forced evaluation of vari
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
$(...) outside of a matchtext section is basically $eval(...)

Top
#142648 - 18/02/06 07:33 PM Re: /unset not accepting forced evaluation of vari
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
$() is actually a shorter equivalent of $eval(), when used outside the <matchtext> field.
_________________________
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Top
#142649 - 18/02/06 07:33 PM Re: /unset not accepting forced evaluation of vari
FiberOPtics Offline
Hoopy frood

Registered: 05/02/04
Posts: 2019
Loc: Leuven, Belgium
$() is a shortcut for $eval, although in an event matchtext/location part you can only use the shortcut (and without specifying a level of evaluation). In all other uses $() and $eval() are identical.

EDIT: Drat, cursed with qwerty's old habit again, ironically losing to him! Oh yea and hixxy too ROFL. All posted in the same minute grin
_________________________
Gone.

Top
#142650 - 18/02/06 07:37 PM Re: /unset not accepting forced evaluation of vari
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
I win cool

Top
#142651 - 18/02/06 07:38 PM Re: /unset not accepting forced evaluation of vari
Limerick Offline
Ameglian cow

Registered: 27/10/03
Posts: 18
Well, each preceding post added more detail, so it's all good ;p

Top
#142652 - 18/02/06 11:03 PM Re: /unset not accepting forced evaluation of variable
ScreeM Offline
Self-satisified door

Registered: 18/02/06
Posts: 3
/set [ [ %test ] ] success
; bad set value


the set is;

set % [ $+ [ test ] ] success
unset % [ $+ [ test ] ]

Top
#142653 - 18/02/06 11:30 PM Re: /unset not accepting forced evaluation of vari
BlueGhost Offline
Nutrimatic drinks dispenser

Registered: 17/02/04
Posts: 8
Quote:
/set [ [ %test ] ] success
; bad set value


the set is;

set % [ $+ [ test ] ] success
unset % [ $+ [ test ] ]


What are you talking about ?
I took the liberty of testing those -just to make sure- and as I expected, neither of them work.

Top
#142654 - 19/02/06 05:57 AM Re: /unset not accepting forced evaluation of vari
FTLNewsFeed Offline
Nutrimatic drinks dispenser

Registered: 13/07/05
Posts: 7
BlueGhost, what ScreeM is talking about is dynamic variables...

lets say you have a while loop

while (%i <= %number) {

and you want to create variables as the loop runs, then you can use evaluation brackets to force new variables to be created:

var %var. [ $+ [ %i ] ] what-you-want-it-set-to

everytime that loop runs a set of vars will be created with whatever the loop pulled up.
These can also be unset in the loop by having:

unset %var. [ $+ [ %i ] ]

if we didn't use the evaluation brackets the loop would create one var: %var.%i (literally %i) which is what we don't want... hoped this helped...

P.S. the equal sign is not used when creating this local variable b/c the variable would include it in whatever was set (quirky, I know)


Edited by FTLNewsFeed (19/02/06 06:00 AM)

Top
#142655 - 19/02/06 07:18 AM Re: /unset not accepting forced evaluation of vari
Cork Offline
Ameglian cow

Registered: 16/06/04
Posts: 20
FTLNewsFeed, what BlueGhost is looking for seems to be a pointer.
And hes right it dosnt work for unset, but you can use eval in stead to get the right behaviour.
Code:
alias test {
  set %test % $+ test2
  set %test2 proof-of-concept
  echo -a %test2 will return "proof-of-concept"

  set [ [ %test ] ] success
  echo -a %test2 will return "success"

  ; unsets %test2
  unset $eval(%test, 1)
  ; unsets %test
  unset [ [ %test ] ]
}


Edited by Cork (19/02/06 07:19 AM)

Top
#142656 - 19/02/06 09:45 PM Re: /unset not accepting forced evaluation of vari
FTLNewsFeed Offline
Nutrimatic drinks dispenser

Registered: 13/07/05
Posts: 7
Cork, when I tried your code I got:

* Set %test to %test2
* Set %test2 to proof-of-concept
proof-of-concept will return "proof-of-concept"
* Set %test2 to success
success will return "success"
* Unset %test2
* /unset: insufficient parameters (line 62, aliases.ini)

(I added the -s switches and tried it in Aliases without the 'alias' and Remotes with it just to be sure)

but... when I chaged the last line to:

unset % [ $+ [ test ] ]

it worked like a charm and I got:

* Set %test to %test2
* Set %test2 to proof-of-concept
proof-of-concept will return "proof-of-concept"
* Set %test2 to success
success will return "success"
* Unset %test2
* Unset %test

but I get what BlueGhost is saying, I was trying to explain where ScreeM was coming from and why BG wasn't getting the same results.

Top