Return
 
Control flow statement to return from a procedure or GoSub.

Syntax

Return [ expression ]
or
Return [ label ]


Description

Return is used to return from a procedure or return from a gosub GoSub.

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.

Return (from procedure) is used inside a procedure to exit the procedure possibly with a return value. A Sub cannot specify a return return value. In a Function, Return must specify its return value. Return expression is roughly equivalent to the Function = expression : Exit Function idiom.

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 label is specified, execution continues at the specified label. If no GoSub was made, a runtime error is generated, and execution continues immediately after Return.

A GoSub should always have a matching Return statement. However, 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

'$lang: "qb"

Print "Let's Gosub!"
GoSub MyGosub
Print "Back from Gosub!"
Sleep
End

MyGosub:
Print "In Gosub!"
Return


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


Dialect Differences

  • In the -lang fb dialect Return always means return-from-procedure.
  • In the -lang qb dialect, Return means return-from-gosub by default unless changed with Option Nogosub, in which case the compiler will recognize Return as return-from-procedure.
  • In the -lang fblite dialect, Return means return-from-procedure by default unless changed with Option Gosub, in which case the compiler will recognize Return as return-from-gosub.

Differences from QB

See also

Сайт ПДСНПСР. Если ты патриот России - жми сюда!


Знаете ли Вы, низкочастотные электромагнитные волны частотой менее 100 КГц коренным образом отличаются от более высоких частот падением скорости электромагнитных волн пропорционально корню квадратному их частоты от 300 тыс. км/с при 100 кГц до примерно 7 тыс км/с при 50 Гц.

НОВОСТИ ФОРУМАФорум Рыцари теории эфира
Рыцари теории эфира
 10.11.2021 - 12:37: ПЕРСОНАЛИИ - Personalias -> WHO IS WHO - КТО ЕСТЬ КТО - Карим_Хайдаров.
10.11.2021 - 12:36: СОВЕСТЬ - Conscience -> РАСЧЕЛОВЕЧИВАНИЕ ЧЕЛОВЕКА. КОМУ ЭТО НАДО? - Карим_Хайдаров.
10.11.2021 - 12:36: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от д.м.н. Александра Алексеевича Редько - Карим_Хайдаров.
10.11.2021 - 12:35: ЭКОЛОГИЯ - Ecology -> Биологическая безопасность населения - Карим_Хайдаров.
10.11.2021 - 12:34: ВОЙНА, ПОЛИТИКА И НАУКА - War, Politics and Science -> Проблема государственного терроризма - Карим_Хайдаров.
10.11.2021 - 12:34: ВОЙНА, ПОЛИТИКА И НАУКА - War, Politics and Science -> ПРАВОСУДИЯ.НЕТ - Карим_Хайдаров.
10.11.2021 - 12:34: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от Вадима Глогера, США - Карим_Хайдаров.
10.11.2021 - 09:18: НОВЫЕ ТЕХНОЛОГИИ - New Technologies -> Волновая генетика Петра Гаряева, 5G-контроль и управление - Карим_Хайдаров.
10.11.2021 - 09:18: ЭКОЛОГИЯ - Ecology -> ЭКОЛОГИЯ ДЛЯ ВСЕХ - Карим_Хайдаров.
10.11.2021 - 09:16: ЭКОЛОГИЯ - Ecology -> ПРОБЛЕМЫ МЕДИЦИНЫ - Карим_Хайдаров.
10.11.2021 - 09:15: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от Екатерины Коваленко - Карим_Хайдаров.
10.11.2021 - 09:13: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от Вильгельма Варкентина - Карим_Хайдаров.
Bourabai Research Institution home page

Боровское исследовательское учреждение - Bourabai Research Bourabai Research Institution