Sign in to follow this  
Followers 0
lee321987

Func - Optional parameter - can't set array index as default value

5 posts in this topic

When I try to run this:

Dim $aArray[2]

$aArray[0] = 'arrrg'

_My_Func()

Func _My_Func($arg = $aArray[0])
    MsgBox(0, '', $arg)
EndFunc

It won't run and I get this error:

Badly formatted "Func" statement.

Share this post


Link to post
Share on other sites



I guess you want to do this: ?

Dim $aArray[2]

$aArray[0] = 'arrrg'

_My_Func($aArray[0])

Func _My_Func($arg = "default")
    MsgBox(0, '', $arg)
EndFunc

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I can't do that, because the Func is called from a hotkey.

I should have mentioned that.

Share this post


Link to post
Share on other sites

I can't do that, because the Func is called from a hotkey.

I should have mentioned that.

Then simply use the Global variable directly in the Func.

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Wow, I don't know what I was thinking.

Thank you.

If anyone wants to delete this thread, please feel free to do so.

Share this post


Link to post
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
Sign in to follow this  
Followers 0