CHAIN: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(12 intermediate revisions by the same user not shown)
Line 5: Line 5:
: [[CHAIN]] {{Parameter|moduleName$}}
: [[CHAIN]] {{Parameter|moduleName$}}


{{PageLegacySupport}}
=== Legacy support ===
* The multi-modular technique goes back to when '''QBasic''' and '''QuickBASIC''' had module size constraints. In '''QB64''' the [[CHAIN]] instruction 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.
* The multi-modular technique goes back to when '''QBasic''' and '''QuickBASIC''' had module size constraints. In '''QB64''' the [[CHAIN]] statement 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.




{{Parameters}}
{{PageParameters}}
* {{Parameter|moduleName$}} is a variable or a literal [[STRING]] value in quotation marks with the optional EXE or BAS file name extension.
* {{Parameter|moduleName$}} is a variable or a literal [[STRING]] value in quotation marks with the optional EXE or BAS file name extension.


Line 18: Line 18:
* CHAIN looks for a file extension that is the same as the invoking module's extension.
* CHAIN looks for a file extension that is the same as the invoking module's extension.
* The module's filename extension is not required. To save editing at compile time just omit the extensions in the calls.
* The module's filename extension is not required. To save editing at compile time just omit the extensions in the calls.
* To pass data from one module to the other use [[COMMON SHARED]]. The COMMON list should match [[type]]s and names.
* To pass data from one module to the other use [[COMMON SHARED]]. The COMMON list should match [[Variable Types|type]]s and names.
* '''QB64 does not retain the [[SCREEN]] mode like QBasic did.'''  
* '''QB64 does not retain the [[SCREEN]] mode like QBasic did.'''
* Variable data can be passed in files instead of using [[COMMON SHARED]] values. '''QB64''' uses files to pass [[COMMON]] lists.
* Variable data can be passed in files instead of using [[COMMON SHARED]] values. '''QB64''' uses files to pass [[COMMON]] lists.
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]'''.
* '''[[Keywords currently not supported by QB64#Keywords_not_supported_in_Linux_or_macOS_versions|Keyword not supported in Linux or macOS versions]]'''




Line 30: Line 30:
{{PageExamples}}
{{PageExamples}}
''Example:'' CHAIN looks for same file type extension as program module (BAS or EXE).
''Example:'' CHAIN looks for same file type extension as program module (BAS or EXE).
{{CodeStart}} '' ''
{{CodeStart}}
  {{Cl|CHAIN}} "Level1" '' ''
  {{Cl|CHAIN}} "Level1"
{{CodeEnd}}
{{CodeEnd}}


Line 37: Line 37:




{{PageSeeAlso}}  
{{PageSeeAlso}}
* [[RUN]]
* [[RUN]]
* [[COMMON]], [[COMMON SHARED]]
* [[COMMON]], [[COMMON SHARED]]
* [[SHARED]]
* [[SHARED]]
* [[LINKed or Merged Modules]]




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 20:23, 26 January 2024

CHAIN is used to change seamlessly from one module to another one in a program.


Syntax

CHAIN moduleName$

Legacy support

  • The multi-modular technique goes back to when QBasic and QuickBASIC had module size constraints. In QB64 the CHAIN statement 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.


Parameters

  • moduleName$ is a variable or a literal STRING value in quotation marks with the optional EXE or BAS file name extension.


Description

  • CHAIN requires that both the invoking and called modules are of either .BAS or .EXE file types.
  • In Windows, QB64 will automatically compile a CHAIN referenced BAS file if there is no EXE file found.
  • CHAIN looks for a file extension that is the same as the invoking module's extension.
  • The module's filename extension is not required. To save editing at compile time just omit the extensions in the calls.
  • To pass data from one module to the other use COMMON SHARED. The COMMON list should match types and names.
  • QB64 does not retain the SCREEN mode like QBasic did.
  • Variable data can be passed in files instead of using COMMON SHARED values. QB64 uses files to pass COMMON lists.
  • Keyword not supported in Linux or macOS versions


QBasic/QuickBASIC:

  • Compiled EXE files had to include BRUN45.EXE in QuickBASIC 4.5 when CHAIN was used with COMMON SHARED.


Examples

Example: CHAIN looks for same file type extension as program module (BAS or EXE).

 CHAIN "Level1"

Explanation: The file referred to is "Level1.BAS" if the program module using the call is a BAS file. If the program was compiled, it would look for "Level1.EXE".


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link