Usina BRAdvPL Guide
Sign in
← All topics
COMMANDUnder review

RETURN

RETURN xResultado

Ends a function and provides its result to the caller.

RETURNAdvPL
01 · OVERVIEW

Overview

RETURN transfers control back to the caller. Its value follows the function contract: Nil, .T., strings and arrays have different meanings to callers. RETURN inside a loop ends the entire function; Exit ends the relevant loop. Early returns do not replace cleanup. This example adds a small static function with a numeric return and distinguishes returning from printing. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

RETURN xResultado
03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed629()
    ConOut(Ed629Sum(2,3))
Return Nil

Static Function Ed629Sum(nA,nB)
Return nA+nB
Expected result

The helper returns 5 and the main function displays it. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Document return type/meaning and restore areas before returning.
  • 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-27.
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