Input command with wildcard option

Report problems with documented functionality
sirksel
Posts: 222
Joined: 12 Nov 2013, 23:48

Input command with wildcard option

13 Nov 2013, 00:12

The Input command is not behaving as expected with respect to the * (wildcard) option. It does not appear to behave consistently when terminating input and returning a partial match. (This appears to be the case in all versions I've tried...) For example, given the following code:

Code: Select all

Input, lInput, T3*, {Enter}{Escape}, a,bb,bcedqas,d
MsgBox % lInput "`n" ErrorLevel
Here are some examples of expected/unexpected behavior:
1. (EXPECTED) If you enter "ed", "ed" is returned as a partial match for "bcedqas" with ErrorLevel Match.
2. (EXPECTED) If you enter "qa", "qa" is returned as a partial match for "bcedqas" with ErrorLevel Match.
3. (UNEXPECTED) If you enter "bc", command times out, rather than returning partial match for the first 2 chars of "bcedqas" (which seems to be an unambiguous match).
4. (UNEXPECTED) If you enter "s", command times out, rather than returning partial match for the last char of "bcedqas".
5. (UNEXPECTED) If you enter "q", command times out, rather than returning partial match for the 5th char of "bcedqas".
6. (UNEXPECTED) If you enter "za", "za" is returned as a partial match (for what, I don't know) with ErrorLevel Match. It seems like this shouldn't be the case because "za" isn't contained within any of the strings!

The reason that #1, #2 and #6 (above) match appears to be because the second characters "d" and "a" and "a", respectively, are also standalone matches in the list. I don't think this is the intent of the command, right? Is this fixable?

I admit this is just a small issue, and the language on the whole is terrific. Once again, Lexikos and others, thanks for all your work making AHK the great language that it is today!
Last edited by sirksel on 13 Nov 2013, 05:22, edited 1 time in total.
gregster
Posts: 9000
Joined: 30 Sep 2013, 06:48

Re: POSSIBLE BUG: Input command with wildcard option

13 Nov 2013, 01:50

I think you misunderstood how the Input command works, especially in partial match mode *. If you type something, the function takes the matchlist and looks if any of the comma separated single key phrases (here: a bb bcedqas d) are completely part of the string you put in, your input string might have other leading characters, though. Not the other way round! If your input doesn't match or matches only a part of every single member of the matchlist, there is no match (and eventually timeout in the end), that means, you must have a string like 'a', 'bb', 'd' or 'bcedqas' in your input to get a (partial) match.
1. (EXPECTED) If you enter "ed", "ed" is returned as a partial match for "bcedqas" with ErrorLevel Match.
2. (EXPECTED) If you enter "qa", "qa" is returned as a partial match for "bcedqas" with ErrorLevel Match.
3. (UNEXPECTED) If you enter "bc", command times out, rather than returning partial match for the first 2 chars of "bcedqas" (which seems to be an unambiguous match).
4. (UNEXPECTED) If you enter "s", command times out, rather than returning partial match for the last char of "bcedqas".
5. (UNEXPECTED) If you enter "q", command times out, rather than returning partial match for the 5th char of "bcedqas".
6. (UNEXPECTED) If you enter "za", "za" is returned as a partial match (for what, I don't know) with ErrorLevel Match. It seems like this shouldn't be the case because "za" isn't contained within any of the strings!
Thus,
1. match, because 'ed' contains 'd' (explicitly part of the matchlist: a bb bcedqas d ), the leading 'e' doesn't matter because you use the 'partial match mode'
2. match, because 'qa' contains 'a' (explicitly part of the matchlist), the leading 'q' doesn't matter because you use the 'partial match mode'
3. time out, because no single 'bc' is no part of the matchlist
4. time out, because no single 's' is no part of the matchlist
5. time out, because no single 'q' is no part of the matchlist
6. match, because a single 'a' is explicitly part of the matchlist, the leading 'z' doesn't matter because you use the 'partial match mode'

In partial match mode, if you would try to input 'bcedqas', input would be terminated already with a match in the moment you typed 'bced', because 'd' is a match (as part of your matchlist: "any of which will cause the Input to be terminated", see http://ahkscript.org/docs/commands/Input.htm).

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 47 guests