What are the factors to be considered to write a method as Procedure or function?
Printable View
What are the factors to be considered to write a method as Procedure or function?
function has return value.
so if U want to return a value after the process u can use a function
Dinesh Asanka
Yes, of course, Function has return value. but i can return this value as out parameter through a procedure also.
if UR using procedure
call ProcedureName(parameters)
if returnvalue = true then
endif
if UR using Function
if FunctionName(parameters) = true then
endif
Dinesh Asanka
Thanks..
This infers that
It is most appropriate to use a function when the return value is used in expressions, as procedures cannot be used in expressions
...and it is not a good practice to use variable (public or global) to the purpouse of return a value from a sub: you will be in a mess while trying to keep track of all public/global variables as soon as your project grows; moreover, public/global may be used by mistake somewhere else, where they should not...
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.