Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

User defined types

 

ThinBASIC offers various elemental numeric and string data types. These are very useful in number crunching and text manipulation.

 

Once you start describing real world objects or more complex math problems, you may feel the need to somehow group the data together into more complex structures.

 

These structures are called user defined types (UDT) in thinBasic.

 

Syntax

 

ThinBASIC uses type / end type block to denote user defined type definition.

 

TYPE nameOfType [alignmentModifier] [EXTENDS baseType]

  element

  [otherElements]

  [dataHandlingfunctions]

END TYPE

 

Example

 

The definition of type looks complicated, but keep in mind only two parameters are mandatory:

1.name of type

2.at least one element

 

To give specific example, if you want to represent a point in 2D, you could design the following UDT:

 

TYPE Point2D

  x AS SINGLE

  y AS SINGLE  

END TYPE

 

The name of type is Point2D and it has two elements - x and y, each of SINGLE basic data type.

 

You can create variable of user defined type the same way as you do with conventional data types:

 

DIM point AS Point2D

 

In order to write or read the data, you can use the dot notation:

 

point.x = 1

point.y = 2

 

msgBox 0, strFormat$("{1}, {2}", point.x, point.y) 

 

Arrays of user defined types are supported as well.

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software