[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2020-06-20T03:03:49-05:00 http://petesqbsite.com/phpBB3/app.php/feed/topic/14827 2020-06-20T03:03:49-05:00 2020-06-20T03:03:49-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=38980#p38980 <![CDATA[Re: how to share Common declare between modules]]> Statistics: Posted by Erik — Sat Jun 20, 2020 3:03 am


]]>
2020-05-02T13:05:37-05:00 2020-05-02T13:05:37-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=38950#p38950 <![CDATA[Re: how to share Common declare between modules]]>
Modules are compiled and SUB's and FUNCTION's are passed to each EXE through CHAIN.
CHAIN can work with ALL BAS or EXE modules, not a combination. one or the other.

One possible reason to use multiple modules is when OUT OF STRING SPACE errors start...

The COMMON SHARED values are passed in order listed and the variable names can be
changed in each module as they are listed in order from left to right with proper types.
The shared variable lists MUST MATCH the list of comma separated variable types of the original call!

Statistics: Posted by burger2227 — Sat May 02, 2020 1:05 pm


]]>
2020-05-02T10:05:36-05:00 2020-05-02T10:05:36-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=38948#p38948 <![CDATA[Re: how to share Common declare between modules]]>
Does this mean that a "stand alone" compiled EXE with COMMON vars will not carry over if the program isn't recompiled to require BRUN45?
Yep.

Statistics: Posted by MikeHawk — Sat May 02, 2020 10:05 am


]]>
2020-05-02T03:36:17-05:00 2020-05-02T03:36:17-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=38945#p38945 <![CDATA[Re: how to share Common declare between modules]]>
It works with interpreted source code in the IDE, or with BRUN45-dependent EXEs.
Really good info posted above.

QQ on the quoted text. Does this mean that a "stand alone" compiled EXE with COMMON vars will not carry over if the program isn't recompiled to require BRUN45?

Statistics: Posted by Erik — Sat May 02, 2020 3:36 am


]]>
2020-04-13T05:43:24-05:00 2020-04-13T05:43:24-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=38925#p38925 <![CDATA[Re: how to share Common declare between modules]]> only between certain routines: define the variable as usual in the main module, then use SHARED within the routine:

Code:

DECLARE SUB test1 ()DECLARE SUB test2 ()DIM something AS STRINGsomething = "anything, really"test1test2ENDSUB test1  SHARED something AS STRING ' SHARED only, not DIM  PRINT something ' Prints "anything, really"END SUBSUB test2  PRINT something ' Prints "0", because <something> is undefined in this routine and QB assumes it is an integerEND SUB
Just posting this, in case anyone stumbles upon this thread.

Statistics: Posted by MikeHawk — Mon Apr 13, 2020 5:43 am


]]>
2020-01-10T15:56:52-05:00 2020-01-10T15:56:52-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=38910#p38910 <![CDATA[Re: how to share Common declare between modules]]>
COMMON is typically used when sharing variables between modules (more than one source file, more than one compiled program, or when using libraries;) for instance, you have 1.BAS and 2.BAS. In 1.BAS, you declare a variable using COMMON and then, CHAIN to 2.BAS later on. In 2.BAS, you also declare that variable using COMMON and QBasic should carry the data from one program to the other (only the type and the order in which variables are declared with COMMON is important.) It works with interpreted source code in the IDE, or with BRUN45-dependent EXEs.

Since you're writing a one-file program, I don't think you need to use COMMON. Just go straight for the DIM SHARED <var> AS <type> in your main module and have the variable shared among all routines... that being said COMMON SHARED is still technically valid and the following code works as intended in QuickBASIC 4.5:

Code:

DECLARE SUB PrintTerminalNumber()COMMON SHARED TerminalNumber AS STRINGTerminalNumber = "1234"PrintTerminalNumberSUB PrintTerminalNumber  PRINT "Terminal Number :"; TerminalNumberEND SUB
Typical use would be:

Code:

' 1.BASCOMMON myName AS STRINGINPUT "What's your name"; myNameCHAIN "2.BAS"

Code:

' 2.BASCOMMON someName AS STRINGPRINT "So, your name is "; someName
Or, with SHARED:

Code:

' 1.BASCOMMON SHARED myName AS STRINGINPUT "What's your name"; myNameCHAIN "2.BAS"

Code:

' 2.BASDECLARE SUB MyRoutine()COMMON SHARED someName AS STRINGMyRoutineSUB MyRoutine  PRINT "So, your name is "; someNameEND SUB

Statistics: Posted by MikeHawk — Fri Jan 10, 2020 3:56 pm


]]>
2020-01-07T10:16:34-05:00 2020-01-07T10:16:34-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=38908#p38908 <![CDATA[how to share Common declare between modules]]>
I have just started to develop once again in qbasic and for the love of everything I can not remember how to share a variable between modules

Before the main function runs I have declared

Common shared TerminalNumber as string

But I can not seem to access it from another function

Example

Code:

Public sub PrintTerminalNumber  Print "Terminal Number :" + TerminalNumberEnd sub
I end up with Terminal Number :

How do I allow the printTerminalNumber sub access to the TerminalNumber?

I even have tried to declare it like

Code:

public sub PrintTermialNumber (byval termID string)  Print "Terminal Number :" + termIDEnd sub
And then

Code:

PrintTerminalNumber (TerminalNumber)
but I still end up with Terminal Number :

I will say this now I have been using VB6 for meany years and I think i have forgot most of my QBasic skills I I do appreciate any help or example
Code on this

Thanks
Andrew

Statistics: Posted by gablea — Tue Jan 07, 2020 10:16 am


]]>