{{fbdoc item="title" value="RETURN (from procedure)"}}----
Control flow statement to return from a procedure or ##[[KeyPgGosub|Gosub]]##.

{{fbdoc item="syntax"}}##
	**Return** //expression//
##
{{fbdoc item="desc"}}
	##**Return**## is used to return from a procedure.
	
	Because ##Return## could mean return-from-gosub or return-from-procedure, ##[[KeyPgOptiongosub|Option Gosub]]## and ##[[KeyPgOptionnogosub|Option Nogosub]]## can be used to enable and disable ##[[KeyPgGosub|Gosub]]## support.  When ##[[KeyPgGosub|Gosub]]## support is disabled, ##[[KeyPgReturn|Return]]## is then recognized as return-from-procedure.  When ##[[KeyPgGosub|Gosub]]## support is enabled, ##[[KeyPgReturnGosub|Return]]## is then recognized as return-from-gosub.
	
	##**Return**## (from procedure) is used inside a procedure to exit the procedure possibly with a return value:
		- A ##[[KeyPgSub|Sub]]## cannot specify a return return value. ##**Return**## is roughly equivalent to the ##[[KeyPgExit|Exit]] Sub## idiom.
		- In a ##[[KeyPgFunction|Function]]##, ##**Return**## must specify its return value.  ##**Return** //expression//## is roughly equivalent to the ##Function = //expression// : [[KeyPgExit|Exit]] Function## idiom.
				**Warning:** Whatever the output branch used, the return value must be always defined, otherwise an unexpected behavior may occur.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/control/return2.bas"}}%%(freebasic)
'' Return from function

type rational              '' simple rational number type
	numerator as integer
	denominator as integer
end type

'' multiplies two rational types
function rational_multiply( r1 as rational, r2 as rational ) as rational

	dim r as rational
	'' multiply the divisors ...
	r.numerator   = r1.numerator   * r2.numerator
	r.denominator = r1.denominator * r2.denominator

	'' ... and return the result
	return r

end function

dim as rational r1 = ( 6, 105 )   '' define some rationals r1 and r2
dim as rational r2 = ( 70, 4 )
dim as rational r3

r3 = rational_multiply( r1, r2 )  '' multiply and store the result in r3

'' display the expression
print r1.numerator & "/" & r1.denominator; " * ";
print r2.numerator & "/" & r2.denominator; " = ";
print r3.numerator & "/" & r3.denominator
%%
{{fbdoc item="lang"}}
	- In the //[[CompilerOptlang|-lang fb]]// dialect ##**Return**## always means return-from-procedure.
	- In the //[[CompilerOptlang|-lang qb]]// dialect, ##**Return**## means return-from-gosub by default unless changed with ##[[KeyPgOptionnogosub|Option Nogosub]]##, in which case the compiler will recognize ##**Return**## as return-from-procedure.
	- In the //[[CompilerOptlang|-lang fblite]]// dialect, ##**Return**## means return-from-procedure by default unless changed with ##[[KeyPgOptiongosub|Option Gosub]]##, in which case the compiler will recognize ##**Return**## as return-from-gosub.

{{fbdoc item="diff"}}
	- None when using the //[[CompilerOptlang|-lang qb]]// dialect.

{{fbdoc item="see"}}
	- ##[[KeyPgSub|Sub]]##
	- ##[[KeyPgFunction|Function]]##
	- ##[[KeyPgGosub|Gosub]]##
	- ##[[KeyPgOptiongosub|Option Gosub]]##
	- ##[[KeyPgOptionnogosub|Option Nogosub]]##
	- ##[[ProPgLabels|Labels]]##
	- ##[[KeyPgReturnGosub|Return (from Gosub)]]##

{{fbdoc item="back" value="CatPgControlFlow|Control Flow"}}