Difference between revisions of "COMMON"

From QB64 Wiki
Jump to navigation Jump to search
imported>Cyperium
imported>SMcNeill
m (-)
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
COMMON makes the variables or block of variables available to a different module.
+
[[COMMON]] shares common variable values with other linked or [[CHAIN]]ed modules.
  
 +
==Legacy support==
 +
* The multi-modular technique goes back to when QBasic and QuickBASIC had module size constraints. In QB64 [[COMMON]] has been implemented so that that older code can still be compiled, though '''it is advisable to use single modules for a single project (not counting [[$INCLUDE]] libraries), for ease of sharing and also because the module size constraints no longer exist.'''
  
''Syntax:'' COMMON [SHARED] [/blockname/] variablelist
 
  
 +
{{PageSyntax}}
 +
: [[COMMON]] [SHARED] variableList
  
  
[[SHARED]] makes the variables shared within the subs and functions within that module.
+
{{PageDescription}}
 +
* COMMON must be called before any executable statements.
 +
* [[SHARED]] makes the variables shared within [[SUB]] and [[FUNCTION]] procedures within that module.
 +
* variableList is the list of common variables made available separated by commas.
 +
* Remember to keep the variable type ''order'' the same in all modules, as the variables names don't matter.
 +
* [[COMMON SHARED]] is most commonly used to share the variables with subs and functions of that module.
 +
* '''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.'''
  
  
/blockname/ gives the ability to name a block of variables (ex. COMMON /thename/ a, b, c), this name can later be referenced in the module to only give access to those variables. As such many COMMON statements can be issued with different names to be shared in different modules.
+
{{PageSeeAlso}}
 +
* [[COMMON SHARED]], [[CHAIN]]
 +
* [[DIM]], [[REDIM]], [[SHARED]]
 +
* [[DEFSTR]], [[DEFLNG]], [[DEFINT]], [[DEFSNG]], [[DEFDBL]]
  
 
+
{{PageNavigation}}
variablelist is the variables that should be made available separated by commas.
 
 
 
 
 
Remember to keep the variable ''order'' the same in both modules as it is the order that matters and not the variables names.
 
 
 
 
 
COMMON must be called before any executable statements.
 
 
 
 
 
[[COMMON SHARED]] is most commonly used, as then you don't need to share them seperately in the module.
 
 
 
 
 
 
 
 
 
''See:'' [[COMMON SHARED]]
 
 
 
 
 
 
 
==Navigation:==
 
 
 
[[Keyword_Reference_-_Alphabetical|Go to Keyword Reference - Alphabetical]]
 
 
 
[[Keyword Reference - By usage|Go to Keyword Reference - By usage]]
 

Latest revision as of 14:31, 10 September 2017

COMMON shares common variable values with other linked or CHAINed modules.

Legacy support

  • The multi-modular technique goes back to when QBasic and QuickBASIC had module size constraints. In QB64 COMMON has been implemented so that that older code can still be compiled, though it is advisable to use single modules for a single project (not counting $INCLUDE libraries), for ease of sharing and also because the module size constraints no longer exist.


Syntax

COMMON [SHARED] variableList


Description

  • COMMON must be called before any executable statements.
  • SHARED makes the variables shared within SUB and FUNCTION procedures within that module.
  • variableList is the list of common variables made available separated by commas.
  • Remember to keep the variable type order the same in all modules, as the variables names don't matter.
  • COMMON SHARED is most commonly used to share the variables with subs and functions of that module.
  • 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.


See also



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