Modify

Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#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 Valik, 17 years ago

Resolution: No Bug
Status: newclosed

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

comment:2 by wraithdu, 17 years ago

Fair enough. I can work around it then.

comment:3 by Rob Saunders <therks@…>, 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.

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.