Differences from QB
Since version 0.17, FreeBASIC introduced a -lang command-line option, that is used to change the language compatibility mode. Use the -lang qb option when compiling to select the most QB compatible parser. All differences listed below assume that -lang qb was used.
- FreeBASIC is written for 32-bit operating systems and a 32 bit DOS extender, and cannot utilize code which depends on 16-bit DOS, 16 bit assembly or memory model (segment & offset, XMS/EMS, ...).
- DEF SEG is no longer necessary and will not work - any code which POKEs to video memory this way will no longer function, however, for DOS it can be easily rewritten using DPMI features.
- CALL INTERRUPT no longer functions, as it relies on 16-bit DOS. DOS interrupts can be called in the DOS32 version by using the DPMI library, but they might work slowly because of the 32bit-16bit-32bit mode changes the processor will have to perform.
Changed due to ambiguity
- A scalar variable and an array with the same name and suffix can no longer share the same name.
- SHARED can't be used inside a SUB or FUNCTION as it resulted in shared variables not defined in the main program. A proper DIM SHARED in the main program must be used.
- COMMON declarations do not depend on the order they are made, variables are matched by name and for that reason named COMMON is no longer supported. All COMMON arrays are variable-length arrays in FB.
- If a single line IF has an (unnecessary) colon directly after the THEN, it has to be terminated by an END IF in FB. If that unneeded colon is removed, FB will behave as QB.
- Graphics support was internally redesigned, see GfxLib overview
- CLEAR is no longer used to reset all variables and set the stack. Variables must be reset one by one, and stack size can be changed in the compiler command line. The keyword CLEAR is used to do memory fills in FB.
- String DATA items must be enclosed in quotes in FB, in QB this was optional
- All functions must have been declared, even with a CALL in FreeBASIC. With CALL it was possible to invoke prototype-less functions in QuickBASIC. (to be supported in future with -lang qb)
- In FreeBASIC all arrays must be explicitly declared. (Interpreted QuickBASIC arrays are automatically created with up to 10 indices.)
- Strings use a null (char 0) terminator to be compatible with C libraries and the Windows API, fixed-length strings can't contain chr$(0) chars for now.
- When INKEY[$] reads an extended key (Num Pad, Arrows...) it returns a two character string. In FB the first character is CHR[$](255), while in QB this first char is CHR$(0).
- With fixed length strings FreeBASIC gives the real length as LEN plus one (null-char), even on TYPE fields.
- In FreeBASIC, unused characters of fixed-length strings are set to 0, regardless of what "-lang" compiler option is used. In QB, unused characters are set to 32 (space, or " ", in ASCII).
- When a fixed-length string is declared, but still not initialized, all characters are set to 0, both in FreeBASIC and QB.
- The arrays are stored in row-major order in FB, they were stored in column-major order in QB by default. Row major order: data with the same last index are contiguous. Column-major order: data with the same first index are contiguous. For example, if you have DIM A(1 TO 3, 1 TO 8), in row-major order the elements are stored such that A(3,5) is followed in memory by A(3,6); in column-major order A(3,5) is followed in memory by A(4,5).
- Programs don't stop anymore on runtime errors unless -e or -ex option is used in the command line. Using these options allow the use of QB style error handling (ON ERROR, RESUME...).
- Octal numbers are written &o...