bas7advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
SHARED Statement Details
  Syntax  Details  Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
The SHARED statement gives a SUB or FUNCTION procedure access to variables
declared at the module level without passing them as parameters.
 
SHARED variable[()] [AS type] [,variable[()] [AS type]]...
    ■ AS type declares the type of the variable. The type may be
      INTEGER, LONG, SINGLE, DOUBLE, STRING (for variable-length strings),
      STRING * length (for fixed-length strings), CURRENCY, or a user-
      defined type.
 
Usage Notes
    ■ By using either the SHARED statement in a SUB or FUNCTION
      procedure, or the SHARED attribute with COMMON or DIM in the
      module-level code, you can use variables in a procedure without
      passing them as parameters.
    ■ The SHARED attribute used with COMMON or DIM shares variables
      among all procedures in a module, while the SHARED statement shares
      variables between a single procedure and the module-level code.
 
Important
    ■ The SHARED statement shares variables only within a single compiled
      module. It does not share variables with programs in the Quick
      library or with procedures compiled separately and linked to the
      program. The SHARED statement shares variables only between the
      module-level code and a SUB or FUNCTION procedure in the same module.
    ■ The SHARED statement can appear only in a SUB or FUNCTION procedure.