Process_Globals in Basic4ppc?

timsteeman

Member
Licensed User
Longtime User
Hello,
Maybe a little bit a silly question, but can this be done in basic4ppc? So, create a super global variable and use it in every module?

Greetings,
Tim
 

akgh2010

Member
Licensed User
Longtime User
If I were to build an app. in VB, I would create a new module and Name it something like Global_Var and put any Public variables in it. The scope and lifetime for them will be in the WHOLE project and ends when you terminate or quit you application. I hope this works.
 

mjcoon

Well-Known Member
Licensed User

As Erel says, all you have to do is declare each variable as "Public".

But I don't see the point in having a distinct module for globals. I certainly would not have done that when writing VB for a living.

Every variable must have a purpose. Dividing a program into modules is done on the basis of regions of functionality. So it is to be expected that the majority if not all variables will have a "home" module with which they are most associated. To declare these variables anywhere but in their home module is merely hiding this association (even if extensive commenting is used to explain their purpose; hollow laugh! :sign0147.

A more object-oriented approach is of course to use no global variables at all but use Public Subs to manipulate local variables instead. The variables exist for the lifetime of the program in either case; it is merely the scope that differs, and thus following the logic becomes easier if scope is limited to one module. The names of the public Subs provide an additional self-documenting hint of the variable's purpose.

All the Grandmothers can stop sucking their eggs now... :sign0060:

Mike.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…