$deltok(string,range,delimiter)
1] Deltok with positive range
1 = this
2 = is
3 = a
4 = test
$deltok(this is a test,1,32)
-> range: 1 = this
-> result: is a test
$deltok(this is a test,2-3,32)
-> range: 2-3 = is a
-> result: this test
$deltok(this is a test,3-,32)
-> range: 3- = a test
-> result: this is
In other words, you can specify a range by using the - sign, which will remove these tokens from the string. If you specify N-, then anything from the token N will be deleted, since we don't specify an end point, just a beginning point.
2] Deltok with negative range
When the range is preceded by a minus sign (-), it means that mIRC will reference to the tokens in backwards order. Meaning -1 = the last token in the string, -2 the one before that, etc.
So:
-1 = test
-2 = a
-3 = is
-4 = this
$deltok(this is a test,-1,32)
-> range: -1 = test
-> result: this is a
$deltok(this is a test,-3,32)
-> range: -3 = is
-> result: this a test
$deltok(this is a test,-3-,32)
-> range: -3- = is a test
-> result: this
What just happened? The range is -3-. This means:
a) Delete the third token, counting from the end of the string.
b) Don't only delete the third token, but anything following that.
The result is that "is a test" is deleted from the string.
Regarding your user data, provided in this thread:
ADAMS JOEL E 03405 005 QUAL 13 NOV 04
ACHORD THOMAS 19908 003 QUAL 23 SEP 05
If the name of a person would always be 2 tokens, then we would not need to use $deltok, because we can get that info by using $gettok($1-,1-2,32).
However, the number of tokens which define a name, is variable. In other words, we don't know the range. What we do know, on the other hand, is that there are always 6 tokens following the name, so the solution is at hand. We simply delete the 6 tokens with $deltok, by referencing them in backwards order.
$deltok(ADAMS JOEL E 03405 005 QUAL 13 NOV 04,-6,32)
-> result: ADAMS JOEL E 005 QUAL 13 NOV 04
-> the sixth token, counting backwards is "03045", is deleted
$deltok(ADAMS JOEL E 03405 005 QUAL 13 NOV 04,-6-,32)
-> result: ADAMS JOEL E
-> the sixth token, counting backwards, and everything following it, is deleted
I hope you found this mini-tutorial regarding deltok handy, and that you can create a solution for your problem.
Greets