Opened 14 years ago
Closed 13 years ago
#2109 closed Feature Request (Rejected)
ProcessList and WinList should accept Default or -1
| Reported by: | Owned by: | ||
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | Severity: | None | |
| Keywords: | ProcessList WinList Default | Cc: |
Description
When we use ProcessList or WinList with Default keyword or with -1, the function recognize it like a string, and searches for window/process with Default/-1 title/process name.
Sometimes we need to pass the parameters of our UDF to ProcessList/WinList function, and we should be able to set it as Default/-1.
Example:
Func _MyUDF($sTitle = Default) $aWinList = WinList($sTitle) .... EndFunc
If the user omit the $sTitle parameter, the result will be wrong.
For now i must do this:
Func _MyUDF($sTitle = Default) If (IsKeyword($sTitle) And $sTitle = Default) Or $sTitle = -1 Then $aWinList = WinList() Else $aWinList = WinList($sTitle) EndIf .... EndFunc
The same issue with ProcessList.
Attachments (0)
Change History (5)
comment:1 by , 14 years ago
| Version: | 3.3.8.0 |
|---|
comment:2 by , 14 years ago
| Resolution: | → Rejected |
|---|---|
| Status: | new → closed |
The functions will never accept -1 because -1 is a number. To specify an default parameter for a string you use "". There is some merit to accepting the Default keyword. However your usage case just boils down to I'm too lazy to write If $param = Default Then $param = "" before you pass it to a function so I'm not inclined to make changes to the language itself to save you a single line of code.
follow-up: 4 comment:3 by , 14 years ago
Replying to Valik:
To specify an default parameter for a string you use ""
It's the same, it will not return all processes/windows list. Perhaps it's a bug (if you say it should work).
And it's not about me been lazy (it's not in my nature :) ), this is about inconsistency with other functions that accept Default, and we talking about [optional] parameter.
comment:4 by , 14 years ago
| Resolution: | Rejected |
|---|---|
| Status: | closed → reopened |
Replying to MrCreatoR <mscreator@…>:
It's the same, it will not return all processes/windows list. Perhaps it's a bug (if you say it should work).
Without looking the code probably does something different when there are no parameters. What that means is the function doesn't support any form of default behavior so adding Default isn't just filling in missing functionality but adding new functionality.
And it's not about me been lazy (it's not in my nature :) ), this is about inconsistency with other functions that accept Default, and we talking about [optional] parameter.
Look at many of the cases where Default is supported. It's in places where you want to skip parameters so you can access later parameters. For example, in WinMove() you might use Default for width so you can specify a new height. In this case you are asking for Default to exist on the only parameter the function takes (in the case of ProcessList()). So no, it's really not inconsistent.
I'll re-open this merely to remind myself to look and see what is going on with the functions. I'm still not convinced supporting Default is really useful for these functions.
comment:5 by , 13 years ago
| Resolution: | → Rejected |
|---|---|
| Status: | reopened → closed |

Automatic ticket cleanup.