Private and Public commands

Purpose

Used to declare local and global variables and constants.

Syntax

Private [Dim] [Const | Enum] varname [As Type] [,..]

Public [Dim] [Const | Enum] varname [As Type] [,..]

Description

Private and Public are implemented to make porting VB code easier. In fact, Public is the same as Global and Private is the same as Local.

NOTE: GFABasic only accepts Private and Public in relation to variables and constants, not declared APIs. If the latter are imported, the IDE will flag them up as errors.

Remarks

In VB subroutines are declared Private or Public often. VB divides the source code about multiple files and need to know which procedures are to be used inside the file only, or outside the file as well. Hence the keywords Private and Public. In GFA-BASIC 32 all subroutines are equal and cannot be qualified as either local or global. When porting VB code to GFA-BASIC 32, you must remove these qualifiers from the code.

Known Issues

When using local private arrays, you may develop a memory leak problem. This stems from the fact that the compiler forgets to add destruction code for local arrays when an explicit local declaration of a string variable is absent. As a workaround, in any procedure, function or sub which declares a local array, add a local string variable dummy$ if none other is present.

See Also

Dim, Global, Local, Static, Const, Enum

{Created by Sjouke Hamstra; Last updated: 12/05/14 by James Gaite}