New items added 1/17/88 to 1/23/88: Part 1 - PRINT # DIM (QB 3) limited to 123 arrays. RUN Part 2 - Patching QB 4 - Color table is now complete Updated info on long integers Part 3 - Update sample program #3 for RUN problem mentioned in Part 1. ------------------------------------------------------------------------- This file contains information about bugs, quirks, and general points of interest to programmers working with compiled BASIC. It is divided into three parts: Part 1 - Description of bugs, quirks and errors Part 2 - General points of interest Part 3 - Sample programs If you want to find one of the above quickly, use your text editor to search for the text shown above. i.e., Search for "Part 1 -". This file is maintained by Mark Novisoff of MicroHelp, Inc. Much of the information was contributed by members of MicroHelp's BASIC Users Group. If you have additional information that should be added, please send it to: Mark Novisoff MicroHelp, Inc. 2220 Carlyle Drive Marietta GA 30062 (404) 973-9272 Compuserve ID 73047,3706 in MSSYS (Microsoft Systems Forum) Part 1 - Description of bugs, quirks and errors Command/Error Compilers Description -------------- --------------- -------------------------------------------- $INCLUDE QB 4 If you have a DEFINT statement in an include file and you wish to use it within subprograms/ functions in a module, you must $INCLUDE it within each sub/function structure. If you simply include it in the mainline code, the DEFINT statement is not recognized. However, if you have a statement DEFINT in your mainline code (as opposed to $INCLUDE), it will work ok. CALL (asm) QB 4 Effective with QB 4, assembly language subroutines must preserve the SI and DI registers and make sure the direction flag is cleared before returning to BASIC. CALL INIT QB 2-3 Do not name a precompiled subprogram "INIT". If you do, the compiler will go into never- never land when your user library is loaded. CALL vs GOSUB All If you have many calls to the same asm routine or subprogram, you'll use less memory if you set variables and GOSUB to a routine that performs the CALL instead of having the CALL "in line". CALL is much faster using variables than using "literals". CALLS QB 4 When CALLS (note the "S") is used and you compile with "/D" (debug), the segment of of a string element descriptor does not get passed on the stack. In other words, if you have an assembly language subroutine that uses CALLS, you should not compile with "/d". CHAIN QB 4 Unreliable when using DOS 2.x. CIRCLE QB 4 The start and end angles must be LESS than 2*pi. Previously they could be less than or equal to. CLEAR,,Size QB 3,4 If you receive an out of stack space message. The stack size is not reset between CHAIN'ing but if you CHAIN back to your original program, be sure to skip the CLEAR instruction. COMMON and QB 2-4 All statements that use COMMON or variations COMMON SHARED thereon with CHAIN must use parameter lists that match exactly. Best done with $INCLUDE. COMMON with TYPE QB 4 The TYPE statement must appear before the COMMON statement and must appear in all programs that use it. The COMMON statement must contain "AS". See sample program #1 at the end of this file. Compile to EXE QB 4 QB issues an unusual LINK command in the form of: LINK Prog+YourLib.Lib; This causes LINK to bring the entire library into your program! The solution is to exit QB, and run BC and LINK yourself. CONST QB 4 Must be included in all program modules that use the constant. Place in the file at the top, rather than inside SUB's. DATA QB 4 When a DATA statement is encountered inside a SUB...END SUB structure, QB moves it into the "mainline" portion of the code when you are in the environment. DEFINT QB 4 See $INCLUDE. DEF FN All Functions are local to the module in which the DEF FN appears. Use QB 4's FUNCTION..END FUNCTION for global functions. DIM QB 3 See sample program #4. QB3 apparently has a limit of 123 dynamic arrays. DIM QB 4 Static numeric arrays are stored on the "heap" when you are inside the QB 4 environment. BC programs store them in the default DS. DIM (TYPE) QB 4 See sample program #1 for dimensioning arrays of TYPE'd variables. Division All Using integer division "\" when an integer result is desired is much faster than normal division "/". DRAW QB 2-4 Does not respect the boundaries designated by WINDOW. FILES QB 3 There is a bug in the QB3-8087 compiler that causes FILES not to work correctly. FRE(-1) QB 4 If a Quick Library is loaded, this value may return incorrectly. QB 4 seems to forget that the library is loaded and thinks that the space is available. But, QB 4 won't let you use the space for dynamic arrays. FRE("") QB 4 Using BRUN gives approximately 4K more than BCOM. FUNCTION QB 4 Provides global functions for all modules in a program. All that is needed is a DECLARE statement in any module that needs to use the function. In addition, this type of function can be recursive. See DEF FN. FUNCTION QB 4 Cannot be used in $INCLUDE files. HEX$ QB 4 Be careful when using with non-integer values. For example, the output from the two lines shown is "FFFF8002". E&=&H8002 PRINT HEX$(E&) IF..THEN..ELSE QB 3 More than two nestings for ELSE on a single line will not compiler properly. LINE INPUT QB 4 Don't attempt to LINE INPUT directly to a typed variable (using TYPE...END TYPE) that has a period in the name. Rather, LINE INPUT to a temporary variable and then assign it to the TYPE'd variable. LINK All Use the /EXEPACK switch to condense the file. Can be used on any program except programs that are CHAIN'ed to using all compilers except QB 4. All QB 4 programs can use this switch. Syntax: LINK /EXE Progname (etc.) LINK QB 4 When building a Quick Library, be sure to specify BQLB40 in the library field. Example: LINK /QU ObjMods,Lib,,BQLB40; LOAD QB 4 If you receive an "out of memory" error, try breaking your program into logical pieces (using subprograms). Then use COMMON SHARED for all variables that you need in the entire program. The exact same COMMON SHARED declaration must appear in all the modules in the program that need access to the variables. LOAD QB 4 If you download a QB 4 program in "fast load" format, many modem transfer protocols pad the file out using a number of CHR$(0)'s. This will cause QB 4 to crash when you attempt to load the program. Use DEBUG to view the file, then write the program to disk after changing the CX register to shorten the length of the file so that the trailing CHR$(0)'s are not included. The other solution is to download this type of file using an ARC program that restores the original length of the file. ON ERROR QB 4 If you have "ON ERROR GOTO 0" as the first statement in a program, and an error occurs (or is forced using ERROR nn), your system will crash. ON ERROR QB 2-4 Error handler routines must be located outside SUB...END SUB structures. You can RESUME to a line number/label that is outside SUB...END SUB structures (using /E) or to code inside the sub using plain RESUME or RESUME NEXT (/X). Much better is to $INCLUDE subroutines that perform error trapping instead of having them in subprograms. This allows the use of RESUME line number/ label and avoids the /X. OPEN All With Novell NetWare, using OPEN on a file that does not exist does not always create the file. Novell has acknowledged the problem but no solution is available as of 12/19/87. Overflow All BASIC uses integer types for all calculations and processes the right side of the equal sign before the left side. To force BASIC to use a different numeric type, place a type identifier on the right of the equal sign. Example: A=Peek(2)+256!*Peek(3) PRINT # QB 4 In order to print a blank line using QB 4, use the syntax: PRINT #, Note the absence of the null string after the comma. We've had an unconfirmed report that if the print buffer is filled, using the null string causes characters to be dropped. PRINT USING QB 4 With previous compilers, you could place TAB statements, variable names, or most anything else between PRINT and USING. With QB 4, nothing should come between PRINT and USING. RESUME All If you always use RESUME or RESUME