The Nested Program Model

When programming using the API, your code should adopt the nested programming model. In the nested programming model the code has calls to an initial function and a corresponding final function. The calls are arranged as a sandwich, with the code to perform some action in between as the filling. Consider the following example:

begin action 1
        begin action 2
                begin action 3
                        perform action 3
                end action 3
                begin action 4
                        perform action 4
                end action 4
        end action 2
end action 1

The implication of this arrangement is that you should ensure that you end every action or operation that you begin. Here is a more concrete example that uses real API actions:

Initialize the API
        Login to a server
                Connect to a database
                        Open a database outline
                                Browse the outline
                        Close the outline
                        Open a report
                                Modify & save the report
                        Close the report
                Disconnect from a database
        Logout from the server
Terminate the API

The example above illustrates the basic structure of any code that accesses the Essbase API.