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 Include files or Module objects. Modules are code objects, which means that they have no window and cannot contain controls, but all code inside them is Public by default, that is, common to the whole project (this can NOT be applied to macros, which are only available in the Window or Module where they are defined). If you want the data in a Module to be private, just 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
On the other hand, Include
files are also common to the whole project
if you add them using the corresponding menu options. That is, for
include files belonging to MASM32
SDK or driver
programming,
use the "Project->Add
Include files (*.inc)..." menu
option, while for other include files you wish to
include (which must be in the project folder) use the "Project->Add
Files..." menu option. Include
files
are the most appropiated ones for macros and/or structures having to be
global to the whole project.
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
.