AMT Help Files

Includable Global Variables

Includables are introduced in Lion to insert variable definitions between variable definitions. Includables do have much similarity with insertables; the Lion parser will insert the code of the includables as well as insertables in the code of the calling program at the moment of parsing. The difference is that for insertables, logic is inserted, while for includables the variable definitions are included.

Using includables helps to reduce programmer transcription errors and also makes implementation simpler by reducing the amount of coding required. For instance, when a number of programs need to access the same data-structure, the relevant record descriptions can be inserted from an includable instead of each programmer having to type their own.

One thing you do have to watch for is that in an includable you have defined var1 : alpha 20 and then define a variable named var1 again locally in the form. This would naturally give 2 variables with the same name, but the parser does catch this.

New Global Includable Variables can be inserted by right clicking a and selecting Insert Object -> Insert Global Routine.

Inside the includable, only variables are allowed, so there is no begin_definitions, vars, const etc. section.

In a form or report you can now program:

begin_definitions
const

var

    s1     : string
    struct : structure
      h : numeric 3
      any_incl()
    end_structure

end_definitions

routine main
begin_routine

    d := 'John Johnson' // d is part of incl2()

end_routine

In this example the variables defined in Includable "any_incl", are now part of the structure “struct”.

This means that it is possible to insert the same includable multiple times in different structures.

Include – replacing.

An additional feature of includables is the use of changing text of the includable at the moment it will be in inserted in to code.

The syntax of the includable is:

Includable ([change TextWord1 to TextWord2 [,TextWord3 to TextWord4]])

Textword can be :

  • Pseudo-text, when it is passed with quotes
  • Word, when it is passed without quotes.

Pseudo-text means it allows replacing a series of words or characters as opposed to an individual identifier, literal or word.

If the includable does use the CHANGE phrase the includable is inserted into the calling program and each occurrence of TextWord1 in the includable is replaced by the corresponding TextWord2 in the CHANGE phrase.

The CHANGE phrase tries to match the TextWord1 items with text words in the includable text. If a match is achieved, then as the text is inserted from the includable, the matched text is replaced by the TextWord2 items.

The next example will make things more clearly as to what actually happens. Assume the following includable named incl1:



and incl2:



In the program there is the following call to the includable:

begin_definitions const

var

    p : integer
    incl1(change 3 to 2numeric to signedstr to structvvv to xyz'zzz' to 'v')
    i : string

booleans

end_definitions

routine main
begin_routine

end_routine


The lion parser now will compose the following code after inserting the includable into the program.

begin_definitions
const

var

    p       : integer

    // Start includable
    // incl1(change 3 to 2, numeric to signed, str to struct, vvv to xyz, 'zzz' to 'v')
    // becomes in code

    ga-1002 : signed 2                      // numeric to signed, and 3 changed to 2
    a       : signed 7                      // numeric replaced by signed
    b       : signed 4                      // numeric replaced by signed
    qqq     : alpha 20 value 'aaa xyz avvv' // vvv replaced by xyz, except avvv
    ppp     : alpha 20 value 'aaa v av'     // zzz replaced by v (pseudo-text)
    yyy1    : alpha 2                       // 3 changed to 2
    c       : signed 6.2                    // no change
    j       : string                        // no change

    i       : string

booleans

end_definitions

routine main
begin_routine

end_routine