Modify

Opened 9 years ago

Closed 9 years ago

Last modified 6 years ago

#3108 closed Bug (No Bug)

function with optional parameters run via AdlibRegister() fails with "Variable used without being declared"

Reported by: alex@… Owned by:
Milestone: Component: AutoIt
Version: 3.3.14.0 Severity: None
Keywords: Cc:

Description

Given the following definition:

Func MyFunc($vVar = 123)
    MsgBox(0, 'MyFunc()', '$vVar = ' & $vVar)
EndFunc

I expect the MyFunc() function to run with $vVar set to 123 if called as MyFunc().

When run normally, the behaviour is as expected.

When run via AdlibRegister(), a "Variable used without being declared" error occurs.

MyFunc(456)
MyFunc()

AdlibRegister('MyFunc', 400)
Sleep(500)
AdlibUnRegister('MyFunc')

Attachments (0)

Change History (2)

comment:1 Changed 9 years ago by jchd18

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

This works as expected since AdlibRegister help explicitely mentions that You can not register a function using parameters.

Closing as "No bug".

comment:2 Changed 6 years ago by Bilgus

It seems this can be worked around with Eval()

Registered_Funct(250);Register
Sleep(10000)
Registered_Funct(-1);UnRegister

Func Registered_Funct($iTime = -1)
    Local $i_Time = Eval("iTime")
    If $i_Time > 0 Then
        AdlibRegister("Registered_Funct", $i_Time)
    ElseIf $i_Time < 0 Then
        AdlibUnRegister("Registered_Funct")
    Else
        ConsoleWrite("Do Stuff")
    EndIf            
EndFunc

Surely it has an impact on efficiency though...

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.