Functions, procedures and return values
Separates returned values from routine effects.
Overview
A function can be called as a statement with its return discarded; that changes neither its declaration nor its effects. RETURN ends the current routine and can explicitly return Nil when no useful value exists. Here a helper calculates a value while the editorial entry only displays it. Display success is not write confirmation. (Sources: refs. 1–1.)
Commented example
#Include "Protheus.ch"
User Function Ed411()
// The helper return participates in the expression.
ConOut(cValToChar(Double411(4)))
Return Nil
Static Function Double411(nValue)
Return nValue*2Displays 8; main routine returns Nil. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- Document return and effects separately; test every exit path.
- Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.