SIMPOL Documentation

Chapter 20. Moving from SBL to SIMPOL

Making the move from being a traditional Superbase SBL programmer to being a SIMPOL programmer doesn't need to be as complicated as many people might believe. Although SIMPOL is an object-oriented programming language, it is not nearly as complex or difficult as learning Java, C#, or even VB.NET. There are very few key words and no real commands in SIMPOL. In SBL there are literally hundreds of key words and a very complicated set of parameters that can be passed to each command. If your SBL programs begin with a SUB main() and tend to be event-driven, spending most of the time in a loop waiting for the user to do something, then writing programs in SIMPOL won't be terribly complicated for you, but even if you have gotten into the habit of just using global variables and GOTO, GOSUB, and RETURN, it is still possible to learn to write programs in SIMPOL without too much effort. In the latter case, the job is complicated somewhat by needing to learn to use structured programming techniques and do some advance planning before writing the program, but the benefits are considerable: easier to understand code, easier and faster maintenance, and a greater amount of code reuse resulting in smaller programs and an ever-growing toolbox of useful functions (and types).

The Basics

It is probably useful to discuss the available data types and programming elements, and then have a look at the various commands from SBL and see how they are done using SIMPOL. In SBL there are four basic data types: strings (maximum length 4000 characters), short integers (-32,768 to +32,767), long integers (-2,147,483,648 to +2,147,483,647), and IEEE double-precision floating point numbers — decimal values — (± 10-323.3 to 10308.3). Variables of these types are indicated by using the dollar sign ($) for strings, a percent symbol (%) for auto variables (can hold any of the numeric types), two percent symbols (%%) for short integers, the ampersand and percent characters (&%) for long integers, and either the hash and percent (#%) or exclamation mark and percent (!%) characters for decimal values. In SIMPOL there is also a string type (maximum length is limited by memory), an integer type (greater degree of significant digits than an SBL HugeInteger), a number type (exact precision, not floating point and virtually unlimited size), a boolean type (true and false values), and the blob type (virtually unlimited in size array of bytes). SIMPOL does not use any characters to indicate data type for variables so it is generally a good idea to use some sort of convention, such as a leading s character for strings, i for integers, b for booleans, bl for blobs, and n for numbers. Which convention is used is not as important as simply picking one and being consistent in its use. It is even okay to use b for both blobs and booleans if it is obvious which is which.

One of the biggest and most significant differences between SBL and SIMPOL is the capability in SIMPOL to create user-defined data types. This capability can completely change the approach to solving a problem. It also makes it possible to use a much more object-oriented approach to solving a problem, though it is not required to do so. User-defined types can include properties that are of any of the standard types, be references to other objects, or be actual embedded objects of some other complex type including user-defined types. This allows for fairly complex object design, which can help to solve many problems that in SBL programs would only be able to be solved by using sets of variables and variable arrays. One of the biggest advantages to using user-defined types is that when passing information from one function to another, the interface does not need to change if one more piece of information is required. Instead the type is changed and the information is added to the object that is being passed, so no change to the parameter list of the function is necessary.

SIMPOL has a very small set of key words, which are listed below:

  • and

  • AND

  • else

  • embed

  • end

  • export

  • function

  • if

  • mod

  • not

  • or

  • OR

  • reference

  • resolve

  • type

  • while

  • XOR

It also has a useful set of operators, which are summarized in the following list:

  • :, ;

  • ,

  • +

  • -

  • *

  • /

  • ==

  • >

  • <

  • >=

  • <=

  • <>, !=

  • @=, =@

  • =@=

  • !@=, <@>

  • ()

  • []

  • {}

  • ", '

  • //

  • "", ''

  • \

For a complete description of the key words and operators please see the SIMPOL Language Reference. Unlike classic SBL, SIMPOL has an extremely small set of key words, a slightly larger set of operators, a number of intrinsic and system functions, and an ever growing number of components, free functions and types (some of which are created using SIMPOL itself). In SBL there is a large number of key words, some of which are operators, some of which are commands, and some of which are functions. There is also a fairly large set of objects that model a number of the components of the system, such as the forms, form controls, and windows, but which do not have a representation for the database files, fields, indexes, and records. In SIMPOL everything that is not a key word, an operator, an intrinsic function, or a system function, is a type and to work with the type it provides built-in methods (functions) and in some cases allows the assignment of event handling functions. In the next section we will compare the key words that actually represent the underlying language structure and in a later section we will explore the special commands and functions.