Modify

Opened 16 years ago

Closed 16 years ago

Last modified 16 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 Changed 16 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 16 years ago by wraithdu

Fair enough. I can work around it then.

comment:3 Changed 16 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
EndFunc

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

Action
as closed The ticket will remain with no owner.
Author


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

 
Note: See TracTickets for help on using tickets.