Amos Professional Manual  Contents  Index

Procedures


There is an alternative method of passing data between a procedure and the main program. When SHARED is placed inside a procedure definition, it takes a list of local variables separated by commas and transforms them into global variables, which can be directly accessed from the main program. Of course, if you declare any arrays as global using this technique, they must already have been dimensioned in the main program. Here is an example:

E> A=666: B=999
   EXAMPLE
   Print A,B
   Procedure EXAMPLE
    Shared A,B
    A=B-A: B=B+1
   End Proc

EXAMPLE can now read and write information to the global variables A and B. If you need to share an array, it should be defined as follows:

X> Shared A(),B#(),C$()

In a very large program, it is often convenient for different procedures to share the same set of global variables. This offers an easy way of transferring large amounts of information between your procedures.

GLOBAL
structure: declare a list of global variables for procedures
Global list of variables

GLOBAL sets up a list of variables that can be accessed from absolutely anywhere in your program. This is a simplified single command, designed to be used without the need for an explicit SHARED statement in your procedure definitions. Here is an example:

E> A=6 : B=9
   Global A,B
   TEST1
   TEST2
   Print A,B
   Procedure TESTI
    A=A+1 : B=B+1
   End Proc
   Procedure TEST2
    A=A+B : B=B+A
   End Proc

AMOS Professional programmers who are familiar with earlier versions of the AMOS system are now able to employ the new facility of using strings in procedure definitions. As with disc names, the "wild card" characters * and ? can also be included. In this case, the * character is

Back    Next
05.05.06