COMMON SHARED - QB64 Wiki

COMMON SHARED

From QB64 Wiki

Jump to: navigation, search

COMMON SHARED is used to pass variable values between 2 or more program modules and sub procedures within that module.


Syntax:

COMMON [SHARED][/block_name/]variable_list


  • COMMON statements must be made before any program code execution.
  • The SHARED statement allows the variable values to also be used in module SUB and FUNCTION procedures.
  • The COMMON block name designates a certain block of variables that certain program modules may use, the name must be within two forward slashes/ (Ex: /thename/ ). Currently NOT supported in QB64
  • The list of variables(separated by commas) to pass MUST be in the same type order in ALL modules used!
  • COMMON variable list names(but not variable types) can change between modules.
  • The list can hold any variable type.
  • The list cannot define a variable's value, but can use AS to designate the type.
  • Quickbasic 4.5 requires you to include BRUN45.EXE when you compile COMMON SHARED values between EXE modules.
  • Use DIM SHARED variables when working in a module to pass variable values to SUB procedures.
  • Data files could be used as an alternative to using COMMON SHARED values.
  • In QB64 COMMON values are sent using files instead of memory presently.
  • Note: Values assigned to shared variables used as procedure call parameters will not be passed to other procedures! The shared variable value MUST be assigned INSIDE of the SUB or FUNCTION procedure to be passed!


Example: COMMON SHARED x%, y%, user$, speed!, score&


See also:



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page
Views
Personal tools