View Single Post
Old 12-18-2014, 10:46 PM  
DayCuts
Senior Member
 
Join Date: Dec 2003
Posts: 421
Default Custom command improvement/discussion

First of all a potential bug/issue, unless I am misusing or missing something...

Take the following example...

Code:
%d[input]
{
command $replace(%f,"s","z",1) %1
}
Gives the following result...

Code:
[13:19:24] [L] command tezt testinput
[13:19:26] [L] 200- ... 
[13:19:27] [L] 200 Command Successful.
[13:19:24] [L] command anothertezt testinput
[13:19:26] [L] 200- ... 
[13:19:27] [L] 200 Command Successful.
[13:19:32] [L] testinput
[13:19:33] [L] 500 'testinput': Command not understood.
As you can see after the code blocks are performed on each item selection the raw string from %d[] is sent to the server. Not sure if this is intentional?

I realize in this basic example I could just replace the %1 with %d[] and remove the code block, and if i need to use the input multiple times within a code block i can reference %1 for the rest. Moving %d[] inside the code block will only prompt once (i assume intentionally) but will then send the raw string from %d[] to the server for each iteration.

I then tried doing things some other ways and came across some unexpected results...

Code:
command:
%d[input]
{
command $replace(%f,"s","z",1) $replace(%1,"e","o")
}
result:
[13:19:24] [L] command tezt
[13:19:26] [L] 200- ... 
[13:19:27] [L] 200 Command Successful.
[13:19:24] [L] command anothertezt
[13:19:26] [L] 200- ... 
[13:19:27] [L] 200 Command Successful.
[13:19:32] [L] testinput
[13:19:33] [L] 500 'testinput': Command not understood.
Code:
command:
command $replace(%f,"s","z",1) $replace(%d[input],"e","o")
result:
[13:19:24] [L] command tezt
[13:19:26] [L] 200- ... 
[13:19:27] [L] 200 Command Successful.
[13:19:24] [L] command anothertezt
[13:19:26] [L] 200- ... 
[13:19:27] [L] 200 Command Successful.
This indicates to me that multiples of the same token modifier can't be use in a single line of a custom command. I tried with $uppercase as the second modifier which worked.

In summery:
1. Should the string input from %d[], when placed at the start of the line, be sent to the server? And if so can this be solved by adding a /noop (no operation) command.
2. Is it intentional for a token modifier to be limited to one instance per line, or is this a bug that can be fixed? If it is intentional then a solution might be to add variable support to the custom command interface. /var <key> <value> and $var(<key>) (or %v[<key>] etc, whichever fits best with the syntax standard) with support for performing /var <key> $modifier(%v[<key>],...) (which might be a useful addition anyway)
DayCuts is offline