What is GFA-BASIC 32?
 

Overview

GFA-BASIC 32 is no longer divided in an interpreter and a stand-alone compiler. When run from the IDE the code is first compiled to machine code and then executed. The compiler is optimized for producing fast machine code, so that GFA-BASIC 32 programs execute at high speed. The command library of GFA-BASIC 32 is partly compatible to Visual Basic and 16-bit GFA-BASIC. Much of the functionality of the 16-bit version is retained, but due to an entirely new concept of creating and handling of windows and dialog boxes, GFA-BASIC 32 is also quite different and much more compatible to VB in that area. Other incompatibilities are due to the 32 bits operating system; an integer is now 32-bits wide rather than the 16-bits in GFA-BASIC 16-bit, for instance. When porting application from 16-bits GFA-BASIC, GFA-BASIC 32 will automatically convert 16-bit code to the new 32-bit syntax.

GFA-BASIC 32 files are single project files. Code, forms (windows and dialogboxes), data, resource info are all contained in one file; the .g32 file. To create modular programs part of the code can be compiled in a library file (.lg32) and included into the project file.

An odd number of parenthesis in a code line are auto-completed to match all required parenthesis (this might lead to problems though, because the parenthesis are not always inserted at the correct location!). The underscore character ( _ ) can be used to split "logical" lines of source code, across physical lines in the source code file.  The underscore character must be preceded by at least one white space character. The effect of using a line continuation character is for "visual" appearance only - the compiler itself treats lines split this way as only one contiguous line of code. The colon character (:) can be used to separate multiple statements on a single (logical) line of source code.
Subs and functions can be folded ofcourse. Procedures can have optional parameters and the code is automatically indented and formatted.

You can use GoSub and Return anywhere in a procedure, but GoSub and the corresponding Return statement must be in the same procedure. A subroutine can contain more than one Return statement, but the first Return statement encountered causes the flow of execution to branch back to the statement immediately following the most recently executed GoSub statement. Using a GOSUB to perform a repetitive task is almost always faster then performing a call to a Sub or Function, since there is no overhead in setting up a stack frame for a GoSub.
GFA-BASIC 32 al
so supports an implicit conditional form (?:). It uses a question mark after the condition to be tested, and specifies two alternatives, one to be used if the condition is met and one if it is not. The alternatives are separated by a colon.

The Integrated Development Environment can be extended through the use of add-ins, called editor extensions. More than 100 special Gfa_XXX functions and statements provide access to manipulating the environment. For repetitive action keystrokes can be recorded and played back.  < xml="true" prefix="o" namespace="">

New data types
New data types are Large (64-bit), Date, Currency, Variant, Object, Pointer and Handle. Integer and long are now 32-bits. Variables declared without specifying a type explicitly are a Variant data type by default.

Array, Hash and Collection
Arrays elements can be inserted and deleted. The array can be sorted using quick sort or shell sort. The
Hash is a one dimensionale array whose index is of type string. The array can be of any type, Int/String/Date/etc. A Hash array is dynamic and is not dimensioned prior to its use. Values are added or assigned to existing elements. A hash can be examinied, sorted, saved and loaded. Elements can be accessed by numeric index as well. Access to hash elements are very fast. The Hash is used with Split, Join, Eval and the regular expression functions reMatch, reSub.
The Collection is a one dimensionale variant array whose index is of type variant. A collection is dynamic and is not dimensioned prior to its use. Values are added or assigned to existing elements. The collection is mainly targeted at OLE objects.

Const and Enum
A constant is a variable whose value is fixed at compile-time, and cannot change during program execution (hence, it remains constant). A constant is defined using the Const keyword. The Enum keyword is used to define a sequence of constants whose values are incremented by one.

$-postfix for string functions
For string functions the $-postfix is no longer mandatory, as in Chr$(0) which becomes Chr(0). The return value from a $-free string functions is NOT a Variant as in VB, but a real (ANSI) string. New are the Pascal compatible character constants #number that can be used in place of Chr(number). The following "Line1" #13#10 "Line2" #13#10 is the same as "Line1" + Chr(13) + Chr(10) + "Line2" + Chr(13, 10).

String concatenation operators & and $
Also new is the string concatenation operator & as used in VB by default. This may lead to strange results, because the numeric operands are automatically converted to strings:

"Number" & 7       "Number 7"
12 & 6                  " 12 6"

In 16 Bit GFA-BASIC is the & - operator the same as And (as in 'C'), meaning 12 & 6 = 4 ó 12 And 6 = 4 (%1100 & %0110 = %0100). In GFA-BASIC 32 a new And operator is added, the %&. So, in GFA-BASIC 32 is 12 %& 6 = 4 (%1100 And %0110 = %0100).
Another quirk coming from VB is the additional space before the numbers when converted to a string this way. You can prevent the automatic conversion of numeric values to strings when using the & operator in the properties dialog box.
Alternatively, GFA-BASIC 32 offers the operator $ as a replacement for the & concatenation operator.

Comparison and assignment operators
In contrast with 16 Bit GFA-BASIC the expression x == y is now the same as x = y and x := y. The comparison == operator from16 Bit GFA-BASIC should now be replaced by NEAR. Alternatively, you can use a forced floating point comparison like If a = 1!.

Direct memory access
For direct memory access a whole range of variants of Peek and Poke are available (PeekCur, PokeStr, etc, etc.).
Memory move and manipulation commands are provided (MemMove, MemOr, MemAnd, MemFill, etc).
’Bits and bytes’ swap and make functions (BSwap8, MakeLiHo, etc, etc).
Bits rotate and shift is supported.
Port access is supported (Port Out, Port In).

Arithmetic
Besides to the normal arithmetic functions, GFA-BASIC 32 offers Matrix functions and many more  (advanced) mathematical functions.
For runtime expression evaluation GFA-BASIC 32 includes Eval().

Special file functions
Special file functions are for checksums (Crc32, Crc16, CheckSum, etc), file encryptions (Crypt), file compression (Pack/UnPack). Others are MimeEncode/MimeDecode, MemToMime/MimeToMem, and UUToMem/MemToUU.

Built-in Win32 API functions
GFA-BASIC 32 supports more than 1000 WinAPI-Functions, functions that can be used as any other GFA-BASIC 32 function. Only the Standard-API-Functions from User, Kernel und GDI are implemented, other not often used API-Functions like for instance WinSock-Functions are to be declared explicitly as in VB.  

The type of the parameters of the built-in API-Functions are not checked upon compiling. Each parameter is assumed to be a 32-bit integer. A string can be passed to an API function, but is always copied to one of the 32 internal 1030-Byte buffer BEFORE the address of the buffer is passed. A user defined Type (As type) is always passed by reference, so that its address is passed (automatically V: ).  To be on the safe side, keep things in your own hand and pass the addresses explicitly using Varptr or V:.

These rules don’t apply to DLL functions introduced with the Declare statement. Here GFA-BASIC 32 behaves like VB and the rules for calling such APIs must be respected. For a thorough article on using see Visual Basic Programmers Guide Chapter 10 - The Windows API and Other Dynamic-Link Libraries.

Some WinAPI function names are already in use by GFA-BASIC 32 as statement or built-in function names and are therefore renamed. GetObject() becomes GetGdiObject(), LoadCursor becomes LoadResCursor. Obsolete functions are not implemented, obviously.

Built-in Win32 API constants
As with the built-in API functions from User, Kernel and GDI, their accompanying constants are built-in. (1400 API-Constants from the 16 Bit-Version and more then  900 Constants from Win32-APIs are implemented. Obsolete constants are not implemented, obviously.

Graphics
Graphic commands take floating point values now. After scaling (set with ScaleMode) the coordinates are passed as integers to the GDI system. Scaling provides much more flexibility and is VB compliant.
Most graphic commands can be used in VB format: Line (x, y)-(z, t),, BF or PBox x, y, z, t.
The Color-command is now the same as RgbColor in 16 Bit GFA-BASIC. Additionally, a table with the 16 standard colors can be used: Color QBColor(i) or a shortcut QBColor i.
The windows now have an AutoRedraw property so that output is captured (performance decrease) to a second bitmap as well. A redraw of the window is then performed by copying the contents of the bitmap to the screen.

Picture and Font Objects
OLE Object types to create and manipulate fonts and pictures. Since these types are OLE-type compatible, a Font or Picture instance can be assigned to a property of an OCX control or form.

Windows and dialogs
Windows and dialogs are all Forms now and their events are handled the same way as in VB. All standard and common controls are implemented using an OCX object wrapper. In general, all GUI objects are now OCX objects and are manipulated through properties, methods and events. The old GetEvent/Menu() structure is now obsolete.
You can still use third party controls by using the old CONTROL statement. The notification messages are then handled in the window procedure of the parent; an form event sub as well!

Assembler and DisAssembler
GFA-BASIC 32 provides an inline assembler and a disassembler object (DisAsm).

App Object
The App specifies information about the application's title, version information, the path and name of its executable file and Help files, and whether or not a previous instance of the application is running. In addition it provides methods to create shorcuts. It has many properties returning information that are otherwise hard to find.

Screen Object
Returns the current capabilities of the display screen your code is executing on. The Screen object has much more properties than the VB counterpart.

Err Object
Contains information about runtime errors or helps in generating useful errors.
Although the VB compliant On Error Goto structure is supported, the Try/Catch/EndCatch error-handling is prefered.

CommDlg object
An OCX wrapper about the common dialog box functions.

Printer Object
Object that provides full(!) printer support for your application.

COM programming
CreateObject creates and returns a reference to an ActiveX object. After the object reference is assigned to a variable of type Object you can use the object's properties, methods, and events. Other COM functions like _DispId and GUID are included.

Integrated Development Environment