COMMON and CHAIN

Forum for discussion about the documentation project.
Post Reply
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

COMMON and CHAIN

Post by angros47 »

In Quick Basic, and also in QB64, the purpose of CHAIN (that justified having a different command from RUN) was that it allowed to send some variables from the caller program to the called one. To do that, the COMMON statement had to be used in both sources.

As result, the COMMON statement had two purposes: sharing variables between modules (as it does in FreeBasic too), and sharing variables between different programs.

In FreeBasic it seems to work only to share variables between modules, but not in chained programs.

If I have program "a"

Code: Select all

Common a as integer
a=100
chain "b"
And program "b"

Code: Select all

common a as integer
print a
By compiling both of them and calling "a" I get 0 as output, not 100

In Quick Basic it could have worked, instead, by compiling including the BRUN executable. According to its wiki, it should work on QB64 too

So, perhaps this difference should be mentioned in "Differences from Quick Basic" in the wiki, under the CHAIN and COMMON pages?
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: COMMON and CHAIN

Post by fxm »

Yes, in QuickBasic, COMMON [SHARED] declares the variables to be transferred in a program called by CHAIN, or the variables common to several modules.
Indeed, the first case (with CHAIN) is not supported by FreeBASIC.

As a result, I will update the documentation as proposed.
Thanks for the tip.


[edit]
Done:
- KeyPgChain → fxm [COMMON does not work with CHAIN]
- KeyPgCommon → fxm [COMMON does not work with CHAIN]
Post Reply