mIRC Home    About    Download    Register    News    Help

Print Thread
Problems with $parms #263520 14/08/18 08:55 PM
Joined: Jan 2004
Posts: 1,202
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,202
/help $parms
Quote:

$parms
Returns an untokenized $1- for events and other command/identifier calls.


Exceptions to $parms matching $1- within the context where $1- changes:

1. $parms is changed to $null inside the $iif(Conditional,$true,$false) but only in the "Conditional" location. It resumes having the correct $parms value in the $true and $false branchings, as well as beyond the $iif() statement.

2. $parms is changed to $null by the /tokenize command

3. $parms is changed to null within my_alias when called as $my_alias(string) but matches $1- when called as "/my_alias string".

Code:
/parms_test parms created by input event

alias parms_test {
  if ($isid) echo 4 -a parms passed to custom identifier is _null: $parms
  else echo       3 -a parms passed to custom /command is correct: $parms
}

on *:INPUT:*:{
  if (/parms_test * iswm $1-) {
    echo 3 -a parms in main event: length $len($parms) $parms
    noop $parms_test(test identifier)
    /parms_test test command
    echo 4 -a                                                                         parms in iif conditional                 is null: $iif($1- == $parms,same (Conditional: 1- is $v1 parms= $v2 ) TrueCond= $parms,diff (Conditional 1- is $1- parms= $v2 ) FalseCond= $parms) $chr(3) $+ 3beyond iif: $parms
    noop $findfile($mircdir,$nopath($mircini),0,1,echo 13 -a parms in findfile:$parms parms in iif_conditional-inside-findfile is null: $iif($1- == $parms,same (Conditional: 1- is $v1 parms= $v2 ) TrueCond= $parms,diff (Conditional 1- is $1- parms= $v2 ) FalseCond= $parms) $chr(3) $+ 3beyond iif: $parms )
    echo 3 -a parms before tokenize: (1-)= $1- / parms= $parms
    //tokenize 32 test string
    echo 4 -a parms .after tokenize: (1-)= $1- / parms= $parms
    halt
  }
}


To preserve backwards compatibility, perhaps /tokenize could be given a -p switch to have it set $parms to match the new $1- within the current alias/event/editbox? I can see the value in having /tokenize preserve the original $parms value, but not in resetting it to $null.

Re: Problems with $parms [Re: maroon] #263521 14/08/18 09:07 PM
Joined: Dec 2002
Posts: 4,563
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,563
Thanks for your bug report. These behaviours are all intentional. $parms depends entirely on the tokenization of parameters across multiple routines/features in multiple contexts. That is what $parms returns. This cannot be changed. If you need to use $parms in these contexts, you will need to store its value.

Re: Problems with $parms [Re: Khaled] #263524 14/08/18 11:07 PM
Joined: Jul 2006
Posts: 3,574
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,574
Quote:
$parms depends entirely on the tokenization of parameters across multiple routines/features in multiple contexts.
isn't $parms completely tied to $1-?

/tokenize is setting $1-; is $parms not being set by /tokenize because it's a command and therefore, $1- and $parms cannot be different after a /tokenize command (a fine argument to me, but I'm assuming that $parms should be set whenever $1- is set)? If not I'd like to hear from you about why /tokenize isn't setting $parms.

It seems to be that way since $parms is filled for custom command call, but not for custom $identifier call, and the only reason for this I can think of is the same as above: inside an identifier $parms and $1- would be equal since identifier indeed preserves spaces.


That being said, I'm pretty curious as how the $iif part is intended.
I'm still assuming that $parms is tied to $1- here, so if $iif sets $parms to $null (way of talking), I'd think that $iif call dealing with $1- in the condition could also see $1- being $null? However this has never been reported as far as I know.

Code:
alias testparms echo -a $parms - $iif($parms,yes $parms, no $parms) - $parms | if ($parms) echo -a yes $parms | else echo -a no $parms
type /testparms, the result is not making any sense, $iif is calling mIRC's /if function so if /if does not 'break' what is so different about $iif?


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Problems with $parms [Re: maroon] #265813 28/07/19 08:22 PM
Joined: Dec 2002
Posts: 4,563
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,563
I am going to include changes in the next beta that address the above issues.

Quote
1. $parms is changed to $null inside the $iif(Conditional,$true,$false) but only in the "Conditional" location. It resumes having the correct $parms value in the $true and $false branchings, as well as beyond the $iif() statement.

This should be fixed in the next beta.

Quote
$parms is changed to $null by the /tokenize command

In the next beta, /tokenize will set $parms to equal $1-. This is, in fact, necessary to ensure internal consistency with how parameters are propagated across functions. $parms will always return $1-.

Quote
$parms is changed to null within my_alias when called as $my_alias(string) but matches $1- when called as "/my_alias string".

This should be fixed in the next beta.

Unfortunately, due to the complexity of how parameters are passed/propagated across function calls, this required critical internal changes to the parser, so will need testing to make sure scripts are working in the same way as before.

Re: Problems with $parms [Re: Khaled] #265814 28/07/19 08:37 PM
Joined: Jul 2006
Posts: 3,574
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,574
Thanks for looking into it, I'll do some tests with the beta.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Problems with $parms [Re: Khaled] #265831 02/08/19 11:35 PM
Joined: Jul 2006
Posts: 3,574
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,574
$parms seems to work correctly, thanks.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net