Documentation
In keeping with our company philosophy of making sure that we use our own products (to keep us in touch with the needs of the customers), many of the lower level and higher level objects and functions are written in the SIMPOL programming language. Many of these are provided as full source code with the entire project code as samples.
The SIMPOL language components are found in the \lib directory
for inclusion in projects. Most of them have equivalent SIMPOL language projects in the
\projects directory. Programming samples are also primarily found in the
\projects directory. In the \samples
directory there are four subdirectories, each of which contains SIMPOL source files (but not projects), except for one that
contains SBL programs. The SBL programs demonstrate methods of calling SIMPOL from SBL, one of which determines
the dimensions of a JPEG image, the other makes the operating system "File Open" and "File Save" dialogs usable from
an SBL application. There are also a group of bitmap resources in the \resources
directory. Finally, in the \include directory are includable SIMPOL source files
for defining useful constants, such as standard error values, or for working with specific libraries. The list of standard
libraries continues to grow. In the following sections we will look at what is provided in more detail.
abs.sml— Implements theABS()function for returning the absolute value of a number or integerappframework.sml— Implements a fairly powerful application framework for creating GUI-style database-based applicationsboolstr.sml— This provides functions for converting boolean and datetime values into strings and also the reversebzip2.sml— This provides functions that wrap theBZip2.dllcompression librarycalceval.sml— Provides a function that can evaluate a string containing a formula and return the resultcalclib.sml— Provides a basic calculator that can be popped up and which returns the final resultcodepageslib.sml— Code page conversion library for converting to and from various code pagescolorpalette.sml— Provides a blob based storage for an image paletteconflib.sml— Library of functions for reading from and writing to configuration files in the Microsoft INI file formatdatabaseforms.sml— Data-aware form library providing the primary interface for working with data-aware forms and form controlsdatetimelib.sml— Collection of functions and types used to provide conversions from and to dates, times, and datetimes, in various formatsdb1lib.sml— Basic stub library that should never be called directly but which acts as a supplier of information to the IDE during development when using thetype(db1table)family of type tagsdb1util.sml— Database utilities library with routines for copying records, creating and maintaining system tables, etc.dbconverter.sml— Import/Export conversion library with support for ASCII-Delimited, CSV, XML, SBM, and PPCSerrormsgs_en.sml— Library that converts an error code into a an English-language message that describes the errorfastset.sml— A set object that allows elements to be string indexed objects of any type, implemented using red/black treesfilesyslib.sml— Functions for working with elements of a file system, such as parsing pathnames, retrieving the current directory, etc.formlib.sml— Functions and types for loading and saving data-aware forms and for saving forms as source codegaugelib.sml— Provides various progress gauge dialog typeshttpclientlib.sml— Objects for retrieving items from the web usingGETorPOSTimagelib.sml— Functions and types for reading and writing images in BMP and XPM formatint.sml— Implements theINT()function for converting a number to an integerjpeglib.sml— Currently only supplies functions for determining the dimensions of an image in JPEG formatlibxml.sml— Implements the Document Object Model Core Level 1 and 2 and part of 3 plus XSLT transforms and XPATH by working with the LXML componentlists.sml— Utility library providing various strutural types, such as nodes, lists, rings, queues, and stacksltrim.sml— Implements theLTRIM()function to trim spaces from the left of a stringmrulib.sml— Provides a library of types and functions for working with most-recently-used lists, including loading and saving to INI files and managing a submenuobjset.sml— An early implementation of a set object based on binary trees, but new code should use thefastset.smllibrary or the internal set typeodbc2.sml— Helper library for working with the ODBC client functionality that is part of the SIMPOL ODBC componentpad.sml— Implements thePAD()function to right-fill a string with spaces to a specified size (or to truncate if it exceeds that size)q1.sml— This is the library that implements the query optimizer for the SIMPOL report enginerandom.sml— Provides the random type for use in generating pseudo-random numbersreorglib.sml— Functions for reorganizing (repacking) databases in the SIMPOL database engine format (*.sbm)replace.sml— Provides thereplace()function for replacing all instances of one substring with another in a target stringrsalib.sml— Contains functions and types for working with RSA encryption, including key generation, encryption and decryptionsbislib.sml— Functions for working in a CGI environment, such asHtmlInclude(), orHtmlRead()sbldatelib.sml— Implements functions for working with dates and for formatting dates as stringssbllib.sml— Functions are provided that represent various FN-style functions from SBL, such asFN_Dec(),FN_Fact(), etc.sbllocaledateinfo.sml— Contains the SBLlocaledateinfo type for use with the date formatting functions insbldatelib.smlsbltimelib.sml— Functions for formatting times as strings and converting strings back to time valuessbnglib.sml— Contains useful types and functions for interfacing with SIMPOL Personal™, such as rings of data sources and tables, and an object for managing wxformoption objectssendkeys.sml— This library implements a SENDKEYS functionality for Win32sendmail.sml— Provides thesendmail()easy wrapper function to thesmtpclientlib.smlfunctionality for sending text-based SMTP emailsserialize.sml— This library implements a serialization mechanism for storing objects at runtime and reloading them latersessionid.sml— Functions and types for creating and manipulating session IDs using cookies for web applicationssessionid2.sml— Functions and types for creating and manipulating session IDs without cookies for web applicationsshellexecute.sml— Wrapper around the Windows API call for loading the appropriate executable for a given file type, ie. Acrobat Reader for*.pdffilessimpolpacker.sml— File archiving functionality with compression using the BZip2 compression format and a SIMPOL language archiversmtpclientlib.sml— Email functionality via SMTPsmtpdatelib.sml— Implementation of a date formatting function that accepts format strings using the standard SMTP date formatsoundlib.sml— Provides sound playback functionality that is currently Windows onlysortlib.sml— Various sorting algorithms such as Insertion sort, Quick Sort (iterative and recursive), etc.sql1.sml— The library providing a SQL92 report engine for SIMPOL databasesstr.sml— Provides theSTR()for formatting a numeric value as a string using a patternstringlib.sml— Numerous functions that implement useful string handling functionality, includingparsetoken(),ltrim(),rtrim(), etc.timer.sml— Provides a timer type that can call an event handler either once or at intervals and which runs in a separate threadtrim.sml— Contains theTRIM()functionuisyshelp.sml— Various functions and types for providing standard system defaults, such as system colors, default fonts, display size, etc.unittest.sml— Basic unit testing library that helps in running regression testsurlendecode.sml— Functions for doing URL-encoding and URL-decodingutf8lib.sml— Functions for converting from and to UTF-8 formatval.sml— Implements theVAL()functionvolatable.sml— Provides a fairly full implementation of a database that only exists in memory. Compatible to the sbme1 family except for table modificationwinfiledlg.sml— Provides a wrapper to the open and save dialogs from the operating system that can be called via thesmexec32.dllfrom a program such as Superbasexmllib.sml— Provides a number of useful programs for parsing and evaluating XML strings and can be used to enhance the functionality provided bylibxml.sml
SIMPOL Professional™ ships with a large number of sample projects. Many if not most of the libraries listed above are included as source code projects. Below is a basic description of the directories containing projects:
The console directory houses projects that demonstrate
basic functionality and are meant to be run from the console:
convert— Demonstrates a command line program for converting end of line characters in text files from DOS (CRLF) to Linux (LF) annd also to the older Macintosh format (CR)hello— The usual "Hello World" programppcsselectkey— A command line program for selecting a specific record from a table on a PPCS server and then showing the content of that record.urldump— A command line program for retrieving a page from the World Wide Web and either storing it in a file or dumping it to the console.
The DOM directory contains a sample program that fully
exercises the XML DOM
libxml_example— Contains 14 tests that demonstrate the various features of the XML DOM support in SIMPOL
The examples directory contains GUI programs, TCP/IP
sockets programs, and samples of using the lists.sml. To begin
with, the sockets examples are a pair of projects. The client
project and the server project are designed to work together
to demonstrate transferring a file from a server to a client upon request of the client.
client— Demonstrates using a TCP/IP-based client program to connect to a server and to communicate with it, including receiving both text and binary data.server— Shows how to create a custom TCP/IP-based server program that implements a basic protocol and which then acts upon connections and can send and receive text data and which then sends binary data.
There are four samples that demonstrate the use of various types from the
lists.sml library. These are:
listsample— This example demonstrates how to use the list and listnode types in order to wrap existing objects and possibly add information to them in addition to managing them in a list.ringsample— This example demonstrates how to use the ring and listnode types in order to wrap existing objects and possibly add information to them in addition to managing them in a list.dlistsample— This example demonstrates how to use the dlist and dlistnode types in order to wrap existing objects and possibly add information to them in addition to managing them in a list. Both dlist and dring types are better choices when you need to insert or delete from the list or ring, since they are more efficient in these operations.dringsample— This example demonstrates how to use the dring and dlistnode types in order to wrap existing objects and possibly add information to them in addition to managing them in a list. Both dlist and dring types are better choices when you need to insert or delete from the list or ring, since they are more efficient in these operations.
There is a single example that shows the use of the dataform1 type family and which loads any
valid form stored as an *.sxf file (opening the data sources that are referenced in the form)
and then allows the browsing of records using the form. That example is:
dataforms— Loads and allows the browsing of data in any valid form
The udtmemberopsample project explains the implementation and use
of the SIMPOL member operator (!) in a user-defined type. It is an advanced topic, but can be useful depending
on the complexity of the application being developed.
udtmemberopsample— demonstrates the use of the SIMPOL member operator in a user-defined type
The remaining projects in this directory all demonstrate various capabilities within the GUI controls provided via the wxWidgets library.
ole2excel— is a sample program that demonstrates the use of OLE2 automation to open Excel, create an Excel workbook, add data, select and calculate that data, create a chart, and then read the results back out into SIMPOLwxdialog— is a very small program that demonstrates the use of the wxdialog type to create a modal dialog and wait until it is closed or the is pressed.?wxdialog2— is a very small program that demonstrates the use of the wxdialog type to create a non-modal dialog and wait until it is closed or the is pressed.wxdialog3— is a very small program that demonstrates the use of the wxdialog type to create a modal dialog using the standard buttons feature, and then waits until it is closed or the is pressed.wxdialog4— is a very small program that demonstrates the use of the wxdialog type to create a non-modal dialog using the standard buttons feature, and then waits until it is closed or the is pressed.wxforms— is a minimal program that demonstrates the use of the wxform and wxwindow types to display a form in a window and then wait for events.wxforms2— is a small program that demonstrates the use of the wxform and wxwindow types together with a group of form controls on the form that allow modification and include sample data. Pressing the button will evaluate the selections and content from the various form controls, close the window and return that as a result.wxgrid— is a small program that demonstrates the use of the wxgrid including various aspects of using the grid control.wxmenu— is a minimal program that demonstrates the use of the wxmenubar, wxmenu, and wxmenuitem types to create a basic menu bar that shows the various features supported and to add that to a window.wxwindows— demonstrates the minimal amount required to create a window on the screen and then wait for events.wxwindows2— creates four different windows of various styles. Closing any of the windows closes all of them and ends the program.
The forms directory contains some more sophisticated
form-based GUI examples. One of them shows various controls in a number of configurations, the other is a
dedicated import program that can import from PPCS data sources into SBME. It was originally designed to
assist the conversion of applications from Superbase into SIMPOL.
demo— demonstrates the use of the various features that SIMPOL provides via wxWidgets.importppcs2sbme— implements an import program that makes use of PPCS, SBME, plus the GUI components via wxWidgets.
The largest number of samples can be found in the Libs directory,
which contains projects that implement reusable functionality either as functions or types.
ABS— implements theABS()function for returning the absolute value of a number or integerappframework— provides a fairly powerful application framework for creating GUI-style database-based applicationsboolstr— formatting library for converting boolean and datetime values to string and backbzip2— compression library wrapper for the BZip2 compression format and theBZip2.dllcalceval— library for evaluating a string and parsing and carrying out the calculation formula and returning the resultcodepageslib— code page conversion library for converting to and from various code pagesconflib— library of functions for reading from and writing to configuration files in the Microsoft INI file formatdatetimelib— library of functions for converting to and from dates, times, and datetimes (includes various other libraries plus its own functions)db1lib— library that implements a stub class to match the db1 type tag family so that the IDE will provide useful information when working with variables that are defined astype(db1table)for exampledb1util— database utilities library with routines for copying records, creating and maintaining system tables, etc.fastset— a set implementation compatible with the objset type but faster using red-black treesfilesyslib— functions for working with elements of a file system, such as parsing pathnames, retrieving the current directory, etc.gaugelib— provides various progress gauge dialog typeshttpclientlib— objects for retrieving items from the web usingGETorPOSTimagelib— functions and types for reading and writing images in BMP and XPM formatINT— implements theINT()function for converting a number to an integerjpeglib— currently only supplies functions for determining the dimensions of an image in JPEG formatlists— utility library providing various structural types, such as nodes, lists, rings, queues, and stacksLTRIM— implements theLTRIM()function to trim spaces from the left of a stringmrulib— provides a library of types and functions for working with most-recently-used lists, including loading and saving to INI files and managing a submenuobjset— an early implementation of a set object based on binary trees, but new code should use thefastset.smllibrary or the internal set typePAD— implements thePAD()function to right-fill a string with spaces to a specified size (or to truncate if it exceeds that size)random— provides the random type for use in generating pseudo-random numbersreplace— provides thereplace()function for replacing all instances of one substring with another in a target stringrsalib— contains functions and types for working with RSA encryption, including key generation, encryption and decryptionsbislib— functions for working in a CGI environment, such asHtmlInclude(), orHtmlRead()SBLDateLib— implements functions for working with dates and for formatting dates as stringssbllib— functions are provided that represent various FN-style functions from SBL, such asFN_Dec(),FN_Fact(), etc.SBLlocaledateinfo— contains the SBLlocaledateinfo type for use with the date formatting functions insbldatelib.smlSBLTimeLib— functions for formatting times as strings and converting strings back to time valuessendmail— provides thesendmail()easy wrapper function to thesmtpclientlib.smlfunctionality for sending text-based SMTP emailsshellexecute— wrapper around the Windows API call for loading the appropriate executable for a given file type, ie. Acrobat Reader for*.pdffilessimpolpacker— Compressed archive functionality that uses the compression from BZip2 together with an archiver written in SIMPOLsmtpclientlib— email functionality via SMTPsmtpdatelib— implementation of a date formatting function that accepts format strings using the standard SMTP date formatsortlib— various sorting algorithms such as Insertion sort, Quick Sort (iterative and recursive), etc.soundlib— Library with the long-term plan to be the host for sound playback routines, currently supports Windows sound playbackSTR— provides theSTR()for formatting a numeric value as a string using a patternstringlib— numerous functions that implement useful string handling functionality, includingparsetoken(),ltrim(),rtrim(), etc.timer— provides a timer type that can call an event handler either once or at intervals and which runs in a separate threadTRIM— contains theTRIM()functionuisyshelp— various functions and types for providing standard system defaults, such as system colors, default fonts, display size, etc.unittest— basic unit testing library that helps in running regression testsurlendecode— functions for doing URL-encoding and URL-decodingurllib— split out of a small library containing a type and function for parsing a URL from a string into its component partsutf8lib— functions for converting from and to UTF-8 formatVAL— implements theVAL()functionwinfiledlg— provides a wrapper to the open and save dialogs from the operating system that can be called via thesmexec32.dllfrom a program such as Superbasexmllib— provides a number of useful programs for parsing and evaluating XML strings and can be used to enhance the functionality provided bylibxml.sml
A series of command line programs that make use of the single-user database engine can be found in the
sbme directory. This includes two utility programs for doing database
maintenance and repair.
jdktutorial— was inspired by one of our users. It provides a basic tutorial on using the sbme1 family of types to first create, then populate a table in a container file. Then to open lock and modify records in that container file.reorganize— provides a command line front-end to the functionality inreorglib.smlfor repacking one or more database tables.sbd2sbme— makes use of thesbflib.smllibrary to read a Superbase*.sbdfile (containing the table description) and to then create an empty SIMPOL database that matches the table layout including data types and field names.sbmecust— reads records from the CUST table at simpol.com port 1280 and creates an*.sbmfile with the same table.sbmecust2— provides a timing test for reading records from one table and creating with them another table.sbmecust3— demonstrates creating a duplicate table in the the same container as the original table.sbmereadcust— shows how to read records from a table and output them to a text file in XML format.sbmerepair— provides a command line based repair program to fix a database table in the unlikely event that it may have become corrupted.
All of the sample programs used in this book that are not located elsewhere can be found in the
Projects\tutorial directory.
addressbook— implements a basic address book application using data-aware forms and the application framework.colorlab— demonstrates a dialog-style application program.sbair— contains the form, program, and required database tables from the Superbase Airlines sample that is converted in the Chapter 9, Converting Superbase chapter.
A full suite of web server programs, which work using CGI or ISAPI are contained in the
ssp directory. To use the samples, make sure that the items from the
Apache directory are placed in the appropriate locations. The items
from the htdocs directory include the items in the
css directory and the images that are located in the
images directory. The items in the
cgi-bin should be placed in the appropriate cgi-bin location in your
system. These items are used by the web server sample projects. There is also a directory called:
include, which contains chunks of code used by more than one project
in this group. The ppcsserver directory contains a Superbase server
program and associated database files, as well as a SIMPOL server program (simpolserver.smp)
together with the necessary database container files and the configuration file for the server
(sspsamples.cfg — read the readme.txt to run or stop the
server).
The examples in this section do not demonstrate particularly attractive web pages. They are very basic in their look and feel. Designing attractive web pages is better done in an HTML authoring tool. These examples demonstrate how to use SIMPOL to dynamically create pages, as well as showing how to interact with the database and to accept data over the web. Most of the more interesting SIMPOL-based web applications are normally designed using CSS and XHTML in a proper authoring tool, and then the template pages are migrated into SIMPOL and set up to use parameters so that they can be output with varying content by the programs.
![]() | Note |
|---|---|
All of the samples that begin with "sbis" were translated from the original samples included with the Superbase Internet Server program (SBIS). |
hellocgi— is designed using the "server page" approach. That uses a file calledhellocgi.smz, which is an HTML file containing special comments that are processed by the SIMPOL IDE into a SIMPOL program file with the same name. This is then compiled as part (or in this case as all) of the program.sbiscalendar— demonstrates creating and outputting a calendar using a table.sbiscontact— is a sample contact database with the ability to view the records in a simple record view format. It also allows browsing with First, Previous, Next, and Last buttons. These all call the same program with specific parameters. On the right-hand side are another set of buttons: Add, Search, Report, and Report2. These buttons call either directly or indirectly other programs in the group.sbiscontactdisplay— displays a selected record (found as a result of searching using the Search button. If the selected record is not found, it redisplays the search page.sbiscontactpost— handles the posting of a new record as a result of a cal to the Add function insbiscontact.sbiscontentsframe— is part of thesbisframesample, although frames have now gone very out of fashion in web design.sbisenvvars— outputs all the various CGI variable values (plus those supplied by ISAPI if called from IIS) that can be retrieved via the cgicall type'sgetvariable()method.sbisframesample— uses various SIMPOL programs to provide different frame content for each of the various frames. Frames are no longer particularly popular in modern web design, but can still have their uses.sbisimagesample— demonstrates a dynamic page that shows an image.sbisincludesample— shows the method of including an external HTML file into the output going back from the program to the browser.sbismainframe— is part of thesbisframesample, although frames have now gone very out of fashion in web design.sbisreport— runs an unoptimized report that shows its results in a table and does a three-level sort of the results. Each line of the results can be clicked on to call thesbiscontactdisplaycode to show the record for the resulting selection.sbisreportfast— runs an optimized report that shows its results in a table and does a three-level sort of the results. Each line of the results can be clicked on to call thesbiscontactdisplaycode to show the record for the resulting selection.sbistitleframe— is part of thesbisframesample, although frames have now gone very out of fashion in web design.
A few basic test programs can be found in the tests directory.
chartest— could actually be called echo, since it returns whatever text is passed in the first parameter to the function.urldecode— makes use of theurlendecode.smllibrary to decode the contents of the file that is passed on the command line. If the file does not contain url-encoded data, then it may do nothing.utf8dectest— attempts to convert the content of the file name passed as the command line parameter from UTF-8 to SIMPOL string format. Makes use of theutf8lib.smllibrary.utf8enctest— converts the text passed as the command line parameter to UTF-8 and stores it in a file calledtest.txt. Makes use of theutf8lib.smllibrary.utf8test— does a full test creating UTF-8 output to a test file, then reading it in and decoding it for comparison. Demonstrates working with input and output files, and uses theutf8lib.smllibrary.
SIMPOL Professional™ contains six different books that cover various aspects of using the product. These are:
SIMPOL Quick Start Guide (this book)
There are a number of standalone utility programs included with SIMPOL Professional™. These include:
dataconvertwx.smp— a standalone import/export program that can convert data from one format to anotherimagetool.smp— provides a tool for manipulating images for creating bitmap buttons (contributed by John Roberts)projectfixer.smp— a program for changing the paths in one or more projects files in a subdirectory treesaveimagetoblob.smp— a program that opens an image and writes out a SIMPOL source code program that provides a function that contains the image as a blob and can return it as a wxbitmapsbf2sbm.smp— a program for converting a list of Superbase database files into SIMPOL database filessbmerepair.smp— a program for repairing a database by retrieving all records via their unique internal record ID (ignores indexes completely and can also ignore sequential linking problems)
To support Superbase programmers and users, there are a number of conversion tools that are provided in the Superbase SBL programming language. These are:
dlg2sma.sbp— a converter for Superbase dialog programs saved from the Superbase Dialog Editor into SIMPOL source code to create the equivalent form using the wxWidgets-based componentsngmengen.sbp— converts Superbase menu programs saved from the Superbase Menu Editor into SIMPOL source code using the wxWidgets-based componentsPPCS Header File Code Generator.sbp— can create a special SIMPOL source file that defines a user-defined type for working with the same database (from a Superbase original database table definition) via PPCS from SIMPOLsbv2wxformsma.sbp— generates a SIMPOL source program that will recreate a non-data-aware form program from a Superbase formsbv2xml.sbp— generates a SIMPOL XML form file that is directly loadable from the SIMPOL data-aware form support, assuming that the database tables have been saved as SIMPOL equivalents, which can be used as the starting point for working with the form in the SIMPOL Form Designer


![[Note]](images/note.png)

