Home Why Omnibasic Features FAQ Examples
Reviews Keyword/Syntax On-Line Manual Download Manual ScreenShots

Chapter 4

Data Types

A brief description of data types is given in the DIM and TYPE sections and a detailed coverage of pointer variables is given in the POINTER VARIABLES section. The mechanics of declaring variables and the various attributes assigned to them is explained in the DIM and TYPE sections.

The first classification of a variable is whether it is a simple variable or an array variable. An array is linear table of the data type. Two and three dimension arrays are also allowed. OmniBasic does no bounds checking of arrays at run time. This may be an advantage or disadvantage depending on whether the bounds violation is intentional or accidental. If it is accidental it is possible to “clobber” adjacent data. Intentional violation of array bounds is certainly not an example of structured programming, but does allow the programmer to take advantage of knowing how the data is stored and to, for example, treat a string as a byte array.

The second classification of a variable is whether it is local, global, or external. Local variables are known only to the module in which it occurs. Global variables are known to all modules in a set, which will be linked together. External variables refer to those that are declared to be global by another module but are referred to by the current module.

The third classification of a variable is whether or not it is a pointer variable. Pointer variables are variables in their own right and are a special form of a 32 bit unsigned integer which have a special property to index their value according to the data type which they are declared to point to. The data, which is accessed by a pointer variable, is treated as if it came from a standard variable of the type pointed to. There are three functions that are used with pointers. The first is ADDR() and is used to set the pointer to an address of a variable (presumably but not necessarily of the same type as the pointer). The second is BUFADR() which is used to set the pointer to the address of a memory buffer (see BUFFER, BUF(), BUFSIZ() section). The third is INDEX() which is used to index the pointer according to the function argument multiplied by the number of bytes in the data type of the pointer.

The fourth classification of a variable is whether or not it is a vector. Vectors (based variables) are similar to (but not the same as) “references” in C++. Vectors are closely related to pointers in concept. Once a vector has been declared with a DIM statement and subsequently assigned an address with a SETVEC statement, it may be used as an ordinary variable. The vector, then, has the power of a pointer without the need for pointer notation and allows array subscripting in buffers instead of pointer arithmetic.

Next Page: Chapter 5
Table of Contents


Home || Why Omnibasic || Features || FAQ || Examples
Reviews || Links || Privacy Statement || Top of Page

 

   Innomation Systems, Inc.

117 Morrison Ave. Morrison, MO 65061 (573) 294-6130

OmniBasic is a trademark of Innomation Systems, Inc., other trademarks are the property of their respective owners.
Innomation Systems, Inc. reserves the right to change prices and specifications without prior notice.
Copyright © 2000, 2001, 2002 Innomation Systems, Inc.