### RETURN (from procedure)

Control flow statement to return from a procedure or

`Gosub`.

**Syntax:**

`
`

**Return**

*expression*

**Description:**

`is used to return from a procedure.`

**Return**Because

`Return`could mean return-from-gosub or return-from-procedure,

`Option Gosub`and

`Option Nogosub`can be used to enable and disable

`Gosub`support. When

`Gosub`support is disabled,

`Return`is then recognized as return-from-procedure. When

`Gosub`support is enabled,

`Return`is then recognized as return-from-gosub.

`(from procedure) is used inside a procedure to exit the procedure possibly with a return value:`

**Return****Examples:**

'' 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

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

**Dialect Differences:**

- In the
*-lang fb*dialectalways means return-from-procedure.**Return** - In the
*-lang qb*dialect,means return-from-gosub by default unless changed with**Return**`Option Nogosub`, in which case the compiler will recognizeas return-from-procedure.**Return** - In the
*-lang fblite*dialect,means return-from-procedure by default unless changed with**Return**`Option Gosub`, in which case the compiler will recognizeas return-from-gosub.**Return**

**Differences from QB:**

- None when using the
*-lang qb*dialect.

**See also:**

Back to Control Flow