Opened 15 years ago

Closed 15 years ago

Last modified 15 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: Severity: None
Keywords: Cc:


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")

While 1

Func _Test($var = "")
	If $var == "" Then Return 0
	Return $var

Func _Exit()

Attachments (0)

Change History (3)

comment:1 Changed 15 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

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

comment:2 Changed 15 years ago by wraithdu

Fair enough. I can work around it then.

comment:3 Changed 15 years ago by Rob Saunders <therks@…>

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

It should work in your situation.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The ticket will remain with no owner.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.