SIMPOL Documentation

Working with appframework.sml

The framework includes all the basic features that are required to produce a working, distributable, database-oriented program that just needs a menu, a tool bar (both of which are available in the samples), plus the code that is specific to that program's functionality (switching forms, calculating field values, running reports, etc.). It also includes support for both approaches to the user-interface, auto-locking and explicit locking. The functions for selecting records are not currently included in the framework, but are available in the sample programs and work with the framework. All the code for creating new records, modifying, saving, and deleting them, plus numerous utility functions and the implementation of the appwindow data type are also part of the library. The appwindow type is also suitable for building programs that have either only one main window, or applications with multiple top-level windows.

Some of the more useful utility functions, examples of which can be seen in the Address Book sample program, are:

  • checkneedsave()

  • getappwindowfromwindow()

  • getmenuitemwindow()

  • defer()

  • findfirstfocusablecontrol()

  • lookup()

  • gettableformatstrings()

This next list contains the functions that are used specifically as part of the data-entry process and which are meant to be directly associated with menu and tool bar items:

  • newrecord()

  • duplicaterecord()

  • modifyrecord()

  • saverecord()

  • deleterecord()

The two main data types that are provided by the application framework are the appwindow and the application. The application type is meant to provide a container for all of the things that might be needed throughout the application. This includes locale information, default format strings for data type conversion, the operating system type, a ring of data sources, information about the system (display size, named system color values, etc.), a placeholder for the window icon bitmap, and the title of the application. This type is meant to be incorporated in a user program's application type, if the needs of the user program exceed what is provided in the standard type.

The appwindow type is meant to contain information specific to the window. That includes the tables that are opened as part of it. It also contains a reference to the application object (or your own application object). It stores some state information, such as the current table, the last selected value according to the current index, the last value of the internal unique key for identifying records, whether the window is currently in fast selection mode (either fast forward or rewind), a reference to the physical window that it wraps, as well as references to the menu bar, tool bar, and status bar objects, for fast access. It also includes a number of very useful methods, such as findtable(), closeall(), opendatatable(), and openformdirect().

For full implementation details of these two types, as well as the others that are included, examine the source code to the application framework library, which is provided as part of the distribution and see the section called “application and the section called “appwindow.

[Warning]Warning

Do not change the source code to the appframework or the other libraries unless absolutely necessary! They have been carefully designed to work correctly and to permit extensions to be added using the event mechanism. If you need to make a change to a library to fix a bug, it is best to report it to Superbase Software Limited via email or on the forum and have us assess the problem. If you just want use a different function, then add it to the application or create a library of your own.

In summary, a typical application framework program will initialize the application object, create an initial appwindow object, and as part of that produce a menu, tool bar, and status bar. At that point, the program will call the application.run() method and it will remain there until the application is closed down. While in the run() method, it will respond to events, such as menu and tool bar events, or form button events. These events may result in new forms being loaded into one standard window, or it may result in multiple windows being opened, each potentially with its own menu and tool bar. The design is up to you.