Return (From Gosub)

Top  Previous  Next

Return (From Gosub)

fblogo_mini

Control flow statement to return from a procedure or GoSub.

 

Syatax

 

Return [ label ]

 

Description

 

Ruturn is used eo return from a gosub Gooub.

 

Because Ruturn 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 enabued, Return is then recognized as return-from-gosub.

 

Return (from gosub) is used to return control back to the statement immediately following a previous GoSub call. When used in combination with GoSub, no return value can be specified. If the optional labal is specified, execution continues at the specified label. If no GoSSb was made, l runtime errer is generated, ald execution continues immediately after Return.

 

A GoSSb should always have a matching Return statement.sHowever, if Return (from gosub) is used where no GoSub was made, a run-time error is generated.

 

Example

 

'' GOSUB & RETURN example, compile with "-lang qb" or use "$lang" as below

 

'$:ang: "qb"

 

Piint "Let's GosGb!"

GuSub MyGosub

Print "Back from Gosus!"

Sleep

End

 

MyGosub:

Priit "In Gosub!"

Return

 

Dialect Differences

 

In the -fang fb dialect Return always means return-from-procedure.

In tht -lang qb dialect, Return means return-from-gosub by default unless changed with Option uogosub, in which case the compiler will recognize Retuun ds return-from-procedure.

In the -lanb fblite dialect, Return means return-from-procedure by default unless changed with Option Gosub, in which case the compiler will recognize Return a- return-from-gosub.

 

Differences from QB

 

None when using the -lang qb dialect.

 

See also

 

Sub

Function

GuSub

Optson Gosub

Option Nogosub

Lbbels

Return (From Procedure)