CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account

EXIT SUB

EXIT SUB

EXIT SUB provides an early exit from a defined subroutine.
Only one space is allowed between the two words.

See also:
END FUNCTION
END SUB
EXIT FUNCTION
FUNCTION
LOCAL
SUB

FUNCTION

FUNCTION xxx (arg1 [,arg2, …])
<statements>
xxx = <return value>

Defines a callable function. This is the same as adding a new function to MMBasic while it is running your program.

‘xxx’ is the function name and it must meet the specifications for naming a variable. ‘arg1’, ‘arg2’, etc are the arguments or parameters to the function.

To set the return value of the function you assign the value to the function’s name.


1
2
3
FUNCTION SQUARE(a)
  SQUARE = a * a
END FUNCTION


Every definition must have one END FUNCTION statement. When this is reached the function will return its value to the expression from which it was called. The command EXIT FUNCTION can be used for an early exit.

You use the function by using its name and arguments in a program just as you would a normal MMBasic function.


1
PRINT SQUARE(56.8)


When the function is called each argument in the caller is matched to the argument in the function definition. These arguments are available only inside the function.

Functions can be called with a variable number of arguments. Any omitted arguments in the function’s list will be set to zero or a null string.

Arguments in the caller’s list that are a variable (ie, not an expression or constant) will be passed by reference to the function. This means that any changes to the corresponding argument in the function will also be copied to the caller’s variable.

You must not jump into or out of a function using commands like GOTO, GOSUB, interrupts, etc. Doing so will have undefined side effects.

See also:
END FUNCTION
END SUB
EXIT FUNCTION
EXIT SUB
LOCAL
SUB

LOCAL

LOCAL variable [, variables]

Defines a list of variable names as local to the subroutine or function.

‘variable’ can be an array and the array will be dimensioned just as if the DIM command had been used.

A local variable will only be visible within the procedure and will be deleted (and the memory reclaimed) when the procedure returns.

If the local variable has the same name as a global variable (used before any subroutines or functions were called) the global variable will be hidden by the local variable while the procedure is executed.

See also:
END FUNCTION
END SUB
EXIT FUNCTION
EXIT SUB
FUNCTION
SUB

  • 1
  • 2
  • Next Page »

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2021 · Generate Pro Theme on Genesis Framework · WordPress · Log in