> What you're requesting that if there is no parameter that parameter is going to be replaced with the specified function call
No, it means if I call the procedure without specifying a newcolor, then it takes the value of #COLOR_BTNFACE instead, no matter what that value is set to in Windows by the user's color scheme. Surely you agree that's not an unreasonable thing to want? Otherwise, I'd have to code it something like this (where passing -1 means use the default system color, and any other value means use that value):
Code: Select all
Procedure ReplaceImageColor(imgnum,oldcolor,newcolor)
If newcolor=-1 : newcolor=GetSysColor_(#COLOR_BTNFACE) : EndIf
...
EndProcedure
Which is why the concept of having default parameters came about in the first place, to avoid doing code like this.
Here's another example. Say you have an email app that lets the user specify a custom port to send through (default is 25) and the value of the custom port is held in a variable called myport, but you also want the user to be able to switch ports on the fly. You get a syntax error with this:
Code: Select all
Global myport=136
Procedure SendMailViaCustomPort(mailto$,mailfrom$,port=myport)
...
EndProcedure
So you have to code it something like this (where -1 means use the custom port, and any other value means use that value):
Code: Select all
Global myport=136
Procedure SendMailViaCustomPort(mailto$,mailfrom$,port)
If port=-1 : port=myport : EndIf
...
EndProcedure