What Can Be Initialized (Magic xpa 4.x)
You should first define which objects can be initialized. These objects will be available to the process during its entire life cycle. The process can use and, in some cases, modify these objects whenever necessary.
The different types of objects that may be initialized are limited. We will describe various objects and situations where initialization is possible.
-
Memory tables – Memory tables are data sources that have values for as long as the context is alive. In some cases, it is useful to initialize these tables with data for performance purposes or with constant data. For example, if you have a list of operation codes that reside in a table on the server, be it a text file or a database table, it may be useful to import this list into a Memory table when the session is initialized to allow for better performance.
-
Variables – There are three types of variables that may be initialized:
-
Global variables for the entire application.
-
Subsystem variables, which are available for the current subsystem.
-
Procedural or thread variables, which are variables that are required for the current thread within the subsystem.
Value Added Tax (VAT) is a good example. Instead of fetching this value from the database every time, a variable can be updated on application initialization that holds the value for the entire session. This is an example of a global variable.
Another example is the name of the user currently logged in. An example of the initialization of a subsystem would be updating a variable with a unique value for use in text files, such as Username concatenated with the current date and time. In an Order subsystem, it might be necessary to have the current US$ exchange rate, which could be a variable that is initialized at the beginning of the subsystem.
-
Database tables – You often want to update actual database tables with values that will be available for all systems, such as updating a database table with the current foreign currency exchange rates. You should note that Resident Tables are loaded into memory when the application loads and are shared for all contexts. The developer cannot initialize these tables within the application.
-
Magic.ini file settings – Specific values in the Magic.ini file, such as Logical names or other user-defined initialization entries, can be initialized. Initializing a value using the INIPut function with the TRUE flag initializes the value for all sessions.
Tip:
|
Because INIGet is a server-side function, it is best to create a variable in the Application Main Program and initialize this variable with INIGet. This is especially useful for directory path Logical Names that can be used in all expressions instead of INIGet.
|
Initial Cleanup is not object initialization per se, but something that should also be taken into account. During previous processing, either in the current process or an earlier one, there may be some residue, such as temporary files in the application working directory or in the server temporary directory, and these files may need to be deleted. This should be done during the initialization process.