Usina BRAdvPL Guide
Sign in
← All topics
FOUNDATIONUnder review

Functions, procedures and return values

Separates returned values from routine effects.

Functions, procedures and return valuesAdvPL
01 · OVERVIEW

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.)

03 · PRACTICAL EXAMPLE

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*2
Expected result

Displays 8; main routine returns Nil. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • 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.

Related content

REFERENCES
  1. TOTVS. FUNCTION. TDN. Accessed on 2026-10-26.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha