PDA

View Full Version : Functions and default parameter values


SeizeTheDave
10-31-2005, 07:03 AM
Is there a way to assign a default value to a parameter in a function definition so that you do not have to enter a value for said parameter when actually calling the function?

Thanks

Worm
10-31-2005, 07:20 AM
My understanding is that the variable name being passed is a "local" variable. That said, you should be able to do this:


function MyFunction(sFolder)
if sFolder == nil then
sFolder = "C:\\Program Files\\"
end
--whatever you need to do here
end

SeizeTheDave
10-31-2005, 08:09 AM
Worm,

Thanks for the reply. That seems to work. It's a little different than I'm used to, but it does the job. Thanks

Dave

Worm
10-31-2005, 08:25 AM
NP, glad I could help.