PUBLIC Command

Example   See Also

Defines global variables or arrays.

Syntax

PUBLIC MemVarList

-or-

PUBLIC [ARRAY] ArrayName1(nRows1 [, nColumns1])
  [, ArrayName2(nRows2 [, nColumns2])] ...

Arguments

MemVarList

Specifies one or more memory variables to be initialized and designated as global.

[ARRAY] ArrayName1 (nRows1 [, nColumns1])
  [, ArrayName2 (nRows2 [, nColumns2])] ...

Specifies one or more arrays to be initialized and designated as global. See DIMENSION for a description of each argument.

Remarks

Global variables and arrays can be used and modified from any program you execute during the current Visual FoxPro session.

Variables and arrays created with PUBLIC are initialized false (.F.) except for the public variables FOX and FOXPRO, which are initialized true (.T.). The public variables FOX and FOXPRO can be used to conditionally execute code based on the product you are running.

Any Variable or array you create in the Command window is automatically public.

Any Variable or array you wish to declare as public must be declared public prior to assigning it a value.

Visual FoxPro generates a syntax error if, within a program, you assign a value to a variable or array and later declare it public with PUBLIC.