Variable handling?
Posted: Wed Oct 26, 2005 4:53 pm
I need to know how I can not lose the value of a variable when leaving a sub, so that I can go back to it and access that value again.
Discuss QBasic, Freebasic, QB64 and more
http://petesqbsite.com/phpBB3/
Code: Select all
DECLARE SUB yoursub ()
DIM SHARED yourvariable
CALL yoursub
PRINT yourvariable
SUB yoursub()
LET yourvariable = 4
END SUB
Code: Select all
DECLARE SUB yoursub (yourvariable)
CALL yoursub (subvariable)
PRINT subvariable
END
SUB yoursub (yourvariable)
LET yourvariable = 4
END SUB
Here's the definition of the COMMON statement:Nathan1993 wrote:You can also use the common statement, but thats really messy and un-good... use it like this... i ferget how to use it though, so check qbs help.[/code]
Code: Select all
COMMON - a non-executable statement that declares global variables for
sharing between modules, or for chaining to another program