Independent Variables as Object

We use independent variables (AIV) a lot. Is there a way to define an object (like LDA, PDA, GDA) and to write something like INDEPENDENT USING … ?

If you use AIVs “a lot” why don’t you use a GDA?

However, if you nest programs with CALLNAT this approach will not work.

But in this case you should decide to write an “AIV-Server”, e.g. a class, that serves all put and get requests to global variables. Then you only have to have a handle to that AIV-Server to get all the values you need. This handle can reside in a single independent.

You can use

DEFINE DATA INDEPENDENT 
1 +AIV-SERVER HANDLE OF OBJECT 

in each program.
Or you can initialize this variable at logon time (then the variable is available at compile time). To achieve this, you should create a GDA named COMMON (with a single, unused field) and a program ACOMMON containing

DEFINE DATA 
GLOBAL USING COMMON
INDEPENDENT 
1 +AIV-SERVER HANDLE OF OBJECT 
END-DEFINE
CREATE OBJECT +AIV-SERVER OF CLASS "aiv-server"
do some inits here
END

At logon time Natural searches for a couple COMMON and ACOMMON and if available, it executes ACOMMON, which initializes the AIV. In you programs you can then use +AIV-SERVER without the need to define this variable.