mIRC Home    About    Download    Register    News    Help

Print Thread
#263520 14/08/18 08:55 PM
Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
/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.

Joined: Dec 2002
Posts: 5,412
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,412
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.

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


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Dec 2002
Posts: 5,412
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,412
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.

Joined: Jul 2006
Posts: 4,146
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
Thanks for looking into it, I'll do some tests with the beta.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2006
Posts: 4,146
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
$parms seems to work correctly, thanks.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard