Revision history for KeyPgReturn


Revision [22344]

Last edited on 2018-07-16 00:00:20 by fxm [Formatting (LF) for .chm]

No Differences

Revision [22343]

Edited on 2018-07-15 01:58:51 by fxm [Clarify the use of Return in a Sub versus a Function]
Additions:
##**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.
Deletions:
##**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. In a ##[[KeyPgFunction|Function]]##, ##**Return**## must specify its return value. ##**Return** //expression//## is roughly equivalent to the ##Function = //expression// : [[KeyPgExit|Exit]] Function## idiom.


Revision [21927]

Edited on 2017-09-29 12:57:57 by fxm [Added (in ยง"See also") a link to the "Labels" page]
Additions:
- ##[[ProPgLabels|Labels]]##


Revision [21810]

Edited on 2017-08-10 09:43:53 by fxm [Corrected typo in "Syntax": RETURN can not be used in functions without returning an expression]
Additions:
**Return** //expression//
Deletions:
**Return** [ //expression// ]


Revision [21111]

Edited on 2016-03-13 09:52:34 by fxm [Formatting]
Additions:





Revision [20488]

Edited on 2016-02-10 16:07:46 by DkLwikki [Update link format]
Additions:
Control flow statement to return from a procedure or ##[[KeyPgGosub|Gosub]]##.
##**Return**## is used to return from a procedure or return from a gosub ##[[KeyPgGosub|Gosub]]##.
Because ##[[KeyPgReturn|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, ##[[KeyPgReturn|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. In a ##[[KeyPgFunction|Function]]##, ##**Return**## must specify its return value. ##**Return** //expression//## is roughly equivalent to the ##Function = //expression// : [[KeyPgExit|Exit]] Function## idiom.
##**Return**## (from gosub) is used to return control back to the statement immediately following a previous ##[[KeyPgGosub|Gosub]]## call. When used in combination with ##[[KeyPgGosub|Gosub]]##, no return value can be specified. If the optional ##//label//## is specified, execution continues at the specified label. If no ##[[KeyPgGosub|Gosub]]## was made, a runtime error is generated, and execution continues immediately after ##**Return**##.
A ##[[KeyPgGosub|Gosub]]## should always have a matching ##**Return**## statement. However, if ##**Return**## (from gosub) is used where no ##[[KeyPgGosub|Gosub]]## was made, a run-time error is generated.
- 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.
- None when using the //[[CompilerOptlang|-lang qb]]// dialect.
- ##[[KeyPgSub|Sub]]##
- ##[[KeyPgFunction|Function]]##
- ##[[KeyPgGosub|Gosub]]##
- ##[[KeyPgOptiongosub|Option Gosub]]##
- ##[[KeyPgOptionnogosub|Option Nogosub]]##
Deletions:
Control flow statement to return from a procedure or ##[[KeyPgGosub Gosub]]##.
##**Return**## is used to return from a procedure or return from a gosub ##[[KeyPgGosub Gosub]]##.
Because ##[[KeyPgReturn 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, ##[[KeyPgReturn 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. In a ##[[KeyPgFunction Function]]##, ##**Return**## must specify its return value. ##**Return** //expression//## is roughly equivalent to the ##Function = //expression// : [[KeyPgExit Exit]] Function## idiom.
##**Return**## (from gosub) is used to return control back to the statement immediately following a previous ##[[KeyPgGosub Gosub]]## call. When used in combination with ##[[KeyPgGosub Gosub]]##, no return value can be specified. If the optional ##//label//## is specified, execution continues at the specified label. If no ##[[KeyPgGosub Gosub]]## was made, a runtime error is generated, and execution continues immediately after ##**Return**##.
A ##[[KeyPgGosub Gosub]]## should always have a matching ##**Return**## statement. However, if ##**Return**## (from gosub) is used where no ##[[KeyPgGosub Gosub]]## was made, a run-time error is generated.
- 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.
- None when using the //[[CompilerOptlang -lang qb]]// dialect.
- ##[[KeyPgSub Sub]]##
- ##[[KeyPgFunction Function]]##
- ##[[KeyPgGosub Gosub]]##
- ##[[KeyPgOptiongosub Option Gosub]]##
- ##[[KeyPgOptionnogosub Option Nogosub]]##


Revision [14833]

Edited on 2010-09-14 16:21:03 by CountingPine ["roughly"]
Additions:
##**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. In a ##[[KeyPgFunction Function]]##, ##**Return**## must specify its return value. ##**Return** //expression//## is roughly equivalent to the ##Function = //expression// : [[KeyPgExit Exit]] Function## idiom.
Deletions:
##**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. In a ##[[KeyPgFunction Function]]##, ##**Return**## must specify its return value. ##**Return** //expression//## is equivalent to the ##Function = //expression// : [[KeyPgExit Exit]] Function## idiom.


Revision [13810]

Edited on 2008-10-23 17:25:15 by CountingPine [Fix second example]
Additions:
'' Return from function
type rational '' simple rational number type
numerator as integer
denominator as integer
'' multiplies two rational types
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
'' display the expression
print r1.numerator & "/" & r1.denominator; " * ";
print r2.numerator & "/" & r2.denominator; " = ";
print r3.numerator & "/" & r3.denominator%%
Deletions:
'' Return from function in lang FB dialect example
type rational_number '' simple rational number type
numerator as integer
denominator as integer
type rational as rational_number '' type alias for clearer code
'' multiplies two rational types (note: r1 remains unchanged due to the BYVAL option)
r1.numerator *= r2.numerator '' multiply the divisors ...
r1.denominator *= r2.denominator
return r1 '' ... and return the rational
'' display the expression
'' using STR function to eliminate leading space when printing numeric types
print str( r1.numerator ) ; "/" ; str( r1.denominator ) ; " * " ;
print str( r2.numerator ) ; "/" ; str( r2.denominator ) ; " = " ;
print str( r3.numerator ) ; "/" ; str( r3.denominator )
sleep
end


Revision [13803]

Edited on 2008-10-22 04:26:22 by DoS386 [FBHELP formatting, $$lang [3]]
Additions:
'' Return from function in lang FB dialect example


Revision [13802]

Edited on 2008-10-22 04:24:48 by DoS386 [FBHELP formatting, $$lang [2]]
Additions:
'' display the expression
'' using STR function to eliminate leading space when printing numeric types
Deletions:
'' display the expression (using STR to eliminate leading space when printing numeric types)


Revision [13801]

Edited on 2008-10-22 04:21:54 by DoS386 [FBHELP formatting, $$lang]
Additions:
'' GOSUB & RETURN example, compile with "-lang qb" or use "$lang" as below
type rational_number '' simple rational number type
type rational as rational_number '' type alias for clearer code
r1.numerator *= r2.numerator '' multiply the divisors ...
return r1 '' ... and return the rational
dim as rational r1 = ( 6, 105 ) '' define some rationals r1 and r2
r3 = rational_multiply( r1, r2 ) '' multiply and store the result in r3
end
Deletions:
'' Compile with -lang qb
type rational_number '' simple rational number type
type rational as rational_number '' type alias for clearer code
r1.numerator *= r2.numerator '' multiply the divisors ...
return r1 '' ... and return the rational
dim as rational r1 = ( 6, 105 ) '' define some rationals r1 and r2
r3 = rational_multiply( r1, r2 ) '' multiply and store the result in r3
end 0


Revision [13550]

Edited on 2008-07-21 15:43:10 by JeffMarshall [added #lang or $lang to example]
Additions:
'$lang: "qb"
Print "Let's Gosub!"
GoSub MyGosub
Print "Back from Gosub!"
Sleep
End
Print "In Gosub!"
Return
Deletions:
print "Let's Gosub!"
gosub MyGosub
print "Back from Gosub!"
sleep
end
print "In Gosub!"
return


Revision [13347]

The oldest known version of this page was created on 2008-05-08 07:43:44 by JeffMarshall [added #lang or $lang to example]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode