Jump to content

HotKeySet and Optional Parameter


Ejoc
 Share

Recommended Posts

So I set an optional parameter to see if I call it via a menu or via HotKey, this is a simplified example:

The first 2 calls to test() work as expected, but when I call it w/ the hotkey a, it breaks...

EDIT

I know I can check @NUMPARAMS it see if a param was passed, but it seems like something is broken.

If Not @NUMPARAMS Then local $opt_param = 0

Global $i
HotKeySet("a","test")

test(1)
test()

$i = 1
while $i
    sleep(250)
WEnd

Func test($opt_param = 0)
    MSGBox(0,"","$opt_parm = " & $opt_param)
    $i = 0
EndFunc
Edited by Ejoc
Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
Link to comment
Share on other sites

  • Developers

:) ... strange, guess this needs to be checked....

here's a work around:

Global $i
HotKeySet("a","test")

test(1)
test()

$i = 1
while $i
    sleep(250)
WEnd

Func test($opt_param = 0)
    if not IsDeclared("opt_param") then $opt_param = 0
    MSGBox(0,"","$opt_parm = " & $opt_param)
    $i = 0
EndFunc

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...