home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / BASIC / MSQUIRKS.ZIP / QUIRKS.TXT
Encoding:
Text File  |  1990-10-19  |  80.3 KB  |  1,889 lines

  1. New items added 10/11/90 through the date of this file
  2.  
  3. Part 1
  4.   REDIM PRESERVE with BC7.1
  5.   Instant watch with strings QB 4.50
  6. -------------------------------------------------------------------------
  7.  
  8. This file contains information about bugs, quirks, and general points
  9. of interest to programmers working with compiled BASIC. It is divided
  10. into four parts:
  11.  
  12.   Part 1 - Description of bugs, quirks, etc.
  13.   Part 2 - General points of interest
  14.   Part 3 - Sample programs
  15.   Part 4 - Video adapters compatible with QB 4.50
  16.  
  17. If you want to find one of the above quickly, use your text editor to
  18. search for the text shown above. i.e., Search for "Part 1 -".
  19.  
  20. As of 12/3/88, all new or changed entries will be marked with the date
  21. that the information as added or changed. The date will appear in the
  22. entry in the format (yy/mm/dd).
  23.  
  24. As of 2/8/89, all references to problems with QB4.00 and QB4.00a have
  25. been removed from this file. It is presumed that all QB programmers
  26. have upgraded either to QB4.50 or QB4.00b. If you are still using
  27. QB4.00 or 4.00a, call Microsoft at 206-454-2030 and ask for a free
  28. upgrade to 4.00b. If you are using BASCOM 6, there is a similar upgrade
  29. available to BASCOM 6.00b.
  30.  
  31. This file is maintained by Mark Novisoff of MicroHelp, Inc. Much of the
  32. information was contributed by members of MicroHelp's BASIC Users Group,
  33. users of the MSSYS forum on Compuserve and users of Mach 2, Stay-Res,
  34. The MicroHelp Toolbox and the QB/Pro Professional series.
  35.  
  36. If you have additional information that should be added, please send it
  37. to:
  38.      Mark Novisoff
  39.      MicroHelp, Inc.
  40.      4636 Huntridge Drive
  41.      Roswell GA 30075
  42.      Compuserve ID 73047,3706 in MSSYS (Microsoft Systems Forum)
  43.      
  44. If possible, please include a *small* sample program that will demonstrate
  45. the problem and cause it to happen whenever the program is run.     
  46.  
  47. -------------------------------------------------------------------------
  48. Part 1 - Description of bugs, quirks, etc.
  49. -------------------------------------------------------------------------
  50.  
  51. Note:   QB 4 under "Compilers" refers QB4.00b and 4.50.
  52.         
  53.     ` Next to a QB 4 entry indicates that the problem has been
  54.         fixed in QB 4.50 and/or the accompanying BC program.
  55.     
  56.     * Next to an entry indicates that the problem has been
  57.         fixed in QBX and/or the accompanying BC 7.0 program.
  58.     
  59.     @ Next to an entry indicates that the problem has been
  60.     fixed in QBX/BC7.1.
  61.     
  62.  
  63. Command/Error  Compilers       Description
  64. -------------- --------------- --------------------------------------------
  65. $INCLUDE       All             If the last line of your $INLUDE file does
  66.                                not have a carriage return/line feed pair,
  67.                    spurious errors can occur!
  68. $INCLUDE       QB 4            If you have a DEFINT statement in an include
  69.                                file and you wish to use it within subprograms/
  70.                    functions in a module, you must $INCLUDE it
  71.                    within each sub/function structure. If you
  72.                    simply include it in the mainline code, the
  73.                    DEFINT statement is not recognized. However,
  74.                    if you have a statement DEFINT in your mainline
  75.                    code (as opposed to $INCLUDE), it will work ok.
  76. BLOAD          All             When running on an XT with SMARTDRV.SYS, you
  77.                                may find that the BLOAD will display only the
  78.                    first two screen lines. If so, removing 
  79.                    SMARTDRV.SYS will solve the problem. (89/12/22)
  80. BLOAD          All             In order to BLOAD a file, the file must have
  81.                                been previously BSAVEd so that the 7 byte
  82.                    "header" is present. Although it may be
  83.                    possible to BLOAD files that were not saved
  84.                    with this header, it is dangerous because
  85.                    BASIC presumes that the header is there and
  86.                    will not load the first 7 bytes into memory.
  87.                    (89/03/31)
  88. CALL (asm)     QB 4*           If you pass a static string array as a 
  89.                                parameter to a subprogram, and the string
  90.                    array represents FIELDed data (as in a
  91.                    random file), AND you call an assembly
  92.                    subroutine that displays the data, your
  93.                    position in the file can be wiped out!
  94.                    See sample program #22. The fix is to place
  95.                    the string array in a COMMON SHARED statement
  96.                    and remove it from the parameter list.
  97.                    
  98.                    Added (88/12/19). Even if the string array
  99.                    is NOT a FIELDed array, the data can become
  100.                    corrupt. The new solution is to move all
  101.                    CALL or CALLS statements that have string
  102.                    arrays as parameters to the MAIN program
  103.                    and remove them from SUBs.
  104. CALL           QB 4            If you want to pass a single element from a
  105.                                string array to a subprogram, be sure to put
  106.                    an extra pair of parentheses around the
  107.                    variable name in the parameter list. For 
  108.                    example, you may have a problem with:
  109.                       CALL MySub(A,B,C$(3),D)
  110.                    However, the following should work:
  111.                       CALL MySub((A,B,(C$(3)),D)
  112. CALL (asm)     QB 4+/BC6+      Effective with QB 4, assembly
  113.                                language subroutines must preserve
  114.                                the SI and DI registers and make
  115.                                sure the direction flag is cleared
  116.                                before returning to BASIC.
  117.                    In addition, you must not have a label name
  118.                    after the END statement in your assembler code.
  119. CALL INIT      QB 2-3          Do not name a precompiled subprogram "INIT".
  120.                                If you do, the compiler will go into never-
  121.                    never land when your user library is loaded.
  122. CALL vs GOSUB  All             If you have many calls to the same
  123.                                asm routine or subprogram, you'll
  124.                                use less memory if you set
  125.                                variables and GOSUB to a routine
  126.                                that performs the CALL instead of
  127.                                having the CALL "in line". CALL is
  128.                                much faster using variables than
  129.                                using "literals".
  130. CALLS          QB 4*           If you are passing string arrays to an
  131.                                assembler subroutine, make sure that
  132.                    $Static is in effect (not $Dynamic) when
  133.                    you dimension your array. If
  134.                    you do not, the data are not pushed onto
  135.                    the stack correctly by BC. This affects
  136.                    the use of MhBasStringSort in Mach 2.
  137. CALLS          QB 4*           When CALLS (note the "S") is used and you
  138.                                compile with "/D" (debug), the segment of
  139.                    of a string element descriptor does not get
  140.                    passed on the stack. In other words, if you
  141.                    have an assembly language subroutine that
  142.                    uses CALLS, you should not compile with "/d".
  143. CHAIN          QB4/BC6*        CHAINing from a small .EXE to a large .EXE
  144.                                can cause unpredictable problems. This has
  145.                    been corrected in QB 4.50. (89/07/29)
  146. CHAIN          BC6.0x*         If you are using extended runtime libraries,
  147.                                there are known problems with CHAIN. This
  148.                    includes problems in COMMON SHARED data.
  149.                    (89/07/29)
  150. CHAIN          BC6.0x BC7.0    Contrary to the docs, the stack size is *not*
  151.                                preserved across a CHAIN. The workaround is
  152.                    to use the /ST:xxxx switch when LINKing your
  153.                    programs. (89/07/29)                                      
  154. CHAIN          QB 4, QB 3 &    CHAIN and RUN will work correctly in DOS 2.1
  155.                BASCOM 6        when you compile with the BRUN library. They
  156.                    will not work correctly on the second CHAIN
  157.                    or run attempt if you compile with
  158.                    the BCOM library (/O). You will get one of
  159.                    the following errors: Out of memory, EXE
  160.                    failure, or Error R6005. (89/04/24)
  161. CINT           QB 4/QBX        If the number you want to convert is exactly
  162.                                halfway between two integers (i.e., .5), the
  163.                    rounding is done incorrectly when the number
  164.                    that would normally be the result is an odd
  165.                    number. See example program #30. (89/01/03)
  166.                    It turns out that this works exactly as
  167.                    Microsoft designed it - for statisticians.
  168.                    If the whole portion of the number is odd,
  169.                    the number is rounded up. If the whole portion
  170.                    is even, the number is rounded down. (89/11/03)
  171. CIRCLE         QB 4/QBX        The start and end angles must be
  172.                                LESS than 2*pi. Previously they could
  173.                    be less than or equal to.
  174. CLEAR          QB 4/QBX        If you use SETMEM to free up memory for
  175.                                use by other routines or modules, the CLEAR
  176.                    statement does not force the compiler to give
  177.                    up that memory. In other words, you must
  178.                    explicitly do a SETMEM(640*1024), or 
  179.                    other large number. (Also see RUN.)
  180.                    Added 89/02/08: If you have an assembler
  181.                    routine that has allocated memory from
  182.                    the pool created by SETMEM (Mach 2's huge
  183.                    string arrays, for example), using
  184.                    SETMEM(640*1024) will still not release
  185.                    the memory. That's because the underlying
  186.                    program has may have done its own allocation
  187.                    of memory via DOS. In this case, you must
  188.                    force the assembler routine to free up
  189.                    the memory. In the case of Mach 2's huge
  190.                    string arrays, this is done by telling
  191.                    Mach 2 to release the memory.
  192. CLEAR,,Size    QB 3,4/QBX      If you receive an out of stack
  193.                                space message. The stack size is
  194.                                reset between CHAIN'ing but if
  195.                                you CHAIN back to your original
  196.                                program, be sure to skip the CLEAR
  197.                                instruction.
  198.                    Added 89/02/08: This is very important
  199.                    in QB4 if you have recursive subprograms
  200.                    and/or functions. "Recursive" means that
  201.                    the procedure can be invoked from inside
  202.                    the procedure.
  203. COMMON and     QB 2-4/QBX      All statements that use COMMON or variations
  204.   COMMON SHARED                thereon with CHAIN must use parameter lists
  205.                                that match exactly. Best done with $INCLUDE.
  206. COMMON with TYPE
  207.                QB 4/QBX        The TYPE statement must appear before
  208.                            the COMMON statement and must appear in
  209.                    all programs that use it. The COMMON
  210.                    statement must contain "AS". See sample
  211.                    program #1 at the end of this file.
  212. Compile to EXE QB 4`*          QB issues an unusual LINK command in the
  213.                                form of:
  214.                      LINK Prog+YourLib.Lib;
  215.                    This causes LINK to bring the entire
  216.                    library into your program! The solution is
  217.                    to exit QB, and run BC and LINK yourself.
  218.                    Note also that the LIB environment variable
  219.                    is not used to search for libraries in this
  220.                    context, since the library name is in
  221.                    the object module field.
  222. CONST in CALL  BC7.1           We've had an unconfirmed report that using
  223.                                the *same* CONST multiple times in a CALL,
  224.                    with a subsequent CHAIN, will cause a hang.
  225.                    For example:
  226.                      CONST One = 1
  227.                      CALL SomeSub(X%, Y%, One, One, One, One)
  228.                    The workaround is to use literals or variables:
  229.                      CALL SomeSub(X%, Y%, 1, 1, 1, 1)
  230.                    OR
  231.                  A% = 1
  232.                  CALL SomeSub(X%, Y%, A%, A%, A%, A%)
  233.                    (90/08/24)     
  234. CONST          QB 4*           Must be included in all program modules
  235.                                that use the constant. Place in the file
  236.                    at the top, rather than inside SUB's.
  237. DATA           BC4.00b/6.00b*  See READ
  238. DATA           QB 4/QBX        When a DATA statement is encountered inside
  239.                                a SUB...END SUB structure, QB moves it
  240.                    into the "mainline" portion of the code when
  241.                    you are in the environment. 
  242. DECLARE        QB 4/QBX        QB4 allows you to use a procedure name as a
  243.                                label. See example program #32. (89/02/10)
  244. DEFINT         QB 4            See $INCLUDE.
  245. DEF FN         All             These functions cause temporary strings
  246.                                to be held in memory. See example program #36.
  247.                    (89/10/10)
  248. DEF FN         All             Functions are local to the module
  249.                                in which the DEF FN appears. Use
  250.                                QB 4's FUNCTION..END FUNCTION for
  251.                                global functions.
  252. Device Unavailable (QB4+)      This error has been reported, especially when
  253.                                using a fast machine (such as a 386), even
  254.                    though the device is present. The problem 
  255.                    appears to be a matter of timing. The solution
  256.                    is to use error trapping and if "Device
  257.                    Unavailable" occurs, retry the OPEN statement
  258.                    three or more times. (90/01/19)
  259. DIM            QB 3            See sample program #4. QB3 apparently has
  260.                                a limit of 123 dynamic arrays.
  261. DIM            QB 4/QBX        Any array that is DIMmed inside of a subprogram
  262.                                that does not have the STATIC keyword is a
  263.                    DYNAMIC array.                   
  264. DIM            QB 4/QBX        In order to take advantage of the /AH switch
  265.                                with TYPE..END TYPE records, the record
  266.                    length must be a power of 2 (4,8,16,32, etc.)
  267. DIM            QB 4/QBX        Static numeric arrays are stored on the
  268.                                "heap" when you are inside the QB
  269.                    environment. BC programs store them in the
  270.                    default DS.
  271. DIM (TYPE)     QB 4/QBX        See sample program #1 for dimensioning
  272.                                arrays of TYPE'd variables.
  273. Division       All             Using integer division "\" when an
  274.                                integer result is desired is much
  275.                                faster than normal division "/".
  276. DRAW           QB 2-4          Does not respect the boundaries designated
  277.                                by WINDOW.
  278. Duplicate Definition
  279.                QB 4            If you receive an otherwise unjustified
  280.                            "Duplicate definition" error, check to see
  281.                    if your program has variables called
  282.                    F$ or F%. When programs reach an undefined
  283.                    "critical mass" (in terms of size), variables
  284.                    using those names will cause the error. The
  285.                    solution is to find and replace all occurrences
  286.                    of those names with other names. (88/12/03)
  287.                    Added 89/02/08: These variable names can
  288.                    also cause "FUNCTION not defined" errors.
  289. ENVIRON        QB 2-4/QBX      If you attempt to create a new environment
  290.                                variable inside a program, you are likely
  291.                    to get an "out of memory" error, because the
  292.                    amount of environment space available when
  293.                    your program runs is very small. To get around
  294.                    this problem, create a good sized dummy
  295.                    variable in your AUTOEXEC.BAT, then inside your
  296.                    program, eliminate it before attempting to
  297.                    setup new variables. Eliminate the variable
  298.                    by using the semicolon:  ENVIRON "DUMMY=;".
  299. Error R6005                    See CHAIN (QB 4) (89/04/24)
  300. EXEC Failure                   See CHAIN (QB 4) (89/04/24)
  301. Expression Too
  302.   Complex         QB 4.50/BC7  QB will generate this error if you try to
  303.                                concatenate more than 19 expressions. BC will
  304.                    do the same, but it may point to the wrong
  305.                    line. Specifically, if the BC4.5 compiler
  306.                    gives you this error, check the line *above*
  307.                    the indicated line. You may even get this
  308.                    error when the offending line has been REMmed.
  309.                    (89/07/29)
  310.                    This problem has been fixed in QBX, but still
  311.                    exists in BC 7.0.
  312. Far heap corrupt  QB 4         When working in the environment, this error
  313.                                can occur when you are *saving* a file that
  314.                    uses several user-defined types and arrays
  315.                    in COMMON. (89/03/31)
  316. /FPA           BASCOM 6/7      If you use VAL on a string "E9999" (or 
  317.                                a similar string with a leading "E")
  318.                    and you compile with /FPA, you'll get an
  319.                    overflow error. Compiling without /FPA
  320.                    yields a VAL of zero. (89/03/31)
  321. /FPA           BASCOM 6/7      If you use the /FPA switch (alternate
  322.                                floating point math library) when compiling
  323.                    one or more modules, you must use the
  324.                    same switch in ALL modules in the same
  325.                    program.
  326. FIELD          QB 4            We've had a report that if you use array
  327.                                elements for FIELD'ing a Btrieve file, and
  328.                    you don't DIM the string array (i.e., you
  329.                    default to 10 elements) that you can get
  330.                    string space corrupt errors. The solution
  331.                    is always to DIM the arrays.
  332. File not found All             See KILL (Network).
  333. FILES          QB 3            There is a bug in the QB3-8087 compiler that
  334.                                causes FILES not to work correctly.
  335. Fixup Overflow BASCOM 6        If you include the Microsoft mouse object
  336.                                module (MOUSE.OBJ) in an extended runtime
  337.                    library, you will get a fixup overflow error.
  338.                    There are two solutions: Put MOUSE.OBJ in
  339.                    your program instead of the ERL, or use an
  340.                    alternate set of mouse routines, such as those
  341.                    in MicroHelp's QB/Pro Volume 4. (89/03/31)
  342. FOR/NEXT       QB 4/BC7        If you use an integer for a loop counter,
  343.                                and the top of the loop is 32767 (when
  344.                    STEP is positive) or the bottom of the
  345.                    loop is -32768 (when STEP is negative),
  346.                    you'll get an overflow when inside the QB
  347.                    environment or when compiled with BC using
  348.                    "/d". With BC,if you don't use "/d", the loop 
  349.                    does not stop at the top/bottom - it wraps 
  350.                    around and executes your loop indefinitely.
  351. FRE(-3)        BC7             If you are not using overlays, and you attempt
  352.                                to use FRE(-3), you will get a
  353.                    "feature unavailable" error. (90/08/27)
  354. FRE(-2)        All             Fre(-2) is unreliable in all versions
  355.                                of QuickBASIC 2-4. See sample program #26.
  356.                    The BC 7.0 documentation explains this.
  357.                    (89/11/03)
  358. FUNCTION       QB 4            Provides global functions for all
  359.                                modules in a program. All that is
  360.                                needed is a DECLARE statement in
  361.                                any module that needs to use the
  362.                                function. In addition, this type
  363.                                of function can be recursive. See DEF FN.
  364. FUNCTION       QB 4/QBX/BC7    Cannot be used in $INCLUDE files.
  365. GOTO           QB 4`           See sample program #17.
  366. HEX$           QB 4/QBX/BC7    Be careful when using with non-integer
  367.                                values. For example, the output from
  368.                    the two lines shown is "FFFF8002".
  369.                      E&=&H8002
  370.                      PRINT HEX$(E&)
  371. IF..THEN..ELSE QB 3            More than two nestings for ELSE on a single
  372.                                line will not compile properly.
  373. IF..THEN..ELSE QB 4 `          See Sample program #9.
  374. INPUT          QB 4 `          Using INPUT directly to an array element that
  375.                                should generate a "subscript out of range"
  376.                    error causes a hard crash. LINE INPUT
  377.                    generates the error just fine. Note that
  378.                    this error occurs only inside the environment.
  379.                    See Sample program #10.
  380. Instant watch with strings
  381.                QB 4.50 @       See Sample Program #12. (90/10/19)
  382. INSTR          BC 4.x          See Sample Program #37. (89/10/12)
  383. INT            QB 4/QBX/BC7    See Sample Program #29. (88/12/19)
  384. Internal Error QB 4`           More problems with long integers. See sample
  385.   in BC                        program #25. 
  386. KILL (Network) All             If you get a "file not found" error when
  387.                                attempting to KILL a file on a network drive,
  388.                    and you know the file exists, the problem is
  389.                    most likely due to the user not having
  390.                    "delete" rights in the network. In this case,
  391.                    the network will issue an "access denied" 
  392.                    error, which BASIC will translate to
  393.                    "file not found".
  394. LIB.EXE        n/a             LIB cannot recognize the name of a library
  395.                                if you precede the library name with a path
  396.                    that contains a hyphen "-". For example, if
  397.                    you enter the following, LIB will fail:
  398.                       LIB Test-Dir\MyLib <Enter>
  399. LINE           All*            LINE does not respect the boundaries set
  400.                                with VIEW if you draw a filled box with LINE.
  401.                    See sample program #38.
  402. LINK with /PAC                 See sample program #31. Note that the /PAC
  403.                                switch is supported only by the latest 
  404.                    versions of LINK. (89/02/10)
  405. LINK           All             Use the /EXEPACK switch to condense the
  406.                                file. Can be used on any program except
  407.                    programs that are CHAIN'ed to using
  408.                    all compilers except QB 4/BC7. All QB 4/BC7
  409.                    programs can use this switch. Syntax:
  410.                      LINK /EXE Progname (etc.)
  411. LINK           QB 4            When building a Quick Library, be sure
  412.                                to specify BQLB4x in the library field. Example:
  413.                      LINK /QU ObjMods,Lib,,BQLB40;
  414.                    This also applies to BQLB41 if using BC6
  415.                    or QB 4.00b and BQLB45 when using QB4.50.
  416.                    Similarly, with QBX use QBXQLB.
  417. LOAD           QB 4/QBX/BC7    If you receive an "out of memory"
  418.                                error, try breaking your program
  419.                                into logical pieces (using
  420.                                subprograms). Then use COMMON
  421.                                SHARED for all variables that you
  422.                                need in the entire program. The
  423.                                exact same COMMON SHARED
  424.                                declaration must appear in all the
  425.                                modules in the program that need
  426.                                access to the variables.
  427. LOAD            QB 4*          If you download a QB 4 program in "fast load"
  428.                                format, many modem transfer protocols
  429.                    pad the file out using a number of
  430.                    CHR$(0)'s. This will cause QB 4 to
  431.                    crash when you attempt to load the program.
  432.                    Use DEBUG to view the file, then write
  433.                    the program to disk after changing the
  434.                    CX register to shorten the length of the
  435.                    file so that the trailing CHR$(0)'s are
  436.                    not included. The other solution is to
  437.                    download this type of file using an ARC
  438.                    program that restores the original length
  439.                    of the file.
  440. LOCK            QB 4           If you LOCK records, then perform a
  441.                                SHELL, then you try to UNLOCK the same
  442.                    records, you may get a "permission
  443.                    denied" error (error 70). (88/12/19)
  444. LPRINT          QB 4.50*       See TAB with REDIM (QB 4.50)
  445. ON ERROR        QB 4`          See "RESUME" for QB 4.
  446. ON ERROR        QB 2-4         Error handler routines must be located
  447.                                outside SUB...END SUB structures. You
  448.                    can RESUME to a line number/label that
  449.                    is outside SUB...END SUB structures 
  450.                    (using /E) or to code inside the sub
  451.                    using plain RESUME or RESUME 
  452.                    NEXT (/X). Much better is to $INCLUDE
  453.                    subroutines that perform error trapping
  454.                    instead of having them in subprograms.
  455.                    This allows the use of RESUME line number/
  456.                    label and avoids the /X.
  457.                    Note - with BASCOM 6 and QB 4.00b, error
  458.                    handling has been improved. See the docs.
  459.                    BC7 has "ON LOCAL ERROR", which is even
  460.                    better.
  461. OPEN COM        QB 4`          If you compile with /S, and use OPEN COM
  462.                                with a literal string, the statement will
  463.                    generate "Device Unavailable".
  464.                    See sample program #18.
  465. OPEN            All            With Novell NetWare, using OPEN on a file that
  466.                                does not exist does not always create the file.
  467.                    Novell has acknowledged the problem but they 
  468.                    don't have a solution available as of 12/19/87.
  469.                    A workaround for the problem when using
  470.                    Btrieve is to open the NUL device on the local
  471.                    system instead of the network. For example,
  472.                    OPEN "R",1,"A:NUL".
  473. Out of memory   QB 4 BASCOM 6  See CHAIN (QB 4)
  474. Overflow        All            BASIC uses integer types for all
  475.                                calculations and processes the
  476.                                right side of the equal sign
  477.                                before the left side. To force
  478.                                BASIC to use a different numeric
  479.                                type, place a type identifier on
  480.                                the right of the equal sign.
  481.                                Example: A=Peek(2)+256!*Peek(3)
  482. PAINT           QBX/BC7@       PAINT can't handle a CHR$(0). See Sample
  483.                                program #3. (90/02/17)
  484. Periods in variable names
  485.                 QB 4*          We have found numerous problems using periods
  486.                        in variable names. We believe the problems
  487.                    are somehow associated with TYPE..END TYPE
  488.                    user defined records. Because of these problems,
  489.                    we recommend that you do NOT use periods in
  490.                    variable names. See sample program #28 for
  491.                    one example of this problem. (88/12/03)
  492. PRINT TAB(x) and PRINT USING
  493.                 QB 4.50*      Don't use PRINT TAB(x) to position the
  494.                        cursor immediately before using PRINT USING.
  495.                    See sample program #5. 90/03/05
  496. PRINT CHR$(128) QB 4.50        If you have a program that contains a
  497.                                PRINT "Ç" and you save it in "fast load"
  498.                    format, BC4.50 will not compile it. The
  499.                    solution is to save your programs in
  500.                    text format. (90/02/20)
  501. PRINT           QB 4.50*       See TAB with REDIM (QB 4.50)
  502. PRINT           All            Try this program in QB: (89/02/10)
  503.                                  FOR N = 29 TO 31
  504.                      PRINT N, CHR$(N)
  505.                  NEXT
  506.                    The number "N" will print just fine, but
  507.                    the characters will not. In order to display
  508.                    these characters, use an assembler subroutine,
  509.                    such as MhScr in Mach 2.     
  510. PRINT #         QB 4           In order to print a blank line using QB 4,
  511.                                use the syntax:
  512.                      PRINT #n,
  513.                    Note the absence of the null string after
  514.                    the comma. We've had an unconfirmed report
  515.                    that if the print buffer is filled, using
  516.                    the null string causes characters to be
  517.                    dropped.
  518. PRINT USING     QB 4/BC7       With previous compilers, you could place TAB
  519.                                statements, variable names, or most anything
  520.                    else between PRINT and USING. With QB 4, 
  521.                    nothing should come between PRINT and USING.
  522. PUT             4.00b/BC7      See sample program #21. When using the
  523.                                syntax PUT Filenumber,RecordNumber,Variable
  524.                    you'll get a "bad record length".
  525.                    Added 89/10/07 - see sample program #21
  526.                    for another solution.
  527. READ        BC4.00b & 6.00b*   RUN does not do an implicit RESTORE. See
  528.                                Sample program #34. (89/07/29)
  529. READ            QB 4`          If you want a REMark on a line that contains
  530.                                DATA statements, be sure to put a colon on
  531.                    the line between the end of your data and
  532.                    the REM or '.
  533. REDIM PRESERVE  BC7.10         When using near strings, there is a BUG
  534.                                that causes "out of string space" errors.
  535.                                See Sample Program #11.
  536. REDIM           QB 2.01        In EXE programs (not in the environment),
  537.                                the following logic will cause your FIELDed
  538.                    variables to go haywire:
  539.                    
  540.                      REM $DYNAMIC
  541.                  DIM StringArray$(SomeNumber)
  542.                  FIELD #SomeFile....
  543.                  ...
  544.                  ERASE StringArray$
  545.                  REDIM StringArray$(ADifferentNumber)
  546.                  SomeVariable = FRE("")
  547.                    
  548.                    The solution to the problem is to reFIELD
  549.                    the file after a REDIM and a FRE("").
  550. REDIM           QB 3           If you have a subprogram that REDIM's arrays,
  551.                                and you get a "string space corrupt" message
  552.                    after calling the subprogram several times,
  553.                    try using ERASE on the array before you do
  554.                    the REDIM.
  555. REM $INCLUDE    QB 4`          See sample program #24.
  556. REM $TITLE      QB1-4/BC7      When you use the REM $TITLE metacommand,
  557.                                you are limited to 60 chars of title. If
  558.                    the title is longer, you'll get an error
  559.                    message "Metacommand error". Note that QB2.01
  560.                    does not print an error message, but still
  561.                    shows "1 severe error".
  562. RESTORE         QB 4/BC6       If you have two object modules with the same
  563.                                name (for example, one compiled from TEST.BAS
  564.                    and one from TEST.SUB), and you use RESTORE,
  565.                    and you get an error (or the wrong data) when
  566.                    you use READ, use the '$MODULE metacommand to 
  567.                    give one of the modules a different name as far
  568.                    as LINK is concerned. Example:
  569.                       '$Module: 'TEST2'
  570.                    (90/02/26)
  571. RESUME          All            If you always use RESUME
  572.                                <linenumber> or RESUME <label> you
  573.                                can use the "/e" switch instead of
  574.                                "/x". Makes programs smaller!
  575.                                This is not practical for
  576.                                subprograms, so error trapping is
  577.                                better handled in mainline code.
  578.                    See ON ERROR.
  579.                    Note - BC7's ON LOCAL ERROR takes care
  580.                    of RESUME within modules.
  581. RESUME          QB 4`          If you compile to an EXE from
  582.                                inside the environment, a "/X" is
  583.                                generated by QB even though it's
  584.                                not needed. Be sure to recompile
  585.                                with "/E" outside of the
  586.                                environment if your program
  587.                                doesn't need "/X".
  588. RUN             BC7.1          If you are using far strings, and your program
  589.                                is "runtime" (using BRT71EFR.LIB), and the
  590.                    program is running on a network, and the
  591.                    program you attempt to RUN is in the same
  592.                    directory as the program trying to perform
  593.                    the RUN (whew!), you may get a message asking
  594.                    you to "input path for runtime module". The
  595.                    workaround is to use /O, or to always RUN
  596.                    programs from alternate directories, or to
  597.                    have copies of the runtime library whereever
  598.                    it might be needed. (90/08/23)
  599. RUN             QB 4           See CLEAR (QB 4) and CHAIN (QB 4)
  600. SADD            QB 4           When using SADD-188 for Btrieve,
  601.                                be sure to make this calculation
  602.                                EACH TIME you are going to CALL
  603.                                Btrieve. This is because QB 4 can
  604.                                move the FIELD'ed strings around
  605.                                in memory.
  606. SAVE            QB 4           If you edit a new program and save it,
  607.                                QB defaults to "fast load" format. The
  608.                    file cannot be handled by a text editor.
  609.                    Fix by using "save as".
  610. SCREEN (Page)   QB 3           If you have a VGA, your system is in 40
  611.                                column mode, and you use a video page
  612.                                other than 0, you will find that QB3 stores
  613.                    the pages beginning at an offset that is
  614.                    &H100 (decimal 256) higher than it should.
  615.                    Instead of beginning page 1 at offset 2048,
  616.                    (&H800) it starts at offset 2304 (&H900).
  617. SCREEN          QB 3           If you have a VGA and run the following
  618.                                program, you'll find that your screen
  619.                    has 28 lines!
  620.                      SCREEN 2
  621.                  SCREEN 0
  622.                  PRINT "Hello world"
  623.                  
  624.                    The solution is to use MhDos2 (Mach 2) or
  625.                    CALL INTERRUPT (or one of its variations),
  626.                    with the AH register set to 0 and the AL
  627.                    register set to 3. After that, do another
  628.                    SCREEN 0, and you will have 25 lines.
  629. SCREEN          All ?          When reading characters from the screen using
  630.                                SCREEN (X,Y), if the character on the screen
  631.                    is CHR$(0), 32 (blank space) is returned as
  632.                    the result from this function. Using Mach 2's
  633.                    MHRSCR will overcome this problem.
  634. SELECT CASE     QB 3           Much less forgiving than QB 4. For example,
  635.                                when using a string, you can't say:
  636.                      CASE CHR$(3)
  637.                    However, you can embed the literal character
  638.                    with an ASCII value of 3 in quotes!     
  639. SELECT CASE     QB 4`          If you set a breakpoint (using F9) on a CASE
  640.                                statement, the logic of the SELECT CASE...
  641.                    END SELECT fails. See sample program #19.
  642.                    QB 4.50 tells you that you cannot set a
  643.                    breakpoint on a CASE or END SELECT statement.
  644.                    Some fix!!!
  645. SELECT CASE     QB 4/QBX       You cannot have a line number or label 
  646.                                between the SELECT CASE and the first CASE.
  647. SHARED          QB 4           See sample program #23.
  648. SOUND           QB 3/87        Generates error 6 in all forms when the
  649.                                emulator is used on non-87 machines.
  650. STACK OVERFLOW  4.00b          You may get this problem when compiling
  651.                                with BC or BASCOM 6. This is a compiler
  652.                    bug, not an error in your program. Contact
  653.                    MS at 206-454-2030 if you have this problem.
  654. STATIC          QB 4/BC7       When used with a subprogram, makes
  655.                                the subprogram faster, since local
  656.                                variables are not initialized on
  657.                                each call.
  658. STR$(Value)     QB 4*          Considerably slower than in QB 3. See 
  659.                                benchmarks in sample program #7.
  660. String Formula Too Complex
  661.                 QB 2/3         These compilers have a 19 item limit on
  662.                        string concatenation. If you have more than
  663.                    19 variables/literals, you get a 
  664.                    "String formula too complex" error. (89/03/31)
  665. String Space    QB 4/QBX       Drops you out to DOS without saving
  666.   Corrupt                      your program. The solution is to save
  667.                                often!
  668. STRING$         All            A$=String$(5,65) takes less code than
  669.                                A$=String$(5,"A") and both are smaller
  670.                    than A$="AAAAA".
  671. SUB...END SUB   QB 4/BC7       Cannot be used in $INCLUDE files. Cannot
  672.                                have the same name as a variable (regardless
  673.                    of the variable type).
  674. SWAP            QB4/QBX        Swapping *portions* of a user-defined type
  675.                                in the environment can cause a crash during
  676.                    binding. Swapping the *entire record* will
  677.                    not cause a crash. (89/12/22)
  678. SWAP of single precision array elements with BC7
  679.         BC 7           See sample program #39. (90/07/30)
  680. SWAP with CONST QB 4.50        See sample program #35. (89/09/07)
  681. TAB with REDIM  QB 4.50*       See sample program #33. (89/04/24)
  682. TIMER Replacement              The following is much faster than BASIC's
  683.                                TIMER function (90/08/27):
  684.                     MyTimer! = (PEEK(&H6C) + 256! * PEEK(&H6D)_
  685.                      + 65535! * PEEK(&H6E)) / 18.206227!
  686. Too Many Files  ???            A QB user has reported a problem that we are
  687.                                unable to duplicate. He says that the "Too
  688.                    many files" error can occur when a disk is
  689.                    full or there are too many files in the root
  690.                    directory. (89/02/10)
  691. Too Many Files  4.00b          When you use QB to make an EXE program, if
  692.                                you get this error, it usually indicates that
  693.                    a module's complete file spec (i.e., drive,
  694.                    path and filename) is longer than 60 chars.
  695.                    60 is the longest name that QB can handle.
  696.                    The solution is to shorten the file name.
  697. TYPE..END TYPE  QB 4           There has been an unverified problem reported
  698.                                in QB when the record length is an odd number.
  699.                    A "FAR HEAP CORRUPT" error is generated.
  700.                    The problem does not seem to appear in BC,
  701.                    only QB. If you have an unusual, otherwise 
  702.                    unexplained problem, try changing the record
  703.                    length to an even number.
  704. TYPE..END TYPE  QB 4           See "DIM" for QB 4.
  705. TYPE..END TYPE
  706.  (with COMMON)  QB 4           See COMMON (with TYPE) and sample program #1.
  707. UBOUND          QB 2-3         If you ERASE an array, UBOUND will return the
  708.                                upper bound of the array BEFORE it was erased.
  709.                    This works OK in QB 4.
  710. UNLOCK          QB 4           See LOCK QB 4 (88/12/19)
  711. VAL             QB 4 BC6/BC7   Much slower than QB3, including when /FPA
  712.                                switch is used. See part 2, under "VAL" for
  713.                    a workaround if you have Microsoft C. If you
  714.                    don't have C, you may want to consider
  715.                    MicroHelp's QB/Pro Volumes 1-4, which have
  716.                    routines that convert strings to integers
  717.                    and long integers. (90/01/08)
  718. VAL             QB 4 BC6*      Generates an error (rather than value of 0)
  719.                                when "e%" or "d%" (case doesn't matter) are 
  720.                    the first characters in a string, or when
  721.                    "%" is the first character. (89/04/24)
  722. VAL             QB 4*          When you use VAL("&"), you get 203 instead of 0.
  723. WINDOW          QB 2-4         Does not affect DRAW statements.
  724. ----------------------------------------------------------------------------
  725. Part 2 - General points of interest
  726. ----------------------------------------------------------------------------
  727. OPEN QB4.x BC7
  728.  
  729. When OPENing a file for APPEND and locking that file for write
  730. operations in a networking environment, you should be sure to
  731. specify an access clause of *both* read and write.
  732.  
  733. If your access clause just specifies "write" it is possible
  734. that QB will return error 75 "Path/file access error" for the OPEN
  735. command. (90/03/03)
  736. ----------------------------------------------------------------------------
  737. BC7 Type coercion from floating point to integer (90/06/19)
  738.  
  739. The following program demonstrates a problem when coercing a floating point
  740. number to an integer in BC7. The program will work fine in the QBX 
  741. environment, but returns spurious values for C% when compiled to an .EXE
  742.  
  743.     c2% = 10
  744.     a! = 1
  745.     DIM t%(10)
  746.     FOR c% = 1 TO c2%
  747.         PRINT c%, c2%
  748.         t%(c%) = a!
  749.     NEXT
  750.  
  751. The perceived value of C% is not spurious, it is the value of C2%.
  752.  
  753. A workaround:
  754.  
  755. By not allowing automatic coercion to be the last operation in the
  756. loop, the perceived value of C% remains correct.
  757. The coercion in the VAL function also causes the same problem.
  758.  
  759.         c2% = 10
  760.         a! = 1
  761.         DIM t%(10)
  762.         FOR c% = 1 TO c2%
  763.             PRINT c%, c2%
  764.             t%(c%) = a!
  765.             i%=i%+1             ' Added dummy instruction
  766.         NEXT
  767. ----------------------------------------------------------------------------
  768. BC7 with Inboard/PC and CoProcessor (90/01/08)
  769.  
  770. Effective with BC7, Microsoft has changed the way they test for the presence
  771. of a math coprocessor (80x87). They now test to see if the motherboard
  772. switch indicating a coprocessor is on or off. The Inboard/PC has to have
  773. the motherboard switch off. This means that BC7 won't recognize a 
  774. coprocessor on such a system.
  775. ----------------------------------------------------------------------------
  776. VAL Workaround (90/01/08)
  777.  
  778. If you have Microsoft C, you can take advantage of two functions built into
  779. the C library that will speed up the VAL function when used with integers and
  780. long integers.. In your BASIC program, you need to declare two FUNCTIONs and
  781. you must work with ASCIIZ strings (a BASIC string with a CHR$(0) on the end):
  782.  
  783.    DECLARE FUNCTION ATOI% CDECL (BYVAL ST%)
  784.    DECLARE FUNCTION ATOL& CDECL (BYVAL ST%)
  785.    ST$ = "1" + CHR$(0)
  786.    NUM% = ATOI%(SADD(ST$))
  787.    NUM& = ATOL&(SADD(ST$))
  788.    
  789. You'll also need to make a "dummy" C program, compile it and include it
  790. in your Quick Library (for use in the environment) and on the LINK command
  791. line:
  792.  
  793.    void dummy()
  794.    int n; long l; char near *ST;
  795.    n = atoi(st);
  796.    l = atol(st)
  797.  
  798. (90/01/18) Another suggestion from the same person is to read
  799. numeric DATA statements into strings and then use the ATOI
  800. function to get the integer value.
  801. ----------------------------------------------------------------------------
  802. Converting large numbers to integers (89/12/22) (updated 90/10/07)
  803.  
  804. A common technique to stuff a large number (between 32767 and 65536)
  805. into a BASIC integer is:
  806.  
  807.   BigNum& = 50000&
  808.   Intg% = BigNum& + 65536 * (BigNum& > 32767)
  809.  
  810. ----------------------------------------------------------------------------
  811. Using CALL with literals takes lots of stack space.  (89/10/10)
  812.  
  813.     ' Demonstrate the effect on stack space when using literals
  814.     ' in CALL statements.
  815.     
  816.     ' First, run the program as is and note the low point for
  817.     ' stack space. Then REM the line with variables in the CALL
  818.     ' and unREM the line with literals and run the program again.
  819.     
  820.     ' Note that the low stack point is ten bytes lower when
  821.     ' literals are used. In a large program with a lot of CALL
  822.     ' statements, this can really add up.
  823.     
  824.     DEFINT A-Z
  825.     PRINT "Lowest amount of stack space before CALL:"; FRE(-2)
  826.     A% = 1
  827.     B% = 2
  828.     C% = 3
  829.     D% = 4
  830.     E% = 5
  831.     ' REM next line for second pass
  832.     CALL TestStack(A%, B%, C%, D%, E%)
  833.     ' UNREM next line for second pass
  834.     'CALL TestStack(1, 2, 3, 4, 5)
  835.     PRINT "Lowest amount of stack space after CALL:"; FRE(-2)
  836.  
  837. SUB TestStack (A%, B%, C%, D%, E%)
  838.  
  839. END SUB
  840.  
  841. ----------------------------------------------------------------------------
  842. Long Integers in TYPE..END TYPE (BC 4.5*)
  843.  
  844. When long integers are part of a user defined type, and used in a SUB,
  845. the results are unpredictable. If you compile the following, you'll get
  846. different results in BC4.5 with and without /O.
  847.  
  848.  TYPE BugRecord
  849.  nbr AS LONG
  850.  END TYPE
  851.  
  852.  CALL bugsub
  853.  END
  854.  
  855.  SUB Bugsub
  856.  
  857.  DIM BUG(100) AS BugRecord
  858.  
  859.  BUG(1).nbr = 4
  860.  BUG(2).nbr = 6
  861.  
  862.  PRINT BUG(1).nbr + BUG(2).nbr
  863.  
  864.  END SUB
  865.  
  866.  
  867. ----------------------------------------------------------------------------
  868. BC 6 with math coprocessor (89/07/29)
  869.  
  870. If you are using the Microsoft BASIC Compiler 6 (version 6.00 or
  871. 6.00b) and are using the default math library (/FPI), you may
  872. experience unexplained "overflow" errors if your program is
  873. running on a 286/386 with a math coprocessor AND under DOS 3.2
  874. or 3.3. The solution is to use the alternate floating point math
  875. library (/FPA), however:
  876.  
  877. If you are running on a machine with a math coprocessor,
  878. you're using Btrieve 4.x or 5.x, you've compiled
  879. with the /FPA switch, AND your program CHAINs, then you
  880. must perform a Btrieve "reset" (Op%=28) before CHAINing
  881. or an "illegal function call" error will result.
  882. ----------------------------------------------------------------------------
  883. AB45ACVR.HLP and QB45ACVR.HLP (QB 4.50)
  884.                                The actual hypertext help file is QB45ACVR.HLP.
  885.                    Some of the entries in the help screens try
  886.                    to find AB45ACVR.HLP instead (i.e., the "Q"
  887.                    is changed to an "A". If you have a hard disk,
  888.                    you can remedy this by copying the "Q" file
  889.                    to the "A" file. (89/04/24)
  890. ----------------------------------------------------------------------------
  891. BUILDRTM (BC7)                 Has a limit of 127 exports in a single 
  892.                                extended runtime library. (89/04/24)
  893.                    Note that the error you receive is
  894.                    "Fixup overflow" when you run the BUILDRTM
  895.                    program.
  896. ----------------------------------------------------------------------------
  897. BUILDRTM (BC7)                 Has a limit of 255 exports. (89/11/03)
  898. ----------------------------------------------------------------------------
  899. Wyse PC Keyboard Problem
  900.  
  901. Some early versions of the BIOS used by Wyse incorrectly set a byte in the
  902. BIOS data area that tells QB that an enhanced keyboard is present. This
  903. causes a lockup, since QB is using an "enhanced" BIOS call to read the 
  904. keyboard and is not getting a response.
  905. ----------------------------------------------------------------------------
  906. ATI EGA Wonder Cards
  907.  
  908. If you find that you are unable to set EGA modes on a system with one
  909. of these cards, call ATI for a free BIOS upgrade.
  910.  
  911. ----------------------------------------------------------------------------
  912. Editor problem in QB 4.50
  913.  
  914. If the QB 4.50 editor seems to be "changing" your programs, including
  915. placing "garbage" characters on the screen, it may be due to your
  916. math "coprocessor" (80x87 chip). Two solutions:
  917.  
  918. 1. Check to make sure that the coprocessor chip is firmly seated.
  919. 2. Make sure that the motherboard switch indicating the presence of the
  920.    coprocessor is set correctly.
  921. ----------------------------------------------------------------------------
  922. Keeping DTR High QB 4 
  923.  
  924. According to Microsoft, you can keep DTR high when exiting from QB 4.x by
  925. performing the following steps:
  926.  
  927. 1. Close the serial port.
  928. 2. Immediately perform one of the following statements:
  929.    a. For COM1:  OUT &H3FC,3
  930.    b. For COM2:  OUT &H2FC,3
  931.    
  932. The OUT command will force pin 20 (DTR) to stay high. DTR will actually
  933. be dropped for an instant between the CLOSE and the OUT, but it should
  934. be too short for the modem to care. If this does cause a problem, try
  935. adjusting the "S" register (see your modem manual) to allow a larger
  936. time-out period before dropping the carrier.   
  937. ----------------------------------------------------------------------------
  938. Logitech Mouse Info QB 4.50 (88/12/19)
  939.  
  940. When running QB 4.5, if DOS is in 25 line mode and the QB editor
  941. is started with the /h option for 43 line mode, a Logitech
  942. Hi-Rez Bus mouse cursor disappears below line 25.  Solution: use
  943. the Microsoft vers.  6.24 mouse driver that came with QB4.5 or
  944. get the Logitech vers.  3.43 or later driver.  Contact Logitech
  945. at 1-415-795-8500.  Another solution is to use MODE43.COM from
  946. earlier QB versions to put the screen in 43 line mode before
  947. starting QB4.5.
  948.  
  949. ----------------------------------------------------------------------------
  950. Non-IBM EGA cards QB4.50 (88/12/19)
  951.  
  952. After running a program that uses the 25 line mode and a return
  953. is made to the editor, press F4 to review the Output screen and
  954. then press any key to return to the editor.  The screen will
  955. return to 43 line mode but the lines below line 25 will be
  956. blacked out.  The problem was found to be the Tseng EVA-480 EGA
  957. card.  A temporary fix is to do 'Alt-F' and then 'D' to execute
  958. a shell to DOS and immediately return or else press F5 to rerun
  959. the loaded program to restore the full 43 lines.  The better
  960. solution is to just not use the F4 key until the Tseng card's
  961. rom is updated or QB is fixed.
  962.  
  963. ----------------------------------------------------------------------------
  964. Cut and Paste Problems QB 4.50 (88/12/19)
  965.  
  966. On some "clone" computers, the Cut and Paste keys (Ctrl-Ins) and (Shift-Ins)
  967. do not work correctly. There are two things you can try:
  968.  
  969. 1. Turn off Caps Lock, Num Lock and Scroll Lock.
  970. 2. Run FIXSHIFT.COM with the "/I" switch to force installation.
  971.  
  972. If neither of the above work, contact Microsoft and let them know what
  973. your hardware configuration is.
  974. ----------------------------------------------------------------------------
  975. Avoiding unwanted line feeds when printing to LPT         
  976.  
  977. When you LPRINT a CHR$(13), QB4 automatically appends a CHR$(10) character
  978. causing "unwanted" line feeds. To avoid this problem:
  979.  
  980.   OPEN "LPT1:BIN" FOR OUTPUT AS #1
  981.  
  982. Then instead of using LPRINT, use PRINT #1,String. This causes the output
  983. to the printer to be "unfiltered".  
  984. ----------------------------------------------------------------------------
  985. DOS 4.00
  986.  
  987. On August 29, 1988, Infoworld reported several known problems with IBM DOS
  988. 4.0. Their suggestions include:
  989.  
  990. 1. If you use the DOS "Shell", run it in text mode to avoid conflicts with
  991.    TSR programs.
  992. 2. Disk un-fragment programs, such as Norton Utilities, Mac Utilities, 
  993.    VOPT, etc. don't work.
  994. 3. Lotus Metro doesn't work.
  995. 4. Don't use the EMS driver that comes with DOS if you have a third-party
  996.    memory board. Instead, use the driver that came with the board.
  997. 5. Don't try to install IBM DOS 4.0 on a hard disk that already has a
  998.    non-IBM version of DOS 3.x.
  999. 6. Don't use the "/X" switch with any itmes in CONFIG.SYS.
  1000.  
  1001. In the same issue, Cringely reports that IBM is working on DOS 4.1.   
  1002. ----------------------------------------------------------------------------
  1003. Problems when moving SUBs between modules in the environment.
  1004.  
  1005. The following is unedited text uploaded by a Compuserve user. The
  1006. problems described have not been confirmed - this is included for your
  1007. info and so that you can avoid doing what he did.
  1008.  
  1009. On SOME occations, QB will not let you save your program,
  1010. giving instead an "Out of Memory" error.  Automatically, you
  1011. lose everything you've done since you last saved.  But upon
  1012. exiting, you also find that the file was erased from the disk!
  1013. GONE!  Using Norton can RARELY bring it back (usually trying to
  1014. load the resurected file causes a complete system hang).  This
  1015. has happened at least 10 times to me.  The program is VERY large
  1016. (over 1200 lines) with many Subprograms.  The most notable cause
  1017. (but not ONLY) is when moving a SUBprogram from one program to
  1018. another (i.e. copying it).  When deleting the original SUB line
  1019. in the target program and substituting the one to be copied
  1020. (with <Sift><Ins>), everything appears fine until the next save.
  1021. This does not always happen, but USUALLY.  If I do not remove
  1022. the original SUB line, it doesn't seem as likely to happen.
  1023. These are all the clues I have on this one.  Also, jumping
  1024. between programs using <F>ile <O>pen tends to aggrivate the
  1025. problem.  If I do this frequently, a <F>ile <N>ew is likely to
  1026. give me a "string space corrupt" or "far heap corrupt" error and
  1027. dump me back to DOS.  Remember, these are large programs, with
  1028. large arrays (the /AH switch).
  1029.  
  1030. ----------------------------------------------------------------------------
  1031. Embedded Ctrl Characters (QB 4*)
  1032.  
  1033. Pressing Ctrl-P, followed by CHR$(12) (regardless of how you enter it),
  1034. does not embed a CHR$(12) in the text. However, if you use another text
  1035. editor to embed the CHR$(12), QB will display it just fine.
  1036.  
  1037. ----------------------------------------------------------------------------
  1038. Using DECLARE (QB 4*) without a CALL
  1039.  
  1040. The following code demonstrates a quirk after a SUB has been DECLAREd and
  1041. you invoke it without a CALL:
  1042.  
  1043.   DECLARE SUB XSUB (A!)
  1044.   start=0
  1045.   XSUB (start-1)\20+1            ' This does not work. QB cannot parse it.
  1046.   XSUB ((start - 1) \ 20 + 1)    ' This works. Note that the entire
  1047.                   ' expression is enclosed in parentheses.
  1048. SUB XSUB(A!)
  1049.     A!=A!+1
  1050. END SUB
  1051. ----------------------------------------------------------------------------
  1052. QB4 editor and marked blocks
  1053.  
  1054. If you mark a block, using the SHIFT and cursor keys, and then you type
  1055. a space (while still pressing the SHIFT key), your marked block will
  1056. disappear.
  1057. ----------------------------------------------------------------------------
  1058. Scan Codes for F11-F12 and Variations:
  1059.  
  1060.         F11=133
  1061.         F12=134
  1062.   Shift-F11=135
  1063.   Shift-F12=136
  1064.   Ctrl -F11=137
  1065.   Ctrl -F12=138
  1066.   Alt  -F11=139
  1067.   Alt  -F12=140
  1068. ----------------------------------------------------------------------------
  1069. Long integers with QB 4*
  1070.  
  1071. When you have a long integer array with two dimensions, BC may not handle
  1072. the zeroth elements correctly on machines without a math coprocessor
  1073. unless you use the "/d" switch. QB handles the situation OK because "debug"
  1074. is always on when working in the environment.
  1075.  
  1076. Secondly, if you dimension the same two-dimensional array using a variable
  1077. name instead of a numeric constant, BC may not handle your array at all! The
  1078. fix is to use only constant numbers in dimensioning the array. Another fix
  1079. that DOES work with dynamic arrays, is to use the /R switch when compiling.
  1080. ----------------------------------------------------------------------------
  1081. More on long integers *
  1082.  
  1083. If you pass a long integer array to a subprogram, QB will work OK, but
  1084. BC does not. See Sample Program #2.
  1085. ----------------------------------------------------------------------------
  1086. Long Integers and Calculations QB 4 `
  1087.  
  1088. Calculations using long integers should be tested thoroughly after compilation
  1089. with BC. Sample Program #6 demonstrates the problem.
  1090. ----------------------------------------------------------------------------
  1091. LIB environment variable
  1092.  
  1093. If you set the LIB environment variable, you will find that QB, BC, BUILDLIB
  1094. and LINK will all search the specified path whenever a User Lib, Quick Lib or
  1095. LINK lib is needed. The syntax is similar to the DOS Path syntax:
  1096.  
  1097.   SET LIB=C:\Libs;C:\DOS;C:\QB
  1098.   
  1099. Note that this does not have any effect when you are compiling from 
  1100. within the QB4` environment, and QB sticks the name of a library in the
  1101. object module field.
  1102. ----------------------------------------------------------------------------
  1103. Undocumented switches in QuickBASIC 3
  1104.  
  1105. QB ProgramName/F compiles the specified program to an EXE file without 
  1106. starting up the QB editor.
  1107.  
  1108. QB ProgramName/Z tells QB to load and execute ProgramName and exit to DOS
  1109. when the program ends.
  1110. ----------------------------------------------------------------------------
  1111. Response files
  1112.  
  1113. BUILDLIB and LINK both accept input from response files. This is exactly the
  1114. same as redirection of input, but the programs will continue running when
  1115. the end of the file is reached prematurely. Example:
  1116.  
  1117. Response file contains:
  1118.   Prog1+Prog2+Prog3+
  1119.   Prog4+Prog5+Prog6 Rem Don't include ANY additional blank lines
  1120.   
  1121. Buildlib batch file contains:
  1122.   Buildlib @Response.Fil,MyLib.Exe;
  1123.   
  1124. Buildlib will take its input from the response file because the "@" sign
  1125. tells it to!      
  1126. ----------------------------------------------------------------------------
  1127. BUILDLIB and "too many segments" error
  1128.  
  1129. Where "nnnn" is a number from 1 to 1024, use:
  1130.  
  1131.    BUILDLIB /SEG:nnnn
  1132.  
  1133. That increases (or decreases) the number of allowable segments. Default=255.
  1134. ----------------------------------------------------------------------------
  1135. Entering unusual ASCII values.
  1136.  
  1137. If you're not familiar with WordStar, you may not know that you can enter
  1138. unusual characters into the QB4 editor by doing the following:
  1139.  
  1140.   Hold the Ctrl key and press "P" once (nothing will happen).
  1141.   Release the Ctrl key.
  1142.   Press and hold the Alt key.
  1143.   Using the keypad number keys (not the keys on the top of the keyboard),
  1144.     enter the ASCII value for the key you want. For example, the 'Esc' key
  1145.     is ASCII 27, so press the "2", then the "7".
  1146.   Release the Alt key, and your special character will appear!  
  1147. ----------------------------------------------------------------------------
  1148. Part 3 - Sample programs
  1149. ----------------------------------------------------------------------------
  1150. Sample program #1. How to use COMMON with TYPE'd variables.
  1151.  
  1152.        ' Prog1.bas
  1153.  
  1154.          TYPE Namerec
  1155.            LastName AS STRING * 20
  1156.            FirstName AS STRING *15
  1157.          END TYPE
  1158.          COMMON Filename() AS Namerec
  1159.          DIM Filename(5) AS Namerec
  1160.          Filename(1).LastName="Novisoff"
  1161.          Filename(1).FirstName="Mark"
  1162.          CHAIN "Prog2"
  1163.  
  1164.        ' Prog2.bas
  1165.        
  1166.          TYPE Namerec
  1167.            LastName AS STRING * 20
  1168.            FirstName AS STRING * 15
  1169.          END TYPE
  1170.          COMMON Filename() AS Namerec
  1171.          PRINT Filename(1).LastName, Filename(1).FirstName
  1172.  
  1173. ----------------------------------------------------------------------------
  1174. Sample program #2. Demonstrates problem with long integers in subprograms.
  1175.  
  1176. DECLARE SUB TestLong (LongArray&())
  1177. 'Demonstration to show difference between return values of long integers
  1178.  
  1179. 'Returns desired value if compiled in the environment, but not if compiled
  1180. 'by BC.
  1181.  
  1182. 'This fault only appears if the code is in a subprogram and compiled with BC
  1183. REM $Dynamic
  1184. DIM LongArray&(10)
  1185. DIM MainArray%(10)
  1186.  
  1187. CLS
  1188. LongArray&(1) = 100
  1189. MainArray%(1) = 10
  1190.  
  1191. FOR x% = 1 TO 2
  1192.     LongArray&(1) = MainArray%(1) + LongArray&(1)
  1193.     ' Note: if you change the above into the following two lines, this part
  1194.     '       of the program will run correctly.
  1195.     'Temp& = MainArray%(1)
  1196.     'LongArray&(1) = Temp& + LongArray&(1)
  1197. NEXT
  1198.  
  1199. PRINT "TestLong should = 120"
  1200. PRINT "Long Array from MAIN = "; LongArray&(1)
  1201. PRINT : PRINT "Same code in a subprogram"
  1202. PRINT
  1203.  
  1204. CALL TestLong(LongArray&())
  1205.  
  1206. PRINT "TestLong should return 120"
  1207. PRINT "Long Array from TestLong sub = "; LongArray&(1)
  1208.  
  1209. SUB TestLong (LongArray&())
  1210. DIM IntArray%(10)
  1211.  
  1212. LongArray&(1) = 100
  1213. IntArray%(1) = 10
  1214.  
  1215. FOR x% = 1 TO 2
  1216.     LongArray&(1) = IntArray%(1) + LongArray&(1)
  1217.     ' Note: if you change the above into the following two lines, this part
  1218.     '       of the program will run correctly.
  1219.     'Temp& = IntArray%(1)
  1220.     'LongArray&(1) = Temp& + LongArray&(1)
  1221. NEXT
  1222. END SUB
  1223.  
  1224. ----------------------------------------------------------------------------
  1225. Sample program #3. Demonstrates problem with PAINT in QBX and BC7 when
  1226. chr$(0) is used.
  1227.  
  1228.     ' This code erases the yellow line in earlier compilers,
  1229.     ' but QBX/BC7 can't handle the CHR$(0) in the PAINT statement.
  1230.     
  1231.     SCREEN 8
  1232.     LINE (0,0)-(150,150),15,B
  1233.     LINE -(0,0),14
  1234.     PAINT (1,1),chr$(0),15
  1235.  
  1236. ----------------------------------------------------------------------------
  1237. Sample program #4. Demonstrates the limit on dynamic numeric
  1238. arrays in QB 3.  This program generates a program called
  1239. ARRAY.BAS. Compile ARRAY.BAS with the "/d" switch, LINK it and
  1240. RUN it. The sole function of ARRAY.BAS is to generate arrays.
  1241. Regardless of the value of I%, and regardless if you use "#",
  1242. "%" or "!" as the array type, the program gives an "Out of
  1243. memory" error when the 124th array is DIMmed.
  1244.  
  1245. OPEN "O",#1,"ARRAY.BAS"
  1246. PRINT #1,"I%=1"
  1247. FOR J=1 TO 126
  1248.   L=L+10:PRINT #1,MID$(STR$(L),2);" DIM A";MID$(STR$(J),2);"#(I%):PRINT FRE(-1)"
  1249. NEXT 
  1250. CLOSE
  1251. END
  1252. ----------------------------------------------------------------------------
  1253. Sample program #5. Demonstrates the a problem with PRINT TAB(x) followed
  1254. by PRINT USING in QB4.50. Fixed in MS PDS 7.0.
  1255.  
  1256. The program works OK in the QB4.50 environment. However, if you
  1257. use BC 4.50 to compile and LINK this program, you'll get strange results.
  1258. The workaround is to REM the PRINT TAB statements and UNREM the LOCATE
  1259. statements.
  1260.  
  1261.     CLS
  1262.     OPTION BASE 1
  1263.     DEFINT C, I
  1264.     C = 2
  1265.         DIM N$(C)
  1266.         DIM B(C)
  1267.     FOR I = 1 TO 2                        'Generate data
  1268.         N$(I) = CHR$(64 + I)                  'Row labels array
  1269.         B(I) = .08 * (I) ^ 4                  'Arbitrary array of numbers to print
  1270.     NEXT I
  1271.     PRINT TAB(5); "Char"
  1272.  
  1273.     FOR I = 1 TO 2
  1274.  
  1275.         PRINT TAB(5); N$(I);
  1276.         PRINT TAB(10); B(I);
  1277.  
  1278.         PRINT TAB(23);
  1279.         'LOCATE , 23
  1280.         PRINT USING "###.####"; B(I);
  1281.  
  1282.         PRINT TAB(40);
  1283.         'LOCATE , 40
  1284.         PRINT USING "###.###"; B(I);
  1285.  
  1286.         PRINT TAB(60);
  1287.         'LOCATE , 60
  1288.         PRINT USING "####.##"; B(I)
  1289.     NEXT I
  1290.     END
  1291.  
  1292. ----------------------------------------------------------------------------
  1293. Sample program #6. Demonstrates long integer calculation problem. This 
  1294. program will run in QB 4.00 and 4.00a, but it gives incorrect results
  1295. using BC or BC 6. This problem has been fixed in the BC that comes with
  1296. QB 4.50.
  1297.  
  1298. DEFINT J: DEFLNG T
  1299.  
  1300. DIM tum(2), ttm(2), th(2)
  1301.  
  1302. ttm(2) = 100000: th(2) = 1000000: j = 2
  1303.  
  1304. PRINT th(j) * VAL("9") + ttm(j) * VAL("9")
  1305.  
  1306. '    Result should be "9900000"
  1307.  
  1308. '    Substituting th(2) for th(j) (etc). makes it work.  So does using
  1309. '    CLNG(VAL("9")).  It also works when the array tum(2) isn't there.
  1310. '    Compiling with "/d" may fix the problem in some cases. Substituting
  1311. '    a single precision number seems to work.
  1312. ----------------------------------------------------------------------------
  1313. Sample program #7. Demonstrates slowdown in STR$ function in QB 4.
  1314.  
  1315.   defint a-z
  1316.   a!=timer
  1317.   for n=1 to 5000
  1318.       a$=str$(n)
  1319.   next
  1320.   print "elapsed:" timer-a!
  1321. ----------------------------------------------------------------------------
  1322. Sample program #9. Demonstrates a problem with IF..THEN..ELSE. Using any
  1323. compiler except QB4.00 and QB4.00a, the string "THIS IS AN ERROR" is
  1324. never printed. Using these two environments causes the string to print
  1325. whenever X<>2.
  1326.  
  1327.   10 INPUT "TYPE A NUMBER ", X
  1328.   20 IF X = 2 THEN 50 : PRINT "THIS IS AN ERROR"
  1329.   30 PRINT "AT LINE 30"
  1330.   40 GOTO 10
  1331.   50 PRINT "AT LINE 50"
  1332.   60 GOTO 10
  1333. ----------------------------------------------------------------------------
  1334. Sample program #10. Demonstrates a problem when INPUT is used directly
  1335. to an array element that is beyond the maximum dimension of the array.
  1336. When run inside the QB 4 environment, this program will cause a hard crash.
  1337. This problem does not apply to LINE INPUT.
  1338.  
  1339. This problem has been fixed in QB 4.50.
  1340.  
  1341.   DIM A$(20)
  1342.   FOR I = 1 TO 20
  1343.       A$(I) = STR$(I)
  1344.   NEXT
  1345.   INPUT "Enter something: ", A$(I)     ' At this point, I=21
  1346.  
  1347. ----------------------------------------------------------------------------
  1348. Sample program #11. Demonstrates a problem with REDIM PRESERVE in BC 7.10
  1349.  
  1350. ' This program works when compiled with /FS/O/AH. It gives
  1351. ' "out of string space" error when compiled with /O/AH (near strings)
  1352. DEFINT A-Z
  1353. FOR N = 1 TO 32766 STEP 16
  1354.     IF INKEY$ = CHR$(27) THEN STOP
  1355.     REDIM PRESERVE X(N) AS STRING * 64
  1356.     LOCATE 25, 1
  1357.     PRINT N, FRE(""), FRE(-1);
  1358. NEXT
  1359. ----------------------------------------------------------------------------
  1360. Sample program #12. Demonstrates a problem with Instant Watch in QB 4.50
  1361. Run this program in QB4.50. When it stops, put your cursor under the "A"
  1362. in A$ and press Shift-F9 and then <Enter>. Your system will crash.
  1363.  
  1364. The workaround is to either use Alt-D-<Enter> and type in the name of the
  1365. string, or to put A$ in the watch window before it is assigned characters.
  1366.  
  1367. The problem has been fixed as of QBX in PDS 7.1.
  1368.  
  1369. A$ = STRING$(200, 65)
  1370. STOP
  1371.  
  1372. ----------------------------------------------------------------------------
  1373. Sample program #17. Demonstrates a problem using GOTO inside an
  1374. IF..THEN..ELSE block. This program will work fine in the QB4.00 and QB4.00a
  1375. environment, but will fail when compiled with BC or BASCOM 6. By "fail",
  1376. I mean that both PRINT statements are executed. The problem has been fixed
  1377. in the BC that comes with QB 4.50.
  1378.  
  1379.    x% = 1
  1380.    IF x% = x% THEN
  1381.      PRINT "1 equals 1"
  1382.      GOTO 10
  1383. 10   x% = x%
  1384.    ELSE
  1385.      PRINT "1 does not equal 1"
  1386.    END IF
  1387.  
  1388. ----------------------------------------------------------------------------
  1389. Sample program #18. Demonstrates a problem using /S in conjunction with
  1390. /O and communications, where a string literal (in quotes) is used for the
  1391. COM parameters. This problem has been fixed in the BC that comes with QB 4.50.
  1392.  
  1393.    ' compile with BC:
  1394.    '        BC prog/s/o;  (produces device unavailable error but runs
  1395.    '                       fine in the environment)
  1396.    '            and
  1397.    '        BC prog/o; (runs fine)
  1398.    CLS
  1399.    OPEN "COM1:1200,O,7,1,CS,DS,CD" FOR RANDOM AS #1 LEN = 256
  1400.    PRINT #1, "ATM1X2E1 S11=72DT 999-9999;"
  1401.    PRINT "Press any key to continue..."
  1402.    DO WHILE LEN(INKEY$) = 0: LOOP
  1403.    PRINT #1, "ATH"
  1404.    CLOSE
  1405.    END
  1406.  
  1407. The solution to the above is to assign the COM specifications to a string
  1408. before doing the OPEN:
  1409.  
  1410.    A$ = "COM1:1200,O,7,1,CS,DS,CD"
  1411.    OPEN A$ FOR RANDOM AS #1 LEN = 256
  1412. ----------------------------------------------------------------------------
  1413. Sample program #19. Demonstrates a problem where If a breakpoint
  1414. is set on a CASE line of a SELECT CASE ... END SELECT
  1415. statement, the SELECT CASE structure is not executed properly.
  1416. QB 4.50 tells you that you cannot set a breakpoint on a CASE or
  1417. END SELECT statement.  Some fix!!!
  1418.  
  1419. 'Set a breakpoint (F9) on the 'CASE 1' line, and RUN the program (F5)
  1420.  
  1421. DEFINT A-Z
  1422. A = 2
  1423. SELECT CASE A
  1424.        CASE 1
  1425.             PRINT "A equals 1"
  1426.        CASE 2
  1427.             PRINT "A equals 2"
  1428.        CASE ELSE
  1429.             PRINT "A is not equal to 1 or 2"
  1430. END SELECT
  1431. ----------------------------------------------------------------------------
  1432. Sample program #21. Demonstrates a problem with PUT and QB4.00b
  1433.  
  1434.    OPEN "test.dat" FOR RANDOM AS 1 LEN = 140
  1435.    t$ = STRING$(140, "A")
  1436.    LSET buffer$ = t$
  1437.    PUT #1, , t$
  1438.    CLOSE 1
  1439.  
  1440. This program will work with QB4.00a but not with QB4.00b
  1441.  
  1442. The solution is to use the "old-style" FIELD statement:
  1443.  
  1444.    OPEN "test.dat" FOR RANDOM AS 1 LEN = 140
  1445.    FIELD 1,140 as Buffer$
  1446.    LSET Buffer$ = STRING$(140, "A")
  1447.    PUT #1,1
  1448.    CLOSE 1
  1449.  
  1450. The following info was added 89/10/07 (contributed by Phil Weber):
  1451.  
  1452. The reason for this is that, beginning with version 4.00b, when PUTting a
  1453. variable-length string into a RANDOM file, QB precedes the string with its
  1454. length (a two-byte integer).  Thus the (apparently) 140-byte T$ above becomes
  1455. 142 bytes in length.  Your recommended solution is to declare a file buffer
  1456. using the FIELD statement -- that works because FIELDed strings are not
  1457. variable-length.  Two other options are to declare the record length two bytes
  1458. longer than you actually need (albeit a bit wasteful, but it works!), or to
  1459. DIM your string variable to a fixed length, like this:
  1460.  
  1461.        OPEN "Test.Dat" FOR RANDOM AS #1 LEN = 140
  1462.        REDIM T AS STRING * 140
  1463.        T = STRING$(140, 32)
  1464.        PUT 1, , T
  1465.        CLOSE
  1466.  
  1467. Thought the above info might help anyone who's been perplexed by the "Bad
  1468. Record Length" error.
  1469. ----------------------------------------------------------------------------
  1470. Sample program #22. Demonstrates a problem with CALL:
  1471.  
  1472. Note that this program requires TEST.DAT, which is part of the ARC file.
  1473. It also requires that you use an assembly subroutine to display a
  1474. string from the array.
  1475.  
  1476. The fix is to place A$() in a COMMON SHARED statement and take it out
  1477. of the parameter list in the CALL and the SUB statements.
  1478.  
  1479.  DEFINT A - Z
  1480.  DIM A$(3)
  1481.  CLS
  1482.  OPEN "R", 1, "TEST.DAT", 128
  1483.  FIELD 1, 32 AS A$(1), 6 AS A$(2), 90 AS A$(3)
  1484.  PRINT "Getting Record One"
  1485.  GET 1, 1
  1486.  PRINT "A$(1) Contains: "; A$(1)
  1487.  PRINT "A$(2) Contains: "; A$(2)
  1488.  CALL AnotherWay (A$())
  1489.  PRINT
  1490.  PRINT "Getting Record Two"
  1491.  GET 1, 2
  1492.  PRINT "A$(1) Contains: "; A$(1)
  1493.  PRINT "A$(2) Contains: "; A$(2)
  1494.  CALL AnotherWay (A$())
  1495.  CLOSE
  1496.  END
  1497.  
  1498. SUB AnotherWay (A$()) STATIC
  1499.  
  1500. stop
  1501.  ' Insert a call to an assembler routine to display A$(1)
  1502.  ' The following 2 lines are included for the benefit of Mach 2 users.
  1503.  ' R%=CSRLIN:C%=POS(0)
  1504.  ' CALL MhScr(A$(1),0%,R%,C%,7%)
  1505.  PRINT
  1506.  PRINT A$(2)
  1507. END SUB
  1508. ----------------------------------------------------------------------------
  1509. Sample program #23. Demonstrates a problem with SHARED in QB4.00b. The
  1510. problem did not exist in QB4.00.
  1511.  
  1512. If you change the name of db to something else, or you place db and db()
  1513. in the parameter list, all is well. The problem seems to be that if
  1514. you have a scalar with the same name as an array, and you name it in the
  1515. SHARED statement, QB thinks that the scalar and the array are one in the
  1516. same.
  1517.  
  1518. DIM db(10)
  1519. db(1) = 1
  1520. db = 2
  1521. CALL Test(db)
  1522.  
  1523. SUB Test (db)
  1524.     SHARED db()      '<= duplicate definition error
  1525.     PRINT db, db(1)
  1526. END SUB
  1527. ----------------------------------------------------------------------------
  1528. Sample program #24. Demonstrates a problem with '$Include in all versions
  1529. of QB 4.00x:
  1530.  
  1531. ' Load this program into QB, move the cursor to the end of the first
  1532. ' rem $include line and press the Del key. You will get "string space
  1533. ' corrupt" and when you go to run another program, you are hung!
  1534.  
  1535. REM $INCLUDE: 'c:\subprogs\done\ssinput.cal'
  1536. REM $INCLUDE: 'c:\subprogs\done\vinput.cal'
  1537. ----------------------------------------------------------------------------
  1538. Sample program #25. Demonstrates a problem with long integers used
  1539. in user defined types. When you attempt to compile the following program
  1540. with BC, you'll get an "Internal error" message from the compiler. The
  1541. problem has been fixed in the BC that is included with QB4.50.
  1542.  
  1543.    DEFINT A-Z
  1544.    TYPE Bt
  1545.       a   AS INTEGER
  1546.       b   AS LONG
  1547.       c   AS LONG
  1548.    END TYPE
  1549.    DIM Bt(1) AS Bt
  1550.    Bt(y).b = x&
  1551.    Bt(y).c = Bt(y).b
  1552.  
  1553. There are several ways of "fixing" the above:
  1554.  
  1555. 1. Swap the last two lines.
  1556. 2. Change a variable subscript (y) to literal subscript (1)
  1557. 3. Change the order of the variables a,b,c.
  1558. 4. Add a line between the last two lines, like "j=k*3"
  1559. 5. Break the last line up into: 
  1560.      temp&=Bt(y).b
  1561.      Bt(y).c=temp&
  1562.  
  1563. The problem apparently has to do with optimization of the last two
  1564. lines of code.
  1565. ----------------------------------------------------------------------------
  1566. Sample program #26. Demonstrates a problem with FRE(-2) in all versions
  1567. of QuickBASIC 2-4.
  1568.  
  1569. DEFINT A-Z
  1570. PRINT "before call", FRE(-2)
  1571. CALL test
  1572. PRINT "after call", FRE(-2)
  1573.  
  1574. ' For QB2/3, add the STATIC keyword after SUB test
  1575. SUB test 
  1576.  
  1577.     PRINT "entering sub", FRE(-2)
  1578.     REDIM a$(100)
  1579.     FOR i = 0 TO 100
  1580.     a$(i) = "this is a test"
  1581.     NEXT i
  1582.     PRINT "before erase", FRE(-2)
  1583.     ERASE a$
  1584.     PRINT "after erase", FRE(-2)
  1585. END SUB
  1586. ----------------------------------------------------------------------------
  1587. Sample program #28. Demonstrates a problem with periods in variable names.
  1588.  
  1589. ' Note - name this program TEST1.BAS
  1590.  
  1591.      DEFINT A-Z
  1592.      DIM STG$(10), DBLP#(10), INTG(10)
  1593.      COMMON SHARED STG$(), DBLP#(), INTG(), message$
  1594.      message$ = "Hello there."
  1595.      CHAIN "TEST2"
  1596.  
  1597. ' Note - name this program TEST2.BAS
  1598.      DEFINT A-Z
  1599.      DIM STG$(10), DBLP#(10), INTG(10)
  1600.      COMMON SHARED STG$(), DBLP#(), INTG(), message$
  1601.      DIM er.Mem(1024)             'Bad Guy
  1602.      TYPE item
  1603.         store AS STRING * 1
  1604.         item AS STRING * 5
  1605.      END TYPE
  1606.      DIM itemrec AS item          'Contributor to the problem
  1607.      PRINT "OK, This is the message...  "; message$
  1608.      END
  1609.  
  1610. Note that the error occurs in QB 4.00b and QB 4.50. The second DIM in
  1611. TEST2.BAS combined with the DIM of an array with a period, causes the
  1612. problem.
  1613.  
  1614. ----------------------------------------------------------------------------
  1615. Sample program #29. Demonstrates a problem with INT in all versions of QB 4
  1616. and QBX. (88/12/19).
  1617.  
  1618. 'This bug only happens using BC4.50/7.0 and QB4.50/QBX. It works
  1619. 'fine in the environment using earlier versions of QB4.  
  1620. 'The INT(numeric expression) statement does not always return the
  1621. 'correct value if the numeric expression is a calculation.  The
  1622. 'following example will illustrate:
  1623.  
  1624.     A = .9
  1625.     B = 10
  1626.     C = INT(A * B)   'This will produce a result of 8 instead of 9.
  1627.     PRINT "All numbers shown should be 9"
  1628.     PRINT C
  1629.     D = A * B
  1630.     PRINT D
  1631.     C = INT(D)       'This will produce the correct result.
  1632.     PRINT C
  1633.     C = INT(.9 * 10) 'This will also produce the correct result.
  1634.     PRINT C
  1635. ----------------------------------------------------------------------------
  1636. Sample program #30. Demonstrates a problem with CINT in all versions of QB 4.
  1637. (88/01/03)
  1638.  
  1639. FOR I = -10.5 TO 10.5
  1640.   PRINT I, CINT(I)
  1641. NEXT
  1642. ----------------------------------------------------------------------------
  1643. Sample program #31. Demonstrates two problems when you LINK with /PAC.
  1644. (89/02/10)
  1645.  
  1646. If you use the /PAC switch, strange things can happen to your
  1647. programs. Compile the code shown below into two object modules using
  1648. the /X switch.
  1649.  
  1650. ' This is TEST1.BAS
  1651. CALL Test2
  1652. DATA "This is string 1"
  1653. DATA "This is string 2"
  1654.  
  1655.  
  1656. ' This is TEST2.BAS
  1657. Ehandler:
  1658.   RESUME NEXT
  1659. Test2Data:
  1660.   DATA "This is string 3"
  1661.   DATA "This is string 4"
  1662.  
  1663. SUB Test2
  1664.   ON ERROR GOTO Ehandler
  1665.   RESTORE Test2Data
  1666.   READ A$
  1667.   PRINT A$
  1668.   READ A$
  1669.   PRINT A$
  1670.   PRINT "Error was handled ok."
  1671. END SUB
  1672.  
  1673. If you LINK the programs normally, the strings are printed correctly
  1674. and the error is handled properly. If you LINK the same modules with
  1675. /PAC, the data are not read and the error is not handled!
  1676.  
  1677. ----------------------------------------------------------------------------
  1678. Sample program #32. Demonstrates a problem with DECLARE.
  1679. (89/02/10)
  1680.  
  1681. In the following program, "MySub1" is not executed. Instead, QB
  1682. treats the invocation of the SUB as a label. Note that this happens
  1683. only when there are no parameters, and you omit the CALL keyword
  1684. (requiring that you DECLARE the procedure). In addition, there must
  1685. obviously be a colon on the line after the name of the SUB.
  1686.  
  1687. DECLARE SUB MySub1 ()
  1688. DECLARE SUB MySub2 ()
  1689.  
  1690.     MySub1: MySub2
  1691.  
  1692. SUB MySub1
  1693.     PRINT "Hello"
  1694. END SUB
  1695.  
  1696. SUB MySub2
  1697.     PRINT "Goodbye"
  1698. END SUB
  1699. ----------------------------------------------------------------------------
  1700. Sample program #33. Demonstrates a problem using TAB with REDIM in QB 4.50.
  1701. (89/04/24)
  1702.  
  1703.         REDIM Text$(4)
  1704.         Text$(1) = "1111"
  1705.         PRINT TAB(4); Text$(1);
  1706.  
  1707. Remove the TAB(4); or change REDIM to DIM and it'll work. As it sits it bombs
  1708. the computer requiring a reboot. Variables vs literals in the TAB argument
  1709. don't appear to affect it after all. This affects both PRINT and LPRINT.
  1710. ----------------------------------------------------------------------------
  1711. Sample program #34. Demonstrates a problem using DATA, READ and RUN with
  1712. BC4.00b and BC6.00b (89/07/29)
  1713.  
  1714. ' On the second and subsequent executions of this program, BC4.00b gives
  1715. ' a SYNTAX error, while BC6.00b just prints zeros.
  1716.  
  1717.  READ A%
  1718.  PRINT A%
  1719.  IF INKEY$ <> "" THEN END
  1720.  RUN
  1721.  DATA 1
  1722.  
  1723. ----------------------------------------------------------------------------
  1724. Sample program #35. Demonstrates a problem using SWAP and CONST in QB 4.50
  1725. (89/09/07)
  1726.  
  1727. ** Warning - this program will crash your system **
  1728.  
  1729. Load the following program into QB4.50 and press F5:
  1730.  
  1731.   const Nul$=""
  1732.   z$="hello"
  1733.   swap z$,Nul$
  1734.   
  1735. QB4.50 gives different results, depending on if Nul$ is "" or has a length.
  1736.  
  1737. QB4.00b and QBX correctly trap the error of trying to SWAP a constant.
  1738. ----------------------------------------------------------------------------
  1739. Sample program #36. Demonstrates a problem using temporary strings with
  1740. DEF FN in all compilers.
  1741.  
  1742. When a string is passed as an argument to a DEF FN function, it
  1743. remains in memory until the next time that function is invoked.
  1744. In (almost) all other situations where BC/QB has to create a
  1745. temporary string, it calls the "String Delete" routine to mark
  1746. it as free for the garbage collection.  So if you pass, say, a
  1747. 10K string as an argument, you just lost 10K of string space.
  1748. Ouch, no?  This happens only when compiled to disk though, not
  1749. in the environment.  Proof follows.
  1750.  
  1751.    DEF FNOuch% (Work$)
  1752.        X = LEN(Work$)
  1753.    END DEF
  1754.    PRINT FRE("")
  1755.    Dummy = FNOuch%(STRING$(10000, "A"))
  1756.    PRINT FRE("")
  1757.  
  1758. ----------------------------------------------------------------------------
  1759. Sample program #37. Demonstrates a problem with INSTR in BC 4.x
  1760.  
  1761.      DEFINT A-Z
  1762.      CLS
  1763.      Literal$ =""            'This string is made in the QB Editor by
  1764.                              'typing Ctrl-P and then holding down Alt
  1765.                              'while typing ASCII code of character.
  1766.                  'Enter ASCII 1 through 5.
  1767.      FOR I = 1 TO 5
  1768.          Found = INSTR(Literal$, CHR$(I))
  1769.          PRINT "INSTR reports CHR$("; MID$(STR$(I), 2);
  1770.          PRINT ") at position"; Found; "of Literal$."
  1771.      NEXT
  1772.      PRINT
  1773.  
  1774.      Char$ = CHR$(1) + CHR$(2) + CHR$(3) + CHR$(4) + CHR$(5)
  1775.      FOR I = 1 TO 5
  1776.          Found = INSTR(Char$, CHR$(I))
  1777.          PRINT "INSTR reports CHR$("; MID$(STR$(I), 2);
  1778.          PRINT ") at position"; Found; "of Char$."
  1779.      NEXT
  1780.      END
  1781.  
  1782. In the environment, as one would expect, the above program
  1783. reports CHR$(1) at position 1, CHR$(2) at position 2, etc. for
  1784. *both* strings.  But compiled to an EXE file, INSTR reports
  1785. position 0 for CHR$(1) and CHR$(2) in Literal$
  1786.  
  1787. Note: BC7 documents that you cannot use CHR$(1) and CHR$(2) in a string.
  1788. Actually, you can have those characters in a string, but INSTR and possibly
  1789. PRINT won't work correctly.
  1790.  
  1791. ----------------------------------------------------------------------------
  1792. Sample program #38. Demonstrates a problem with LINE (filled box) and
  1793. VIEW that was not fixed until BC7.
  1794.  
  1795. SCREEN 9
  1796. VIEW (1,1)-(150,150)
  1797. LINE (-50,50)-(-100,100),12,B
  1798. LINE INPUT "Image clipped correctly";Z$
  1799. LINE (-50,50)-(-100,100),12,BF
  1800. LINE INPUT "Image *not* clipped correctly";Z$
  1801.  
  1802. ----------------------------------------------------------------------------
  1803. Sample program #39. Demonstrates a problem with SWAP and single precision
  1804. array elements using BC7.
  1805.  
  1806.     DIM dt!(2), rn%(2)
  1807.     n = 1    
  1808.     a! = dt!(n) * 100000! + rn%(n)
  1809.     b! = dt!(n + 1) * 100000! + rn%(n + 1)
  1810.     SWAP dt!(n), dt!(n + 1)
  1811.     
  1812. The above program gives an "out of memory" error. Remming the "+ rn%(.."
  1813. in two places solves the problem.
  1814.  
  1815. Microsoft suggests a SUB to do the SWAP:
  1816.  
  1817.     CALL SwapSub(DT!(n), DT!(n+1)
  1818.     
  1819.     SUB SwapSub(A!, B!)
  1820.         SWAP A!, B!
  1821.     END SUB    
  1822.  
  1823. ----------------------------------------------------------------------------
  1824. Part 4 - Video adapters compatible with QB 4.50
  1825. ----------------------------------------------------------------------------
  1826. The following cards are available "in-house" at Microsoft and were tested
  1827. with QB4.50
  1828.  
  1829. Cards that PASSED:
  1830.  
  1831. (Note - if the card is a VGA but not an IBM PS/2 VGA,
  1832.         there will be problems swapping on screen 10.)
  1833.  
  1834.           AST EGA (256k)
  1835.           Compaq Portable (Monochrome)
  1836.           Compaq VGC (Their name for VGA)
  1837.           Daewoo (Leading Edge/AT) EGA (256k) Monochrome
  1838.           Genoa EGA (256k)
  1839.           Genoa EGA (256k) monochrome
  1840.           Hercules Monochrome
  1841.           IBM EGA 256k
  1842.           IBM EGA 64k
  1843.           IBM PC Convertible
  1844.           IBM VGA (Non-PS/2)
  1845.           IBM PS/2 VGA
  1846.           IBM MCGA
  1847.           IBM EGA (64k) with monochrome
  1848.           IBM CGA
  1849.           IBM MDPA
  1850.           NCR EGA
  1851.           Olivetti Monochrome
  1852.           Olivetti EGA (256k)
  1853.           Olivetti VGA
  1854.           Paradise Autoswitch EGA (256k)
  1855.           PC's Limited VGA
  1856.           Tandy EGA (256k)
  1857.           Vega Video-7 Deluxe EGA (256k)
  1858.           Zenith EGA monochrome
  1859. ________________________________________________________________________
  1860.  
  1861. Cards that loaded QB, but had numerous problems with screen swapping
  1862.  
  1863.           Techmar VGA
  1864.           Quadram VGA
  1865.           Vega-Video 7 Fastwrite VGA
  1866.           Vega VGA
  1867.  ________________________________________________________________________
  1868.  
  1869. Cards not guarenteed to load QB (cards in this section would not load QB,
  1870. but may)
  1871.  
  1872.           Compaq Laptop (BIOS problem - no fix)
  1873.           Genoa SuperVGA HiRes (models 5100 and 5200)
  1874.           VIP ATi VGA
  1875.           Sigma EGA!
  1876. ________________________________________________________________________
  1877.  
  1878. In addition, these cards have been reported by support as potential
  1879. problem cards.
  1880.  
  1881.           Older Quadram CGA adapters
  1882.           Sperry Hercules compatible and CGA adapters
  1883.           (stock in Sperry machines)
  1884.           Leading Edge CGA and Hercules compatible adapters
  1885.           (stock in Leading Edge Model M machines)
  1886. ________________________________________________________________________
  1887.  
  1888. {End of QUIRKS.TXT file}
  1889.