SIMPOL Documentation

application

The basic approach to developing a program using the application framework is: initialize the program (create the application object and the first appwindow and display it to the user with whichever form, menu bar, status bar, and tool bar required), call the run() method of the application object and respond to events with event handling code, and finally cleanup when asked to exit.

The application framework provided with SIMPOL in the appframework.sml library file includes several data types and a number of functions that together with the items that are included in the formlib.sml library, such as: the dataform1 and printform1 families of types, plus the numerous functions included in the library for formatting types, working with databases, parsing information and other useful tasks, make it eay to create robust database-based applications. The key to this functionalty lies in the two main types: application and appwindow. Information that is universally required is associated with the application type. Information that is specific to a single window is associated with the appwindow type. Some useful information about working with the application framework can be found in Chapter 26, Using the SIMPOL Application Framework. Let's start by having a look at the application type:

Table 22.10. application Properties
PropertyDescription
localeinfoold SBLlocaleThis contains the datelocale and the numlocale properties, that are used in formatting dates and numbers throughout the libraries.
dring datasourcesThis is a ring of data source objects using the datasourceinfo type. Data sources are stored at the application level since they need to be used by all aspects of the program. Single-user data sources like sbme1 cannot be opened multiple times even by the same program, so the intiial open is used by all elements within the program. Also, even though it is possible to open the same table more than once using PPCS, the objects would not be compatible even on the same table if used from more than one opened instance.
tdisplayformats displayformatsThis contains a set of string properties. One for each of the default data types that might need conversion to or from string. The properties are: defboolean, defdate, defdatetime, definteger, defnumber, and deftime. They are designed to work together with the functions: boolstr(), DATESTR(), datetimestr(), STR() (used by both integer and number values), and TIMESTR().
string inifilenameThis property provides a placeholder for the name of the configuration file that might be associated with the program. See the conflib.sml for functions that work with configuration files.
localeinfo localeThis contains a more modern set of locale information, which can be of use in an application, though it is currently there for potential future expansion.
event onexitrequestThis event provides a mechanism whereby the application programmer can be called to determine if the application should close. If the user closes the last open window then in the closewindow() function if this event is defined, the user program will be called and the application will only be closed if the return value is equal to .true. Otherwise the window being closed will be redisplayed. The handler function takes the following parameter types: (application, wxwindow, type(*) reference). The final reference parameter will only be passed if it is defined.
integer ostypeThese are currently defined in the application source file as: OS_UNKNOWN 0, OS_WIN32 1, OS_LINUX 2. Although every effort is made to ensure transparency between platforms, sometimes it is necessary to detect the platform.
ppcstype1 ppcsThis is the place holder for a ppcstype1 object that can be used throughout the application for opening PPCS-based tables. The system treats all tables coming from the same IP address and port as being part of a single data source.
boolean runningThis property is set to .true when the system enters the run() method of the application object. The exit code in various places will set this property to .false so that it exits the run loop and exits the run() method.
sysinfo systeminfoThis type contains information about the environment and is initialized during the creation of the application object. This includes the size of the display, thickness of scroll bars, the list of system colors and their RGB values, and the system default font.
string titleThis is the default caption for the windows of the application.
wxbitmap windowiconTo promote efficiency, this contains the bitmap used for the window icon in the various windows displayed by the program.
dring windowsThis ring contains the appwindow objects that are created in the application. By using this ring all of the various application windows can be examined even if no appwindow is currently available. It also allows the programmer to iterate through all of the appwindow objects if they have one.


The basic approach to working with the application type is to create another application type specific to the user's program, such as myapplication, insert the application type into it as the first element marking it as reference and resolve (reference because it is important to call the new() method of the application type and resolve so that the properties of the application type appear to be built into the myapplication type). Also type tag the myapplication type as application. There are a number of functions that take an argument of type(application) and this is done so that a derived application type will still work when passed to the function.