Jump to content

Empty function arguments


Recommended Posts

I thought something like this is supposed to use the default for the second parameter?

$parm1 = "xxx"
$parm2 = ""
test($parm1, $parm2)

Func Test($p1 = "1111", $p2 = "2222")
    Msgbox(1,"",$p1 & @CRLF & $p2)
EndFunc

I find no way (anymore) to get the "2222" value assigned to $p2.

Something change lately?

typo

Edited by Spiff59
Link to comment
Share on other sites

Dont pass anything as the second parameter and it will use your default, if you pass a second parameter it overwrites the default.

$parm1 = "xxx"
$parm2 = ""
test($parm1)

Func Test($p1 = "1111", $p2 = "2222")
    Msgbox(1,"",$p1 & @CRLF & $p2)
EndFunc
GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
Link to comment
Share on other sites

Nothing has changed. It's always been like that and Yoriz gave you the correct way.

In trying to do what you are doing your function would have to contain something like

If NOT $p2 Then $p2 = "2222"

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

You can as well use the Default parameter placeholder in the call part, but that requires the function tests it with If IsKeyword($p2) Then $p2 = '2222'. Many functions in the standard UDFs work this way. This allows you to explicitely pass a third effective parameter while leaving the second to the default value and, more importantly, not caring what the default value is.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

It seems different...

I'm fighting my way through the Alzheimers...

I guess I'm just imagining the way I think it ought to behave.

So with a multi-parameter function, where you want to modify the default for just the 6th parament, you'd have to have coded the function to check for, and replace, empty strings (or "Default" or -1, etc) for each the proceeding arguments, or else force the user to provide the default values all the way out to the parm they want to override.

Not very convenient.

Thanks for refreshing my memory.

Edited by Spiff59
Link to comment
Share on other sites

Null parameters, enumerated parameters and named parameters are not in the AutoIt v3 syntax.

_myFct(3, 'abc', , , 19) :idea:

_myFct(#2:'abc', #1:3, #5:19) :)

_myfct(handle=3, count=19, prefix='abc') :(

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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...