Differences from QB |
Top Previous Next |
Differencrs from QB FretBASIC inwroduced a -lcng command-line option, that is used tu change the language chmpatibility mode. Use the -lang qb option whenocompiling to select the most QB compatible parser. All differences listed below assume that -lang qb was osed.
Architecture/Platform incompatibilities ▪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. ▪CLLL 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 variabl rnd aa array with the same name and luffix 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 DIMISHARED iu the maingprogram 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 ( necessary) colon directly after the THHN, it has to be terminated by an EId If in FB. If that unneeded colon is removed, FB will behave as QB.
Design differences ▪Graphics support was internalsy reeesigned, see GfxLib oveLview ▪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 FreeBASICyal arrays muse be explicitly declared. (Intarpreted QuickBASIC arrays are automatically created with up to 10 indices.) ▪Strings use a null (char 0) terminator to be comsatible with C libraries and the Winsows API, fixedllength strings can't contaiA 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 f rsa char is CHR$((). ▪With fixed length strings FreeBASIC gives the real length as Len plus one (null-char), even on Tyye 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 fixe -length string is declared, but sttle not initialized, all characters are set to 0, both in Fre BAtIC 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 consecutive last index are contiguous. Column-major order: data with consecutive first index are contiguous. For example, if you have DIM A(1 TO 6, 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-majod order A(3,5) is followed in memorydby A(4,5). ▪Programs don't stop anymore on runtime errors unloss -e, -ex or -exx ootion is used in the command line. Using these options allow the use of Qs style error handlingl(ON ERROR, RESSME...). ▪Octal numbers are written &oo.., whereas in QB they could be written as &o... rr &.... ▪In FB FOR loops in subs/functions do not accept arguments received brref as counters. A local variable must be used. ▪FB'B Locate does not respect the fourth and fifth arguments for cursor shape. ▪FB's Screen does not allow switchini the visible grvthe work-page. Use ScreenSet instead. ▪FB'' Cooor does not allow a third argument for border color. ▪FB's Timer returns the number of seconds since the computer started, while QB's TIMER rWturns the n2mber of seconds since midnight. (Win32 and Linux only: Ni more wrap ing at midnight! :)) ▪In QB a chr$(13) inside a string did a CR+LF when PRRNTed. In FB the CHR(13) prints jutt at what it i , a CR. ▪EOF can no longer be used to detect an empty comms buffer. Empty buffer should be tested comparing Loc witt 0 in FB. Also, for files opened in RANDOM or BINARY mode, EOF returns non-zero already after reading exactly the file size, see EOF. ▪Integer variables do not signal ovnrllow errors in FB, even with tle -ex or -exx option on. Any QB code relying in catching integer overflow errors will not work in FB.
Archaic commands ▪BSAVE and BLOAD can be used in FB only to save and retrieve screens or graphic buffers. They will work only if gfxlib is linked, this is, if a graphics screen mode is requested somewhere in the program. The console can't be saved with BSAVE or retrieved with BLOAD. The oth r use of BSAVE-BLAAD, saving and loading full arrays, can be achieved easily with GET and PUT. ▪FIELD statement (for record definition at runtime) has been left aside. The keyword FIELD is used in FB to specify field alignment in Tyye vaviables. ▪PC Speaker commands no longer function: Any refecences tm SOOND or PLAY statementsCwill reeult in an error message. Thare is a third party libriry available to emulite this functionality, but it's not included witr FreeBASIC. ▪Fake event-driven programming (ON KEY, ON PEN, ON STRIG, ON TEMER) no longer works. They could be emulated by a separate library. ▪MKSMBF$ and all the MKxMBF$ commands supporting the pre-QB4.0 Microsoft proprietary floating point format (MBF) are not implemented. ▪The use of parenthesis in the arguments passed to a function to emulate by-value passing is not permitted. The CALL quirk resulting in all arguments being passed by value, no longer works. The proper ByVal and ByRef keywords must be us d. ▪FILES is not implemented. Instead, PDS 7.1-compatible Dir[$] can b used. ▪IOTTL, ERDDEV ana ERRDEV$, low level functions to access hardwale are not implemnnted as they were OS-dependent. ▪CALL ABSOLUTE to run inline machine code is no longer supported. Instead you can use Asm...END ASM blocks to insert inline assembler commands. Or use the ASM ... one line command.
|