Q re variable scope
Posted: Mon Sep 11, 2023 9:44 pm
Hello everyone,
I have a question re variable scope.
The system I’m converting was written in the Harbour/Clipper dialect and that's what I'm using in the X# conversion.
I have over 100 variables declared as ‘PUBLIC’ in the top (controlling) module (let’s call it ‘TOP.PRG’). These are all ‘set’ at that level before any of the dozens of other modules (let’s call them ‘MOD1.PRG’, ‘MOD2.PRG’, ‘MODn.PRG …) are called.
How can I best declare these variables so they are ‘visible’ by the called modules? For example, I have a public var that tracks the user’s preferred language and which is set at the very beginning (TOP.PRG) based on the user’s login. The var is referenced by just about every called module (MODn.PRG).
EDIT: the variables should not only be visible my the called modules, but also modifiable. For example, MOD3.PRG should be able to change the preferred language variable in a global way.
As always, thanks for your help.
Roland
I have a question re variable scope.
The system I’m converting was written in the Harbour/Clipper dialect and that's what I'm using in the X# conversion.
I have over 100 variables declared as ‘PUBLIC’ in the top (controlling) module (let’s call it ‘TOP.PRG’). These are all ‘set’ at that level before any of the dozens of other modules (let’s call them ‘MOD1.PRG’, ‘MOD2.PRG’, ‘MODn.PRG …) are called.
How can I best declare these variables so they are ‘visible’ by the called modules? For example, I have a public var that tracks the user’s preferred language and which is set at the very beginning (TOP.PRG) based on the user’s login. The var is referenced by just about every called module (MODn.PRG).
EDIT: the variables should not only be visible my the called modules, but also modifiable. For example, MOD3.PRG should be able to change the preferred language variable in a global way.
As always, thanks for your help.
Roland