Code and Data: Private or Public


In visual projects all constants and data for each Window, MDIWindow or DialogBox objects are private, that is, only accessible to the object and its children. To share data with other objects in the project, add one or more Module objects. Modules are code objects, that is, they have no window nor can contain controls, but all code inside them is Public by default (common to the whole project). If you want the data in a Module to be private, do the following:

For visual projects:

Set the PublicData property to FALSE

For classic projects:

Uncheck the Make all variables global option in the Project properties


For Window, MDIWindow and DialogBox objects, Easy Code declares procedures as Private by default, while in Module objects they are declared as Public. As Easy Code ignores the Option Proc directive, all procedures are Public, if not explicitly declared as Private, so that they may be accessed by any other object in the project. In fact, all procedures are Public by default if neither, Private nor Public are declared, so the following procedures are exactly the same:

AnyName Proc
    Ret
AnyName EndP

and

AnyName Proc Public
    Ret
AnyName EndP


If you want a procedure to be private, just add the corresponding reserved word (Private), and the procedure will only be accessible inside the object where it is written:

AnyName Proc Private
    Ret
AnyName EndP

So, if you set the PublicData property to FALSE (visual projects), or unckeck the Make all variables global option (classic projects), and all its procedures are declared as Private, you will get a private module, that is, only accessible inside the own module. On the other hand, setting the PublicData property to TRUE (visual projects), or checking the Make all variables global option (classic projects), and not declaring as Private any of its procedures, will result in a public module, where data and code will be accessible from any other object in the project.

It is a good practice to keep Private all procedures inside a window object (visual projects) and adding one or more Modules for common code and data. Your code will be clearer in that way, looking like higher level languages, and less exposed to errors. So Easy Code works when writing code for a procedure: all procedures inside a window object are declared Private (unless you make them Public), while all procedures inside a module object are declared Public (unless you make them explicitly Private). In fact, Easy Code does not write neither, Public nor Private, which means Public.

REMARKS: Easy Code takes care of the prototypes for all existing procedures in the project. So, you DO NOT NEED to write nor to include any Proto sentence, as they are not needed in Easy Code projects.

IMPORTANT: Remember that Easy Code ignores the Option Proc directive, so for a procedure to be private, just add the corresponding reserved word (Private). If neither, Public or Private are declared, the procedure will be considered as Public

.