The API requires that your program call certain functions before others. The basic ordering rules are:
A program must call EssInit() before calling any other API functions.
A program must call EssLogin() or EssAutoLogin() before calling any API functions which require a context handle argument (most API functions). Additionally, if you need to create a local context for API object functions to use, you must call EssCreateLocalContext() before calling any API functions requiring a context handle argument.
Some API functions require an active application and database to be set. This is done by having the program call EssSetActive() or EssAutoLogin() before they are called.
C programs cannot call any functions except memory management functions from within custom message handling functions.
C programs cannot not call any API functions from within custom memory management functions.
A program must not pass a context handle to any API functions after calling EssLogout() for that handle.
A program must not call any API functions after calling EssTerm().
This is the typical order of operations for a simple API application:
Create and initialize an ESS_INIT_T structure.
Allocate any local static or global structures.
Log in to the required server by calling EssLogin() or EssAutoLogin().
Select an active application and database by calling EssSetActive() or EssAutoLogin().
Retrieve (or lock) data by calling EssReport() or related functions.
Update data by calling EssUpdate() or related functions.
Recalculate the database by calling EssCalc() or related functions.
Produce reports against the data by calling EssReport() or related functions.
Log out from the server by calling EssLogout().
Free any local static or global structures.
Terminate the API by calling EssTerm().