However, in VFP this is completely valid:
Code:
DO doSomething with Date()
if doSomething( Date() )
wait window "Something"
endif
PROCEDURE doSomething( pdDate )
if dow(pdDate)=1
RETURN .T.
else
RETURN .F.
endif
ENDPROC
So, you CAN return values from a Procedure in VFP.
The only real difference in VFP between a function and a procedure is... the word used to define it (and the (unnecessary) matching ENDxxxx word to end it).
Both functions and procedures (in VFP) can be called 'like' functions and 'like' procedures... that is:
like a function: var = function( param, param2 )
like a procedure: do Procedure with param, param2
If you don't set a return value in a procedure (that is, if the procedure ends with "RETURN" instead of "RETURN SomeValue", or "ENDPROC" with no RETURN at all), then the default return value is .T.
Now, the difference between the two calling mechanisms are that SET UDFPARMS TO Reference|Value only affects how parameters are passed to functions... Procedures ALWAYS have parameters passed by... well, I can't remember: Either always by Reference or by value... anyway, SET UDFPARMS doesn't affect it.
HOWEVER, SET UDFPARMS can be overridden with parentheses:
Code:
SET UDFPARMS TO REFERENCE
xx = DoSomething( param1 ) && Passes implicitly by ref.
xx = DoSomething( (param1) ) && Passes explicitly by value
xx = DoSomething( @param1 ) && passes explicitly by ref.
SET UDFPARMS TO VALUE
xx = DoSomething( Param1 ) && passes implicitly by value
xx = DoSomething( (param1) ) && Passes explicitly by value
xx = DoSomething( @param1 ) && passes explicitly by ref.
So, in VFP, there IS NO difference between Procedures and Functions... same with Methods of an object: They are ALWAYS called as Functions, (ie, you can't: DO MyObject.SomeMethod WITH param1, param2)
And you don't have to return a value from a method, but the default return value will be .T. if you don't specifically "RETURN SomeValue"