Application independent variable



Software AG's platform-independent programming language with full support for open-source and Internet applications

Application independent variable

Postby diptisaini » Mon Nov 22, 2010 2:48 pm

Hi,

Can anyone tell me what is the use of Application independent varaible in natural? If possible explain with some example also.

Thanks.
diptisaini
 
Posts: 90
Joined: Sun Mar 14, 2010 5:12 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Application independent variable

Postby ats » Mon Nov 22, 2010 6:33 pm

Documentation:
Defining Application-Independent Variables
General Syntax of DEFINE DATA INDEPENDENT:

DEFINE DATA
INDEPENDENT AIV-data-definition ...
END-DEFINE


The following topics are covered:

Function
Syntax Description
For an explanation of the symbols used in the syntax diagrams, see Syntax Symbols.


--------------------------------------------------------------------------------

Function
The DEFINE DATA INDEPENDENT statement is used to define application-independent variables (AIVs).

An application-independent variable is referenced by its name, and its content is shared by all programming objects executed within one application that refer to that name. The variable is allocated by the first executed programming object that references this variable and is deallocated by the LOGON command or a RELEASE VARIABLES statement.

The optional INIT clause is evaluated in each executed programming object that contains this clause (not only in the programming object that allocates the variable).



Syntax Description
INDEPENDENT AIV-data-definition The DEFINE DATA INDEPENDENT statement can be used to define a single or multiple application-independent variables (AIVs). For each AIV, the syntax shown below applies.

END-DEFINE The Natural reserved word END-DEFINE must be used to end the DEFINE DATA statement.


AIV Data Definition

level variable-definition
redefinition
handle-definition


Syntax Element Description:

level An application-independent variable must be defined at Level 01. Other levels are only used in a redefinition.
variable-definition A variable definition is used to define a single field/variable that may be single-valued (scalar) or multi-valued (array). See Variable Definition.

Note:
The name of an application-independent variable must start with a "+" character.

redefinition A redefinition may be used to redefine a group, a view, a DDM field or a single field/variable (that is a scalar or an array). See Redefinition.

The fields resulting from the redefinition must not be application-independent variables, that is their name must not start with a '+'. These fields are treated as local variables.

handle-definition A handle identifies a dialog element in code and is stored in handle variables. See Handle Definition.

Note:
The first character of the name must be a "+". Rules for Natural variable names apply, see Naming Conventions for User-Defined Variables (in the Natural Programming Guide).


Example:

PROG

DEFINE DATA INDEPENDENT
1 +NAME (A10) INIT <'DIPTI'>
END-DEFINE
WRITE NOTITILE '+NAME IN PROG =' +NAME
CALLNAT 'TESTAIV1'
END



SUBPROG

DEFINE DATA LOCAL
1 #NAME (A10)
END-DEFINE
#NAME := +NAME
WRITE '#NAME IN SUB-PROG = ' #NAME
END


O/P

MORE,
+NAME IN PROG = DIPTI
#NAME IN SUB-PROG =  DIPTI


Hope this helps!

Regards,
Ats
ats
 
Posts: 14
Joined: Mon Sep 06, 2010 12:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Application independent variable

Postby RGZbrog » Tue Nov 23, 2010 12:04 am

In the very early days of Natural, global variables (often called + variables, due to the requisite prefix) often caused maintenance nightmares, as they were difficult to control, having few restrictions placed upon them. The Global Data Area (GDA) was created to bring order to the chaos by replacing global variables. But users complained to Software AG that some features of global variables were not available to the GDA, so Application Independent Variables (AIVs) were introduced, effectively reinstating global variables.

There are two big differences between the GDA and AIVs:
. the GDA must be defined as an external module, while AIVs must be defined in-stream
. the GDA is not available to subprograms (except as parameters), while AIVs are available to subprograms

Talk to your tech lead about the (very) few situations where AIVs should be used/allowed and how they should be controlled. This is an advanced topic/technique.
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: Application independent variable

Postby diptisaini » Tue Nov 23, 2010 10:43 am

Thanks for your valuable information.
diptisaini
 
Posts: 90
Joined: Sun Mar 14, 2010 5:12 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Natural

 


  • Related topics
    Replies
    Views
    Last post