Structured Programming in QuickBasic - Subprograms; SHARED (31822)






This article was previously published under Q31822

SUMMARY

Microsoft QuickBasic for MS-DOS provides structured programming features that exceed BasicA's FOR/NEXT, WHILE/WEND, and GOSUB statements. True subprograms with scalar and array parameters are easy to use in QuickBasic. All variables in subprograms are local unless they are declared as shared-global variables in the current module, as shown in the following example:
         bubbles = 10
         CALL MySort (howbig, Array())     'sort Array()
         END

         SUB MySort (limit, Sieve()) STATIC    'Sieve is 1-dim
         SHARED bubbles               'global variable
           ...  ' MySort subprogram body
         END SUB
				
Note that the SHARED statement does not share variables across separately-compiled modules, it only shares with the main program level ("module level") of the current module. To share variables across separately-compiled modules, you must use the COMMON SHARED statement.

Modification Type: Minor Last Reviewed: 1/9/2003
Keywords: KB31822