SIMPOL Documentation

Assignment Operators

The standard assignment operator in SIMPOL is the equals symbol (=). This operator is used to assign a value to an object that is a value type. In other words, to assign a value to an integer, a number, a string, or a boolean object. This is equivalent to the use of the equals symbol in C and C++ and the assignment operator in Pascal and Delphi (:=). Unlike in most BASIC-derived languages, including the existing Superbase Basic Language (SBL) and Microsoft's Visual Basic, the equals symbol is not allowed to be used for both assignment and comparison. It is strictly used for assignment. See the section on comparison operators for more information.

As was discussed earlier in the chapter on data types, SIMPOL has two primary data types, value types and object types. For the value types the equals operator is used, since it is merely assigning a value to a variable. In the case of the object types, there is lot more going on, and it is important to realize that instead of a value being assigned to a variable, a reference to an object is being assigned to that variable. In SBL and Visual Basic, this is typically done using the SET keyword, as in:

DIM f AS Form
DIM c AS FormControl
SET f = Forms.Add("MyForm")
SET c = f.Controls.Add("tb1", "TextBox")

Rather than using a keyword, in SIMPOL there are two operators that can be used to make the assignment, either @= or =@. The example above converted into SIMPOL might look like this:

wxform f
type(wxformcontrol) c
f =@ wxform.new(...)
c =@ f.addcontrol(wxformedittext, ...)

This example is loosely based upon the current wxWidgets components and their data types. It would not actually work in SIMPOL as it is written unless the method calls were filled out with all of the relevant parameters.