Modify ↓
#727 closed Bug (No Bug)
Optional parameter not declared when func called via OnEventMode
| Reported by: | wraithdu | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.2.13.11 | Severity: | None |
| Keywords: | Cc: |
Description
This script will crash when the button is clicked with an error saying $var is not declared. In message mode, this crash does not happen.
Opt("GUIOnEventMode", 1)
$GUI = GUICreate("GUI")
$button = GUICtrlCreateButton("Test", 10, 10, 50, 20)
GUICtrlSetOnEvent(-1, "_Test")
GUISetOnEvent(-3, "_Exit")
GUISetState()
While 1
Sleep(1000)
WEnd
Func _Test($var = "")
If $var == "" Then Return 0
Return $var
EndFunc
Func _Exit()
Exit
EndFunc
Attachments (0)
Change History (3)
comment:1 by , 17 years ago
| Resolution: | → No Bug |
|---|---|
| Status: | new → closed |
comment:3 by , 17 years ago
I know this is probably not kosher, but I've used code like this for the occasional shortcut.
Func _Test($var = "")
If Not IsDeclared('var') Then Return 0
Return $var
EndFunc
It should work in your situation.
Note:
See TracTickets
for help on using tickets.

It does not crash. It errors out with the expected error since what you are trying to do is not supported.