home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progbas / knowbase.arj / KNOWBASE.ASC
Text File  |  1991-05-01  |  256KB  |  6,879 lines

  1. This is a download of current messages under the QUICKBASIC and BASIC 7
  2. topics in the KnowledgeBase section of Microsoft Online.
  3.  
  4. _____________________________________________________________________________
  5. Q41149 Single Precision Numbers Have 1 to 7 Digits; Double Have 8+
  6. Microsoft QuickBASIC Compiler (QUICKBAS)
  7. 4.00 4.00b 4.50
  8. MS-DOS
  9.  
  10. Summary:
  11.  
  12. The documentation below should be changed to say that a constant is
  13. single precision if it has fewer than eight digits and is double
  14. precision if it has eight or more digits.
  15.  
  16. This correction applies to the following documentation:
  17.  
  18. 1. Page 24 of "Microsoft QuickBASIC: BASIC Language Reference" manual
  19.    for Versions 4.00 and 4.00b for MS-DOS.
  20.  
  21. 2. Page 24 of "Microsoft BASIC Compiler: BASIC Language Reference" for
  22.    Versions 6.00 and 6.00b for MS OS/2 and MS-DOS. (Note: This is the
  23.    same as QuickBASIC's language reference manual.)
  24.  
  25. 3. Page 18 of the "Microsoft QuickBASIC: BASIC Language Reference"
  26.    manual for QuickBASIC Version 4.50. This manual must be ordered
  27.    separately from the Version 4.50 package.
  28.  
  29. 4. The QuickBASIC Version 4.50 QB Advisor on-line help system, when
  30.    you select "Help - Contents - Data Types - Constants".
  31.  
  32. More Information:
  33.  
  34. The above pages INCORRECTLY state that a number is single precision if
  35. it has fewer than 15 digits and is double precision if it has more than
  36. 15 digits.
  37.  
  38. This documentation error was corrected in the "Microsoft BASIC 7.0:
  39. Language Reference" manual of Microsoft BASIC PDS Version 7.00 for
  40. MS-DOS and MS OS/2.
  41.  
  42. The above products follow the IEEE standard format for storage of
  43. floating-point numbers.
  44.  
  45. Keywords:  docerr B_BasicCom  SR# S890208-209
  46.  
  47. COPYRIGHT Microsoft Corporation, 1989.
  48. Updated  89/12/13 04:12
  49. _____________________________________________________________________________
  50. Q51605 Example of Gaussian Elimination; Matrix Math in BASIC 7.00
  51. Microsoft BASIC Compiler (BASICCOM)
  52. 7.00   | 7.00
  53. MS-DOS | OS/2
  54.  
  55. Summary:
  56.  
  57. This article explains the purpose of Gaussian elimination and gives
  58. a code example.
  59.  
  60. In Microsoft BASIC PDS (Professional Development System) Version 7.00
  61. for MS-DOS and MS OS/2, the following FUNCTION procedures perform
  62. Gaussian elimination:
  63.  
  64.    MatSEqnS% (for single-precision)
  65.    MatSEqnD% (for double-precision)
  66.    MatSEqnC% (for currency data type)
  67.  
  68. The source code of all of these functions is provided in the MATB.BAS
  69. source file on one of the release disks. To use these functions in the
  70. QuickBASIC Extended editor, load the MATBEFR.QLB Quick library as
  71. follows:
  72.  
  73.    QBX /L MATBEFR.QLB
  74.  
  75. MATFEFR.QLB and the related .LIB files are mentioned in the $INCLUDE
  76. file MATB.BI. MATB.BI contains DECLARE FUNCTION statements necessary
  77. for the matrix math routines.
  78.  
  79. More Information:
  80.  
  81. Definitions
  82. -----------
  83.  
  84. 1. A matrix is a two-dimensional array in BASIC.
  85.  
  86. 2. A vector is a one-dimensional array in BASIC.
  87.  
  88. 3. An identity matrix is a square array composed of 1's along the
  89.    diagonal from upper left to lower right, with all else 0's (zeros).
  90.  
  91. Gaussian Elimination
  92. --------------------
  93.  
  94. A linear equation of n variables (unknowns) has the following form:
  95.  
  96.    a1*x1 + a2*x2 + an*xn = b
  97.  
  98. where:
  99.  
  100.    a1 through an and b are known constants, and x1 through xn are
  101.    variables with unknown values.
  102.  
  103. Linear equations do not involve any products or roots of variables.
  104. All variables are to the first power, and don't appear as arguments
  105. of trigonometric, logarithmic, or exponential functions.
  106.  
  107. A solution of a linear equation is a sequence of n numbers (s1 through
  108. sn) such that the equation is satisfied when we substitute x1=s1,
  109. x2=s2, ..., xn=sn.
  110.  
  111. A set of multiple linear equations in the variables x1 through xn is
  112. called a system of linear equations. The set (vector) of constants s1
  113. through sn is called a solution of the system if it provides a
  114. solution for every equation in the system. Every system of linear
  115. equations has either no solutions, exactly one solution, or infinitely
  116. many solutions.
  117.  
  118. A system of m linear equations in n unknowns can be written as follows
  119. in BASIC:
  120.  
  121.    a(1,1)*x1 + a(1,2)*x2 + ... + a(1,n)*xn = b(1)
  122.  
  123.    a(2,1)*x1 + a(2,2)*x2 + ... + a(2,n)*xn = b(2)
  124.  
  125.       ...                  ...
  126.  
  127.    a(m,1)*x1 + a(m,2)*x2 + ... + a(m,n)*xn = b(m)
  128.  
  129. If you mentally keep track of the location of the +'s, the x's, and
  130. the ='s, the arrays a(m,n) and b(m) provide a shorthand notation for
  131. the system of linear equations. In elementary linear algebra texts,
  132. a(m,n) and b(m) together make what is called the "augmented matrix."
  133.  
  134. Again, our goal is to discover the unknown values s1 through sn that,
  135. when assigned to variables x1 through xn, solve every equation.
  136.  
  137. Gaussian elimination reduces the augmented matrix [the combination of
  138. a(m,n) and b(m)] to a matrix of reduced row-echelon form, which looks
  139. like a square identity matrix attached to a 1 by m vector [ b() ]. The
  140. vector b() contains the solution set (s1 through sn) of the system of
  141. linear equations.
  142.  
  143. The Gaussian elimination functions MatSEqnS%, MatSEqnD%, and MatSEqnC%
  144. accept a square matrix a() and a vector b() as input arguments
  145. (together composing the input-augmented matrix), and give the solution
  146. in the one-dimensional array b(). After you invoke the function, a()
  147. is replaced with the identity matrix, and the solution values
  148. overwrite the input arguments that you had placed in b(). The n
  149. solution values in b(), when assigned to variables x1 through xn,
  150. satisfy every equation in the system.
  151.  
  152. For more information about linear algebra, the following is an
  153. excellent text:
  154.  
  155.    "Elementary Linear Algebra, Second Edition", by Howard Anton,
  156.     published by John Wiley & Sons, 1977
  157.  
  158. Code Example
  159. ------------
  160.  
  161. ' This program demonstrates Gaussian elimination to solve a set of
  162. ' linear equations using double-precision variables.
  163. ' The MATSEQND, MATSEQNS, and MATSEQNC matrix math routines are
  164. ' provided in the Matrix Math Toolbox in Microsoft BASIC 7.00 for
  165. ' MS-DOS and MS OS/2.
  166. '
  167. ' To run this program in the QuickBASIC Extended editor, load the
  168. ' MATBEFR.QLB Quick library as follows:
  169. '
  170. '     QBX /L MATBEFR.QLB
  171. '
  172. ' MATFEFR.QLB and the related .LIB files are documented in the INCLUDE
  173. ' file 'MATB.BI' but NOT in "Microsoft BASIC 7.0: Language Reference."
  174.  
  175. DECLARE FUNCTION MatSEqnD% (A() AS DOUBLE, b() AS DOUBLE)
  176.  
  177. ' The above DECLARE statement is all that is needed from the following
  178. ' include file:   REM $INCLUDE: 'matb.bi'
  179. DEFDBL A-Z
  180. OPTION BASE 1    ' Use OPTION BASE 1 for easier reference.
  181. DIM A(3, 3), b(3)
  182.  
  183. ' The following system of linear equations:
  184. PRINT "       x +   y + 2*z = 9"
  185. PRINT "     2*x + 4*y - 3*z = 1"
  186. PRINT "     3*x + 6*y - 5*z = 0"
  187. ' ...can be represented in the following matrix:
  188. '     1  1  2  9
  189. '     2  4 -3  1
  190. '     3  6 -5  0
  191. ' ...which can be placed in arrays a() and b() respectively as follows:
  192. '     a(1,1)  a(1,2)  a(1,3)  b(1)
  193. '     a(2,1)  a(2,2)  a(2,3)  b(2)
  194. '     a(3,1)  a(3,2)  a(3,3)  b(3)
  195. A(1, 1) = 1
  196. A(1, 2) = 1
  197. A(1, 3) = 2
  198. A(2, 1) = 2
  199. A(2, 2) = 4
  200. A(2, 3) = -3
  201. A(3, 1) = 3
  202. A(3, 2) = 6
  203. A(3, 3) = -5
  204. b(1) = 9
  205. b(2) = 1
  206. b(3) = 0
  207. errcode% = MatSEqnD%(A(), b())
  208. PRINT "The following values for x, y, and z solve all three equations:"
  209. PRINT "x="; b(1)
  210. PRINT "y="; b(2)
  211. PRINT "z="; b(3)
  212.  
  213. ' Here is the output, accurate to within double-precision limits:
  214. '    x= 1.00000000000001
  215. '    y= 2
  216. '    z= 3
  217.  
  218. COPYRIGHT Microsoft Corporation, 1989.
  219. Updated  89/12/14 05:20
  220. _____________________________________________________________________________
  221. Q45170 Using CALL INTERRUPT to Return DOS Version Number
  222. Microsoft QuickBASIC Compiler (QUICKBAS)
  223. 4.00 4.00b 4.50
  224. MS-DOS
  225.  
  226. Summary:
  227.  
  228. The program shown below demonstrates how to use CALL INTERRUPT to
  229. return the DOS version number.
  230.  
  231. This information applies to Microsoft QuickBASIC Versions 4.00, 4.00b,
  232. and 4.50 and to the Microsoft BASIC Compiler Versions 6.00, and 6.00b
  233. for MS-DOS, and to Microsoft BASIC PDS Version 7.00 for MS-DOS.
  234.  
  235. The following program is INTVER.BAS:
  236.  
  237. ' $INCLUDE: 'qb.bi'
  238. ' For BC.EXE and QBX.EXE in BASIC 7.00 the include is 'QBX.BI'
  239.  
  240. DIM inregs AS RegType, outregs AS RegType
  241. inregs.ax = &H3000
  242. CALL INTERRUPT(&H21, inregs, outregs)
  243. majorver = outregs.ax AND &HFF
  244. minorver = (outregs.ax AND &HFF00) / 256
  245. PRINT "MS-DOS Version: "; majorver; "."; minorver
  246.  
  247. Keywords:  B_BasicCom
  248.  
  249. COPYRIGHT Microsoft Corporation, 1989.
  250. Updated  89/12/14 05:20
  251. _____________________________________________________________________________
  252. Q45171 How to Detect Keypress in BASIC without Reading in Character
  253. Microsoft QuickBASIC Compiler (QUICKBAS)
  254. 4.00 4.00b 4.50
  255. MS-DOS
  256.  
  257. Summary:
  258.  
  259. The program shown below demonstrates how to check for a keypress
  260. without reading in the character, thus leaving the character in the
  261. keyboard buffer.
  262.  
  263. This information applies to Microsoft QuickBASIC Versions 4.00, 4.00b,
  264. and 4.50 and to Microsoft BASIC Compiler Versions 6.00, and 6.00b for
  265. MS-DOS, and to Microsoft BASIC PDS Version 7.00 for MS-DOS.
  266.  
  267. More Information:
  268.  
  269. The following program, INTKEY.BAS, uses an MS-DOS interrupt to check
  270. if a key has been pressed. This can be used to check for a keypress
  271. before doing an INPUT, LINE INPUT, or INKEY$ statement. This approach
  272. is an alternative to invoking the INKEY$ function, which takes one
  273. character at a time out of the keyboard buffer.
  274.  
  275. This example uses MS-DOS interrupt 33 (21 hex) with function call 11
  276. (0B hex), "Check Input Status." For more information about MS-DOS
  277. interrupts, please refer to "Advanced MS-DOS Programming" (Second
  278. Edition) by Ray Duncan (published by Microsoft Press, 1988).
  279.  
  280. Example
  281. -------
  282.  
  283. ' $INCLUDE: 'qb.bi'
  284. ' For BC.EXE and QBX.EXE in BASIC 7.00 the include file is 'QBX.BI'
  285.  
  286. DIM inregs AS RegType, outregs AS RegType
  287. inregs.ax = &HB00  ' Move a hex value of B into the AH register
  288. outregs.ax = 0
  289. PRINT "Press any key: "
  290. DO
  291.   CALL INTERRUPT(&H21, inregs, outregs)
  292. LOOP UNTIL (outregs.ax AND &HFF) = &HFF
  293. INPUT X$   ' The first character typed appears in the INPUT line.
  294. ' Or you can PRINT INKEY$ instead of using INPUT X$ to see the
  295. ' character waiting in the keyboard buffer.
  296.  
  297. Keywords:  B_BASICCOM
  298.  
  299. COPYRIGHT Microsoft Corporation, 1989.
  300. Updated  89/12/14 05:20
  301. _____________________________________________________________________________
  302. Q43256 CALL INTERRUPT RegType in Manual Inconsistent with QB.BI File
  303. Microsoft QuickBASIC Compiler (QUICKBAS)
  304. 4.00 4.00b 4.50
  305. MS-DOS
  306.  
  307. Summary:
  308.  
  309. In the following manuals, the RegType (user-defined TYPE) documented
  310. with the CALL INTERRUPT statement is inconsistent with the TYPE in
  311. QB.BI, the $INCLUDE file:
  312.  
  313. 1. Page 90 of the "Microsoft QuickBASIC 4.0: BASIC Language Reference"
  314.    for QuickBASIC Versions 4.00 and 4.00b for MS-DOS and for
  315.    Microsoft BASIC Compiler Versions 6.00 and 6.00b for MS-DOS and MS
  316.    OS/2
  317.  
  318. 2. Page 74 of the "Microsoft QuickBASIC 4.5: BASIC Language
  319.    Reference," which is available for separate purchase after you buy
  320.    QuickBASIC Version 4.50
  321.  
  322. More Information:
  323.  
  324. To correct the inconsistency, remove the following two statements from
  325. the RegType in the manual:
  326.  
  327.    DS AS INTEGER
  328.    ES AS INTEGER
  329.  
  330. The RegType shown in the manual is actually the RegTypeX in the QB.BI
  331. $INCLUDE file.
  332.  
  333. This documentation error has been corrected in Microsoft BASIC PDS
  334. Version 7.00 for MS-DOS and MS OS/2. The TYPE descriptions in the
  335. "Microsoft BASIC 7.0: Language Reference" for RegType and RegTypeX on
  336. Pages 172-173 agree with the TYPE declarations in the QBX.BI $INCLUDE
  337. file supplied with BASIC PDS 7.00.
  338.  
  339. The RegType defined in the QB.BI file (used with $INCLUDE) does not
  340. contain the DS and ES registers. The DS and ES registers are only
  341. needed for the CALL INTERRUPTX statement, which uses RegTypeX.
  342.  
  343. Keywords:  SR# S890406-35 docerr B_BasicCom
  344.  
  345. COPYRIGHT Microsoft Corporation, 1989.
  346. Updated  89/12/15 04:02
  347. _____________________________________________________________________________
  348. Q50943 Using CALL INTERRUPT to Get Current SCREEN Video Mode
  349. Microsoft QuickBASIC Compiler (QUICKBAS)
  350. 4.00 4.00b 4.50
  351. MS-DOS
  352.  
  353. Summary:
  354.  
  355. It is possible to get the current SCREEN mode using the CALL INTERRUPT
  356. statement in compiled BASIC. This is useful if the program does not
  357. keep track of the current SCREEN mode, and the current video state
  358. needs to be saved.
  359.  
  360. This information applies to Microsoft QuickBASIC Versions 4.00, 4.00b,
  361. and 4.50 for MS-DOS, Microsoft BASIC Compiler Versions 6.00, and 6.00b
  362. for MS-DOS, and to Microsoft BASIC PDS Version 7.00 for MS-DOS.
  363.  
  364. More Information:
  365.  
  366. The following BASIC program allows you to change the video mode, then
  367. uses CALL INTERRUPT to return the current video mode. The return
  368. values from the CALL INTERRUPT are not the same as the BASIC SCREEN
  369. modes, so the program creates an array that is used to translate the
  370. returned values back to BASIC SCREEN modes.
  371.  
  372. Code Example: SCRMODE.BAS
  373. -------------------------
  374.  
  375. REM $INCLUDE: 'qb.bi'   ' defines for CALL INTERRUPT
  376. ' For BC.EXE and QBX.EXE for BASIC 7.00, use the include file 'QBX.BI'
  377. ' and the Quick library  QBX.QLB.
  378. DIM inregs AS regtype
  379. DIM outregs AS regtype
  380. DIM screenarray(19) AS INTEGER
  381. FOR i% = 0 TO 19
  382.         READ screenarray(i%)
  383. NEXT
  384. INPUT "enter screen mode: "; smode%
  385. inregs.ax = &HF00       ' BIOS interrupt to return video mode
  386. CALL interrupt(&H10, inregs, outregs)
  387. smode% = outregs.ax AND &HFF   ' mask off contents of AL register
  388. PRINT "Current screen mode = "; screenarray(smode%)
  389. ' Define conversion array for SCREEN modes
  390. DATA 0, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 7, 8, 10, 9, 11, 12, 12
  391. END
  392.  
  393. To demonstrate this program from an .EXE program, compile and link as
  394. follows:
  395.  
  396.    BC SCRMODE.BAS;
  397.    LINK SCRMODE,,,QB.LIB;
  398.  
  399. For BASIC PDS 7.00, use QBX.LIB instead of QB.LIB.
  400.  
  401. If you run the program within the QuickBASIC QB.EXE editor, the
  402. default Quick library QB.QLB must be loaded in, as follows:
  403.  
  404.    QB SCRMODE /L
  405.  
  406. For QBX.EXE 7.00, the default Quick library QBX.QLB must be loaded in,
  407. as follows:
  408.  
  409.    QBX SCRMODE /L
  410.  
  411. Keywords:  SR# S891113-112 B_BasicCom
  412.  
  413. COPYRIGHT Microsoft Corporation, 1989.
  414. Updated  89/12/15 04:02
  415. _____________________________________________________________________________
  416. Q50947 How to Get Extended Error in QuickBASIC Like EXTERR in GWBASIC
  417. Microsoft QuickBASIC Compiler (QUICKBAS)
  418. 4.00 4.00b 4.50
  419. MS-DOS
  420.  
  421. Summary:
  422.  
  423. The EXTERR function found in GW-BASIC Versions 3.20, 3.22, and 3.23 is
  424. not built into QuickBASIC Versions 4.00, 4,00b, 4.50, or earlier, but
  425. below is a code example calling a DOS interrupt that returns the same
  426. information (concerning extended errors in MS-DOS 3.00 and later).
  427.  
  428. This code example applies to Microsoft QuickBASIC Versions 4.00,
  429. 4.00b, and 4.50 for MS-DOS, Microsoft BASIC Compiler Versions 6.00,
  430. and 6.00b for MS-DOS, and to Microsoft BASIC PDS Version 7.00 for
  431. MS-DOS.
  432.  
  433. More Information:
  434.  
  435. The EXTERR function found in GW-BASIC takes a value of n as an
  436. argument and returns a different set of values, depending on the value
  437. of n. This return value gives detailed information on the most recent
  438. DOS error. For all values of n, EXTERR returns 0 (zero) if there was
  439. no previous DOS error, or if the version of DOS is earlier than 3.00.
  440.  
  441.    Value of n        EXTERR(n) Return Value
  442.    ----------        ----------------------
  443.    0                 Extended error code
  444.    1                 Extended error class
  445.    2                 Extended error suggested action
  446.    3                 Extended error locus
  447.  
  448. To find what the error codes returned by EXTERR mean, look up the
  449. values in "Advanced MS-DOS Programming, 2nd Edition" by Ray Duncan
  450. (published by Microsoft Press, 1988) on Pages 145 and 146. This book
  451. also documents the interrupt used below, along with the extended error
  452. codes on Pages 453 through 456.
  453.  
  454. Compile and link with Microsoft QuickBASIC 4.00, 4.00b. and 4.50, or
  455. with Microsoft BASIC Compiler 6.00 and 6.00b as follows:
  456.  
  457.    BC Test.bas;
  458.    LINK Test.bas,,,BRUNxx.Lib+QB.Lib;
  459.  
  460. The "xx" in the library name is for the current version of the product
  461. you are using (40, 41, 45, 60, or 61). For BASIC compiler 6.00 and
  462. 6.00b, use BRUNxxER.LIB (emulation math package) or BRUNxxAR.LIB
  463. (alternate math package). For the alternate math library, you must
  464. compile with the BC /FPa switch. If you compile with BC /O, link with
  465. BCOMxx.LIB instead of BRUNxx.LIB.
  466.  
  467. Also, if you run this program in the QB.EXE environment, you must load
  468. the Quick library QB.QLB as follows:
  469.  
  470.    QB /L QB.QLB
  471.  
  472. For BASIC PDS 7.00, compile and link as follows:
  473.  
  474.    BC Test.bas;
  475.    LINK Test.bas,,,BRT70ENR.Lib+QBX.Lib;
  476.  
  477. The above example is for the math emulation, near strings, and real
  478. mode run-time library. The other posible run-time libraries and their
  479. corresponding compiler switches are as follows:
  480.  
  481. Library Name   Compiler Switches     Comments
  482. ------------   -----------------     --------
  483.  
  484. BRT70ENR.LIB                         Emulation math, near strings
  485. BRT70ANR.LIB        /FPa             Alternate math, near strings
  486. BRT70EFR.LIB        /Fs              Emulation math, far strings
  487. BRT70AFR.LIB        /FPa /Fs         Alternate math, far strings
  488.  
  489. To use stand-alone libraries, use BCL70xxx.LIB instead of
  490. BRT70xxx.LIB, and you must add the compiler switch BC /O.
  491.  
  492. For the QBX.EXE 7.00 environment, use QBX.QLB as follows:
  493.  
  494.    QBX /L QBX.QLB
  495.  
  496. Code Example
  497. ------------
  498.  
  499. REM $INCLUDE: 'QB.BI'
  500. ' For BC.EXE and QBX.EXE in BASIC 7.00, use the include file 'QBX.BI'
  501.  
  502. DIM Inregs AS RegTypeX, Outregs AS RegTypeX
  503. CLS
  504. INPUT "Enter the filename "; test$
  505. test$ = test$ + CHR$(0)
  506. Inregs.ax = &H3D00
  507. Inregs.ds = VARSEG(test$)
  508. ' For BASIC Compiler 7.00 and QBX.EXE use SSEG(test$)
  509. '     instead of VARSEG(test$)
  510.  
  511. Inregs.dx = SADD(test$)
  512. CALL INTERRUPTX(&H21, inregs, outregs)
  513. check = outregs.flags AND &H1
  514. IF check = 1 THEN
  515.    PRINT "The file was not found"
  516.    Inregs.ax = &H5900
  517.    Inregs.bx = inregs.bx AND &HFF
  518.    CALL INTERRUPTX(&H21, Inregs, Outregs)
  519.    PRINT "This is the error number"; Outregs.ax
  520. ELSE
  521.   PRINT "Your file was found, no extended error information is needed"
  522. END IF
  523. END
  524.  
  525.  
  526. Keywords:  SR# S891107-92 B_BasicCom B_GWBasicI
  527.  
  528. COPYRIGHT Microsoft Corporation, 1989.
  529. Updated  89/12/15 04:02
  530. _____________________________________________________________________________
  531. Q40886 PUT Statement Correction, Page 342 QB Language Reference
  532. Microsoft QuickBASIC Compiler (QUICKBAS)
  533. 4.00 4.00b
  534. MS-DOS
  535.  
  536. Summary:
  537.  
  538. Page 342 of the "Microsoft QuickBASIC: BASIC Language Reference"
  539. manual for Versions 4.00 and 4.00b and the "Microsoft BASIC 6.0
  540. Compiler: BASIC Language Reference" manual for Versions 6.00 and
  541. 6.00b, ("PUT Statement - File I/O") incorrectly states the following:
  542.  
  543.    ...characters in the string's value. For example,
  544.     the following two statements write 15 bytes to file
  545.     number 1:
  546.  
  547.     VarString$=STRING$ (15, "X")
  548.     GET #1,,VarString$
  549.  
  550. The GET should be changed to PUT as follows:
  551.  
  552.     VarString$=STRING$ (15, "X")
  553.     PUT #1,,VarString$
  554.  
  555. This documentation error was corrected in the QuickBASIC Version 4.50
  556. QB Advisor on-line Help system and in the "Microsoft QuickBASIC 4.5:
  557. BASIC Language Reference" manual for Version 4.50 and in the
  558. "Microsoft BASIC 7.0: Language Reference" manual for Microsoft BASIC
  559. PDS Version 7.00 for MS-DOS and MS OS/2.
  560.  
  561. Keywords:  B_BasicCom docerr
  562.  
  563. COPYRIGHT Microsoft Corporation, 1989.
  564. Updated  89/12/16 04:03
  565. _____________________________________________________________________________
  566. Q41389 SIGNAL Is BASIC Reserved Word; SIGNAL ON Usable Only in OS/2
  567. Microsoft QuickBASIC Compiler (QUICKBAS)
  568. 4.00 4.00b 4.50
  569. MS-DOS
  570.  
  571. Summary:
  572.  
  573. The ON SIGNAL(n) GOSUB and SIGNAL ON statements are implemented only
  574. in OS/2 protected mode for programs compiled with BC.EXE in Microsoft
  575. BASIC Compiler Versions 6.00 and 6.00b or Microsoft BASIC PDS Version
  576. 7.00.
  577.  
  578. SIGNAL is a reserved word in QuickBASIC Versions 4.00, 4.00b, and
  579. 4.50, Microsoft BASIC Compiler Versions 6.00 and 6.00b, and Microsoft
  580. BASIC PDS Version 7.00. However, the SIGNAL statements will be
  581. accepted only by BASIC compiler 6.00 and 6.00b and BASIC PDS 7.00 when
  582. compiling in protected mode under OS/2. In all other situations, a
  583. SIGNAL statement results in an "Advanced feature unavailable" error
  584. message.
  585.  
  586. More Information:
  587.  
  588. The BC.EXE compiler that comes with BASIC compiler 6.00 and 6.00b and
  589. BASIC PDS 7.00 supports the ON SIGNAL(n) GOSUB and SIGNAL ON
  590. statements, as documented in Section 5 (Pages 27-29) of "Microsoft
  591. BASIC Compiler 6.0: User's Guide" for Versions 6.00 and 6.00b for MS
  592. OS/2 and MS-DOS and the "Microsoft BASIC 7.0: Language Reference"
  593. manual on Pages 341-342.
  594.  
  595. Below is an example of the correct use of the ON SIGNAL(n) GOSUB and
  596. SIGNAL ON statements. This program is supported only if you compile in
  597. OS/2 protected mode with BC.EXE from Microsoft BASIC Compiler Version
  598. 6.00 or 6.00b, or Microsoft BASIC PDS Version 7.00, and run the
  599. resulting executable in protected mode:
  600.  
  601.    PRINT "This program traps CTRL+BREAK in OS/2. Try it."
  602.    ON SIGNAL(4) GOSUB trap
  603.    SIGNAL(4) ON
  604.    10 a$ = INKEY$
  605.    IF a$ = "" THEN GOTO 10
  606.    END
  607.    trap:
  608.      PRINT "CTRL+BREAK trapped. Press any key to quit"
  609.      RETURN
  610.  
  611. The above program always reports "Advanced feature unavailable" when
  612. run in real mode (DOS) as a compiled executable or when run inside the
  613. QuickBASIC QB.EXE or the BASIC PDS 7.00 QBX.EXE environments.
  614.  
  615. Keywords:  B_BasicCom SR# S890125-25
  616.  
  617. COPYRIGHT Microsoft Corporation, 1989.
  618. Updated  89/12/16 04:03
  619. _____________________________________________________________________________
  620. Q43252 Must DECLARE a FUNCTION Invoked from an External Library
  621. Microsoft QuickBASIC Compiler (QUICKBAS)
  622. 4.00 4.00b 4.50
  623. MS-DOS
  624.  
  625. Summary:
  626.  
  627. To use a FUNCTION that is in a library (.LIB) or Quick Library (.QLB),
  628. you must have a DECLARE statement at the top of each module that uses
  629. the FUNCTION. This is documented in the "Microsoft QuickBASIC 4.0:
  630. BASIC Language Reference" manual for Versions 4.00 and 4.00b, Page
  631. 139, and the QuickBASIC 4.50 on-line QB Advisor by choosing <Help>
  632. <Index> DECLARE Statement (BASIC Procedures) <Details> and in the
  633. "Microsoft BASIC 7.0: Programmer's Guide" on Page 53.
  634.  
  635. The documentation states that you must use DECLARE if you invoke a
  636. FUNCTION that is defined in another module. Library files (.LIB and
  637. .QLB) are "other modules," as are SUBprogram or FUNCTION modules
  638. that start from a separate .BAS or MS-DOS file.
  639.  
  640. This information applies to Microsoft QuickBASIC Versions 4.00, 4.00b,
  641. and 4.50 for MS-DOS, to Microsoft BASIC Compiler Versions 6.00 and
  642. 6.00b for MS-DOS and MS OS/2, and to Microsoft BASIC PDS Version 7.00
  643. for MS-DOS and MS OS/2.
  644.  
  645. More Information:
  646.  
  647. There are two reasons that DECLAREs are necessary for FUNCTIONs and
  648. not for SUBprograms.
  649.  
  650. 1. The only way to identify a SUBprogram without a DECLARE is with a
  651.    CALL. You cannot use CALL with a FUNCTION because a FUNCTION
  652.    returns a value and must be used in an assignment statement.
  653.  
  654. 2. Without the DECLARE, the compiler cannot know if you are referring
  655.    to a variable, array, or FUNCTION.
  656.  
  657. Consider the following BASIC statements:
  658.  
  659.    'Is this a FUNCTION call or assignment of a variable?
  660.    VAR1# = Func1#
  661.  
  662.    ' Is this a FUNCTION call or is this assigning
  663.    ' an array element to a variable?
  664.    VAR1# = Func1#(VAR2,VAR3)
  665.  
  666. The DECLARE FUNCTION Func1#(<variables>) statement tells the compiler
  667. that you are using a FUNCTION when you use the name Func1# and that
  668. this is not a variable or an array.
  669.  
  670. Keywords:  SR# S890405-127 B_BasicCom
  671.  
  672. COPYRIGHT Microsoft Corporation, 1989.
  673. Updated  89/12/16 04:03
  674. _____________________________________________________________________________
  675. Q44035 WAIT Statement Can Access All 65535 Ports, Not Just 0 to 255
  676. Microsoft QuickBASIC Compiler (QUICKBAS)
  677. 2.00 2.01 3.00 4.00 4.00b 4.50
  678. MS-DOS
  679.  
  680. Summary:
  681.  
  682. The documentation for the WAIT statement incorrectly states that the
  683. input port number given as an argument to a WAIT statement can range
  684. from 0 to 255 only. WAIT can actually address all 65,536 machine ports
  685. (0 to 65535).
  686.  
  687. This information applies to the WAIT statement in the following
  688. manuals:
  689.  
  690. 1. Page 446 of "Microsoft QuickBASIC 4.0: BASIC Language Reference"
  691.    for Versions 4.00 and 4.00b for MS-DOS
  692.  
  693. 2. Page 446 of "Microsoft BASIC Compiler 6.0: BASIC Language
  694.    Reference" for Versions 6.00 and 6.00b for MS-DOS and MS OS/2
  695.  
  696. 3. Page 507 of "Microsoft QuickBASIC Compiler" manual for Versions
  697.    2.0x and 3.00 for MS-DOS
  698.  
  699. This documentation error has been corrected in the "Microsoft BASIC
  700. 7.0: Language Reference" manual and in the Microsoft BASIC PDS 7.00
  701. QBX.EXE Microsoft Advisor on-line Help system.
  702.  
  703. Keywords:  B_BasicCom docerr
  704.  
  705. COPYRIGHT Microsoft Corporation, 1989.
  706. Updated  89/12/16 04:03
  707. _____________________________________________________________________________
  708. Q48059 "String Space Corrupt" If BSAVE Variable-Length-String Array
  709. Microsoft QuickBASIC Compiler (QUICKBAS)
  710. 1.00 1.01 1.02 2.00 2.01 3.00 4.00 4.00b 4.50
  711. MS-DOS
  712.  
  713. Summary:
  714.  
  715. If you want to use BSAVE and BLOAD with string arrays, you must use an
  716. array of fixed-length strings. Fixed-length strings are available in
  717. Microsoft QuickBASIC Versions 4.00, 4.00b, and 4.50 for MS-DOS, in
  718. Microsoft BASIC Compiler Versions 6.00 and 6.00b for MS-DOS, and in
  719. Microsoft BASIC PDS Version 7.00, but not in earlier versions.
  720.  
  721. Arrays of variable-length strings CANNOT be BSAVEd to a file, nor can
  722. a file that was BSAVEd from a variable-length-string array be BLOADed
  723. into another variable-length-string array. A "String space corrupt"
  724. error message can display if you attempt to BLOAD a file into a
  725. variable-length-string array, because the pointers in the BSAVEd
  726. string descriptors will overlay and tangle existing pointers to string
  727. space. This is the same mistake as POKEing a spurious value into a
  728. string descriptor, which can corrupt the integrity of string space.
  729.  
  730. This information applies to Microsoft QuickBASIC Versions 1.00, 1.01,
  731. 1.02, 2.00, 2.01, 3.00, 4.00, 4.00b, and 4.50 for MS-DOS, to Microsoft
  732. BASIC Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2, and to
  733. Microsoft BASIC PDS Version 7.00 for MS-DOS and MS OS/2.
  734.  
  735. More Information:
  736.  
  737. Each element of variable-length-string array has a 4-byte string
  738. descriptor composed of an offset (a 2-byte pointer) and length field
  739. (2 bytes). The array of string descriptors is stored sequentially, but
  740. the actual contents of the strings are stored separately in the
  741. dynamic string space. Each 2-byte offset points to a location in the
  742. string space. The string space memory is very dynamic, and strings are
  743. given new offsets whenever new string values are reassigned. The
  744. string contents of an array are not usually adjacent, especially if
  745. they have been reassigned values. As a result, BSAVEing a certain
  746. number of bytes does not mean that you've BSAVEd the contents of the
  747. variable-length-string array.
  748.  
  749. The following code example attempts to BSAVE a variable-length-string
  750. array, but generates the error "String Space Corrupt" when run within
  751. the QuickBASIC QB.EXE Version 4.00, 4.00b, or 4.50 environment.
  752.  
  753. To work around this situation, create fixed-length-string arrays and
  754. BSAVE that information. Fixed-length-string space is allocated
  755. statically and sequentially in memory, and can be BSAVEd and BLOADed.
  756.  
  757. Code Example
  758. ------------
  759.  
  760. This example requires Microsoft QuickBASIC Version 4.00, 4.00b, or
  761. 4.50 for MS-DOS, Microsoft BASIC Compiler Version 6.00 or 6.00b for
  762. MS-DOS, or Microsoft BASIC PDS Version 7.00 for MS-DOS.
  763.  
  764. To alter this program to work correctly, change the DIMension
  765. statements to create a fixed-length-string array and BSAVE just that
  766. many bytes.
  767.  
  768. OPTION BASE 1
  769. DIM Arr1$(10)   ' Instead, use DIM Arr1(10) AS STRING*20
  770. DIM Arr2$(10)   ' Instead, use DIM Arr2(10) AS STRING*20
  771. StrDesc% = 4
  772. ArrayLength% = 0
  773. PRINT "This is the BSAVE array:"
  774. PRINT
  775. FOR I = 1 TO 10
  776.    Arr1$(I) = "TEST" + STR$(I)
  777.    ArrayLength% = ArrayLength% + LEN(Arr1$(I))
  778.    PRINT Arr1$(I)
  779. NEXT I
  780.  
  781. DEF SEG = VARSEG(Arr1$(1))
  782. ' In BC.EXE and QBX.EXE for BASIC 7.00 use SSEG for far variable
  783. ' length strings.
  784.  
  785. BSAVE "Test.Dat", VARPTR(Arr1$(1)), ArrayLength% + StrDesc%
  786. DEF SEG
  787. PRINT
  788. PRINT "Hit a Key"
  789. PRINT
  790. SLEEP
  791. DEF SEG = VARSEG(Arr2$(1))
  792. ' In BC.EXE and QBX.EXE for BASIC 7.00 use SSEG for far variable
  793. ' length strings.
  794.  
  795. BLOAD "Test.Dat", VARPTR(Arr2$(1))
  796. DEF SEG
  797. PRINT "This is the BLOADed array:"
  798. PRINT
  799. FOR I = 1 TO 10
  800.    PRINT Arr2$(I)
  801. NEXT I
  802.  
  803. Keywords:  SR# S890724-71 B_BasicCom
  804.  
  805. COPYRIGHT Microsoft Corporation, 1989.
  806. Updated  89/12/16 04:03
  807. _____________________________________________________________________________
  808. Q47753 List of Run-Time Error Numbers and Messages for QuickBASIC
  809. Microsoft QuickBASIC Compiler (QUICKBAS)
  810. 1.00 1.01 1.02 2.00 2.01 3.00 4.00 4.00b 4.50
  811. MS-DOS
  812.  
  813. Summary:
  814.  
  815. This article contains a complete list of run-time errors and their
  816. corresponding numbers (returned by the ERR function). These errors can
  817. be trapped with the ON ERROR GOTO statement.
  818.  
  819. This information applies to Microsoft QuickBASIC Versions 1.00, 1.01,
  820. 1.02, 2.00, 2.01, 3.00, 4.00, 4.00b, and 4.50 for MS-DOS, to Microsoft
  821. BASIC Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2, and to
  822. Microsoft BASIC PDS Version 7.00 for MS-DOS and MS OS/2.
  823.  
  824. More Information:
  825.  
  826.    Error                              Error
  827.    Code   Description                 Code   Description
  828.    -----  -----------                 -----  -----------
  829.  
  830.     1*    NEXT without FOR            37*    Argument-count mismatch
  831.     2*    SYNTAX error                38*    Array not defined
  832.     3     RETURN without GOSUB        39**   CASE ELSE expected
  833.     4     Out of DATA                 40     Variable required
  834.     5     Illegal function call       50     Field Overflow
  835.     6     Overflow                    51     Internal Error
  836.     7     Out of memory               52     Bad file name or number
  837.     8     Label not defined           53     File not found
  838.     9     Subscript out of range      54     Bad file mode
  839.    10     Duplicate definition        55     File already open
  840.    11     Division by zero            56     FIELD statement active
  841.    12*    Illegal in direct mode      57     Device I/O error
  842.    13*    Type mismatch               58     File already exists
  843.    14     Out of string space         59     Bad record length
  844.    16*    String formula too complex  61     Disk Full
  845.    17*    Cannot continue             62     Input past end-of-file
  846.    18     Function not defined        63     Bad record number
  847.    19     No RESUME                   64     Bad file name
  848.    20     RESUME without error        67     Too many files
  849.    24     Device timeout              68     Device Unavailable
  850.    25     Device Fault                69     Communications-buffer overflow
  851.    26*    FOR without NEXT            70     Permission denied
  852.    27     Out of paper                71     Disk not ready
  853.    29*    WHILE without WEND          72     Disk-media error
  854.    30*    WEND without WHILE          73     Advanced feature unavailable
  855.    33*    Duplicate LABEL             74     Rename across disks
  856.    35*    Subprogram not defined      75     Path/file access error
  857.                                       76     Path not found
  858.  
  859.    *   Denotes errors that usually occur at COMPILE TIME, but may
  860.        occur and be trapped during RUN TIME under special circumstances
  861.  
  862.    **  Denotes that the error number was removed in BASIC PDS 7.00
  863.  
  864. The following errors appear in Microsoft BASIC PDS Version 7.00 only:
  865.  
  866.    80     Feature removed
  867.    81     Invalid name
  868.    82     Table not found
  869.    83     Index not found
  870.    84     Invalid column
  871.    85     No current record
  872.    86     Duplicate value for unique index
  873.    87     Invalid operation on null index
  874.    88     Database needs repair
  875.  
  876. The following undefined error numbers produce an "Unprintable error"
  877. message if they are not trapped with the ON ERROR GOTO statement:
  878.  
  879.    15, 21, 22, 23, 28, 31, 32, 34, 41-49, 60, 65, 66, 77, and upwards
  880.  
  881. For Microsoft BASIC PDS 7.00, the numbers that generate the
  882. "Unprintable error" message are as follows:
  883.  
  884.    15 ,21, 22, 23, 28, 31, 32, 34, 39, 41-49, 60, 65, 66, 77-79, 89
  885.    and upwards
  886.  
  887. For a more detailed explanation of the above errors, please consult
  888. your language reference manual for BASIC or QuickBASIC, or your
  889. "Microsoft QuickBASIC 4.5: Programming in BASIC" manual for Version
  890. 4.50, Appendix I, or the QB Advisor on-line Help system for QuickBASIC
  891. Version 4.50, or your "Microsoft BASIC 7.0: Language Reference" manual
  892. for BASIC PDS 7.00, Appendix D, or the Microsoft Advisor on-line Help
  893. system for BASIC PDS Version 7.00.
  894.  
  895. You can invoke any error in the QB.EXE or QBX.EXE environment with the
  896. ERROR statement. In QB.EXE 4.50 or QBX.EXE 7.00, the ERROR statement
  897. displays the error message with the choice to receive Help on the
  898. error. Choosing Help gives a brief explanation and some key points to
  899. consider when tracking down the cause of the error.
  900.  
  901. Keywords:  B_BasicCom SR# S890720-59
  902.  
  903. COPYRIGHT Microsoft Corporation, 1989.
  904. Updated  89/12/19 06:13
  905. _____________________________________________________________________________
  906. Q44492 Mandelbrot Example Needs to Change "LogicY" to a SINGLE
  907. Microsoft QuickBASIC Compiler (QUICKBAS)
  908. 4.00 4.00b 4.50
  909. MS-DOS
  910.  
  911. Summary:
  912.  
  913. The MANDEL.BAS program example on Pages 213-217 of the "Microsoft
  914. QuickBASIC 4.5: Programming in BASIC" manual for Version 4.50, on
  915. Pages 263-267 of the "Microsoft QuickBASIC 4.0: Programming in BASIC:
  916. Selected Topics" manual for Versions 4.00 and 4.00b, and on Pages
  917. 211-215 of the "Microsoft BASIC 7.0: Programmer's Guide" for Microsoft
  918. BASIC PDS Version 7.00 does not work correctly for all WINDOW
  919. coordinates, unless the variable "LogicY" is changed to a SINGLE or
  920. DOUBLE precision variable.
  921.  
  922. To correct the problem, change all occurrences of LogicY to LogicY! or
  923. add the following line to the beginning of the program:
  924.  
  925.    DIM LogicY AS SINGLE
  926.  
  927. This information applies to QuickBASIC Versions 4.00, 4.00b, and 4.50
  928. for MS-DOS, to Microsoft BASIC Compiler Versions 6.00 and 6.00b for
  929. MS-DOS and MS OS/2, and to Microsoft BASIC PDS Version 7.00 for MS-DOS
  930. and MS OS/2.
  931.  
  932. For more information, query on the following words in this
  933. Knowledge Base:
  934.  
  935.    PMAP and MAP and WINDOW and INTEGER
  936.  
  937. Keywords:  B_BasicCom docerr
  938.  
  939. COPYRIGHT Microsoft Corporation, 1989.
  940. Updated  89/12/21 04:37
  941. _____________________________________________________________________________
  942. Q44494 QuickBASIC 4.50 Arrays Can Have 60 Elements, Not Just 8
  943. Microsoft QuickBASIC Compiler (QUICKBAS)
  944. 4.50
  945. MS-DOS
  946.  
  947. Summary:
  948.  
  949. Appendix C, "Limits of QuickBASIC," on Page 337 of the "Microsoft
  950. QuickBASIC 4.5: Programming in BASIC" manual for Version 4.50 and the
  951. QuickBASIC Advisor on-line Help system incorrectly state that there
  952. is a limit of 8 dimensions for arrays. The actual limit is 60.
  953.  
  954. Appendix C and the on-line Help system should read as follows:
  955.  
  956.    Arrays                        Maximum             Minimum
  957.    -----------------------------------------------------------------
  958.    Array Dimensions                60                   1
  959.  
  960. This information was not included in the documentation for earlier
  961. versions of QuickBASIC or Microsoft BASIC compiler.
  962.  
  963. This documentation error has been corrected in the "Microsoft BASIC
  964. 7.0: Programmer's Guide" for Microsoft BASIC PDS Version 7.00 and in
  965. the Microsoft Advisor on-line Help system of the QBX.EXE environment
  966. in Microsoft BASIC PDS 7.00.
  967.  
  968. Keywords:  SR# S890423-1 docerr
  969.  
  970. COPYRIGHT Microsoft Corporation, 1989.
  971. Updated  89/12/21 04:37
  972. _____________________________________________________________________________
  973. Q45483 Incorrect Number of Parameters to Quick Library Can Hang QB
  974. Microsoft QuickBASIC Compiler (QUICKBAS)
  975. 4.00 4.00b 4.50
  976. MS-DOS
  977.  
  978. Summary:
  979.  
  980. When using FUNCTIONs or SUBprograms that are located in a Quick
  981. library under QuickBASIC Versions 4.00, 4.00b, and 4.50 and under
  982. QuickBASIC Extended in BASIC PDS Version 7.00, it is important to
  983. DECLARE all Quick library routines that your program will be CALLing.
  984. If fewer parameters than expected are passed to a SUBprogram in a
  985. Quick library, your machine may hang, sometimes requiring the power to
  986. be cycled to reboot the machine. This problem occurs only within the
  987. environment and only when CALLing a Quick library routine.
  988.  
  989. If the program is CALLing a routine in another module that is loaded
  990. into the QB.EXE environment, the expected error of "Argument count
  991. mismatch" displays. When compiled to an EXE file, the error "Illegal
  992. function call" displays.
  993.  
  994. Microsoft does not consider this to be a problem with QuickBASIC or
  995. QBX.EXE of any version. The environment cannot perform parameter
  996. checking without a DECLARE statement for each SUB or FUNCTION.
  997. Therefore a DECLARE statement is required for each routine in a Quick
  998. library in order for a program to function normally.
  999.  
  1000. More Information:
  1001.  
  1002. If SUBprograms are not DECLAREd at the top of the module that makes
  1003. the calls, the SUBroutine must be CALLed. If you have a DECLARE SUB
  1004. for that SUBroutine, you need only to mention the SUBprograms followed
  1005. by any expected parameters.
  1006.  
  1007. When using FUNCTIONs, whether in another module or a Quick library,
  1008. the FUNCTION must be DECLAREd at the top of the calling module. If the
  1009. FUNCTION is not DECLAREd, the QuickBASIC environment interprets the
  1010. FUNCTION as an array.
  1011.  
  1012. For more information on SUBprograms and FUNCTIONs, consult Chapter 2
  1013. of the "Microsoft QuickBASIC 4.5: Programming in BASIC" manual for
  1014. Microsoft QuickBASIC Version 4.50 or Chapter 2 of the "Microsoft BASIC
  1015. 7.0: Programmer's Guide" for Microsoft BASIC PDS Version 7.00.
  1016.  
  1017. The code example below illustrates the necessity of the DECLARE
  1018. statement. If the FUNCTION and SUBroutine are combined into a Quick
  1019. library and only one of the arguments is passed to the SUBprogram, the
  1020. computer hangs. If both arguments are passed, it executes as expected.
  1021. If the DECLARE FUNCTION is removed, a "Subscript out of range" is
  1022. generated when the FUNCTION is referenced.
  1023.  
  1024. Code Example
  1025. ------------
  1026.  
  1027. Main Program
  1028. ------------
  1029.  
  1030. DECLARE FUNCTION calculatesomething%(t AS INTEGER)
  1031. DEFINT A-Z
  1032. t = 100
  1033. x = 100                     'to hang machine, change CALL statement to:
  1034. CALL printhello(t, x)       'CALL printhello(t)
  1035. a = calculatesomething(t)
  1036. PRINT a
  1037.  
  1038. Quick Library Routines
  1039. ----------------------
  1040.  
  1041. SUB printhello(t AS INTEGER, x AS INTEGER)
  1042.     PRINT "Hello from the SUBprogram: "; t, x
  1043. END SUB
  1044.  
  1045. FUNCTION calculatesomething%(t AS INTEGER)
  1046.     calculatesomething% = t + t * t
  1047. END FUNCTION
  1048.  
  1049. Keywords:  SR# S890525-13
  1050.  
  1051. COPYRIGHT Microsoft Corporation, 1989.
  1052. Updated  89/12/21 04:37
  1053. _____________________________________________________________________________
  1054. Q46848 TAB Function Documentation Error in QuickBASIC 4.50 Manual
  1055. Microsoft QuickBASIC Compiler (QUICKBAS)
  1056. 4.50
  1057. MS-DOS
  1058.  
  1059. Summary:
  1060.  
  1061. The example for the TAB function on Page 369 of the "Microsoft
  1062. QuickBASIC 4.5: BASIC Language Reference" for Version 4.50 is
  1063. incorrect. The output for the first display is in Column 1 when it
  1064. should be in Column 7.
  1065.  
  1066. This is not an error in the following:
  1067.  
  1068. 1. The on-line help for the QuickBASIC 4.50 environment
  1069.  
  1070. 2. The on-line help for the BASIC PDS 7.00 QuickBASIC Extended
  1071.    environment
  1072.  
  1073. 3. The "Microsoft BASIC Compiler 6.0: BASIC Language Reference" for
  1074.    Versions 6.00 and 6.00b for MS OS/2 and MS-DOS
  1075.  
  1076. 4. The "Microsoft BASIC 7.0: BASIC Language Reference" manual for
  1077.    Version 7.00
  1078.  
  1079. 5. The "Microsoft QuickBASIC 4.0: BASIC Language Reference" manual for
  1080.    Versions 4.00 and 4.00b
  1081.  
  1082. The output on Page 369 should correctly show
  1083.  
  1084.        one
  1085.                two
  1086. three
  1087. 0123456789012345678901234567890
  1088.                     four
  1089.  
  1090. to correspond to the code given for the TAB function.
  1091.  
  1092. Keywords:  SR# S890627-141 docerr
  1093.  
  1094. COPYRIGHT Microsoft Corporation, 1989.
  1095. Updated  89/12/21 04:37
  1096. _____________________________________________________________________________
  1097. Q31882 DATA Statements Not Allowed in SUB or FUNCTION Procedures
  1098. Microsoft QuickBASIC Compiler (QUICKBAS)
  1099. 4.00 4.00b 4.50
  1100. MS-DOS
  1101.  
  1102. Summary:
  1103.  
  1104. The DATA statement should be included in the list of statements
  1105. prohibited in procedure-level code on Page 50 of the following
  1106. manuals
  1107.  
  1108. 1. "Microsoft QuickBASIC 4.0: Programming in BASIC: Selected Topics"
  1109.  
  1110. 2. "Microsoft BASIC Compiler 6.0: Programming in BASIC: Selected
  1111.     Topics"
  1112.  
  1113. 3.  Page 41 of the "Microsoft BASIC 7.0: Programmer's Guide"
  1114.     manual.
  1115.  
  1116. More Information:
  1117.  
  1118. The DATA statement documentation on Page 135 in the BASIC language
  1119. reference manual correctly states that "DATA statements can only be
  1120. entered in the module-level code."
  1121.  
  1122. A module is defined as an individual source file, but "module level"
  1123. is a special term with a different meaning. The glossary on Page 350
  1124. of the "Microsoft QuickBASIC 4.0: Learning and Using QuickBASIC"
  1125. manual defines "module-level code" as follows:
  1126.  
  1127.    (Module-level code is defined as) program statements within any
  1128.    module that are outside a SUB or FUNCTION definition. Error- or
  1129.    event-handling code and declarative statements such as COMMON,
  1130.    DECLARE, and TYPE can appear only at the module level.
  1131.  
  1132. Keywords:  docerr B_BasicCom
  1133.  
  1134. COPYRIGHT Microsoft Corporation, 1989.
  1135. Updated  89/12/22 04:23
  1136. _____________________________________________________________________________
  1137. Q32789 Correction for COMMAND$ Function Example in Manual
  1138. Microsoft QuickBASIC Compiler (QUICKBAS)
  1139. 4.00 4.00b 4.50
  1140. MS-DOS
  1141.  
  1142. Summary:
  1143.  
  1144. The correction below applies to the example program for the COMMAND$
  1145. function on Page 114 of the following manuals:
  1146.  
  1147. 1. "Microsoft QuickBASIC 4.0: BASIC Language Reference"
  1148.  
  1149. 2. "Microsoft BASIC Compiler 6.0: BASIC Language Reference"
  1150.  
  1151. On Page 114, the SUB statement on line seven incorrectly reads as
  1152. follows:
  1153.  
  1154.    SUB Comline(NumArgs, Args$(1), MaxArgs) STATIC
  1155.  
  1156. This line should read as follows:
  1157.  
  1158.    SUB Comline(NumArgs, Args$(), MaxArgs) STATIC
  1159.  
  1160. In brief, replace Args$(1) in the first statement with Args$().
  1161.  
  1162. This information also applies to the example program on Page 61 of the
  1163. "Microsoft BASIC 7.0: Language Reference" manual which comes with
  1164. Microsoft BASIC PDS Version 7.00.
  1165.  
  1166. On Page 61, the SUB statement on line five incorrectly reads as
  1167. follows:
  1168.  
  1169.    SUB Comline(NumArgs,Args$,MaxArgs) STATIC
  1170.  
  1171. This line should read as follows:
  1172.  
  1173.    SUB Comline(NumArgs,Args$(),MaxArgs) STATIC
  1174.  
  1175. Keywords:  docerr B_BasicCom
  1176.  
  1177. COPYRIGHT Microsoft Corporation, 1989.
  1178. Updated  89/12/22 04:23
  1179. _____________________________________________________________________________
  1180. Q40371 Using Medium and Large Memory FORTRAN Models with BASIC
  1181. Microsoft QuickBASIC Compiler (QUICKBAS)
  1182. 4.50
  1183. MS-DOS
  1184.  
  1185. Summary:
  1186.  
  1187. The information below applies to QuickBASIC Versions 4.00, 4.00b, and
  1188. 4.50, and Microsoft BASIC Compiler Versions 6.00 and 6.00b for MS-DOS
  1189. and OS/2.
  1190.  
  1191. This information also applies to Microsoft BASIC PDS Version 7.00 for
  1192. MS-DOS and MS OS/2, but only when using near strings. (For more
  1193. information on using far strings in mixed-language programs, please
  1194. refer to Chapter 13, "Mixed Language Programming with Far Strings," in
  1195. the "Microsoft BASIC 7.0: Programmer's Guide." Note that far strings
  1196. are only available with BASIC PDS 7.00.)
  1197.  
  1198. Variables in a FORTRAN subroutine may be specified as being [NEAR] or
  1199. [FAR]. Likewise, QuickBASIC can pass parameters to a subroutine by
  1200. near or far reference. When parameters are passed as near and the
  1201. FORTRAN subroutine is compiled under the medium memory model or the
  1202. parameters are passed as far and the subroutine is compiled with the
  1203. large memory model option, the variables are passed correctly.
  1204.  
  1205. More Information:
  1206.  
  1207. The run-time error message "F2729 I/O item illegal in namelist I/O" is
  1208. reported if you try to use far pointers while compiling in the
  1209. medium memory model.
  1210.  
  1211. Example 1 below demonstrates a program that performs correctly when
  1212. near parameters are used and the FORTRAN subroutine is compiled using
  1213. the medium model (FL /AM) option. The parameters are passed
  1214. incorrectly when the FORTRAN subroutine in Example 1 is compiled with
  1215. the large model (FL /AL) option.
  1216.  
  1217. Example 2 is the equivalent program using the far option. Example 2
  1218. performs correctly when the FORTRAN subroutine is compiled with the
  1219. large model option.
  1220.  
  1221. The following is Example 1, which uses the medium memory model:
  1222.  
  1223.    Compile in BASIC as follows:     BC basprog/o;
  1224.    Compile in FORTRAN as follows:   fl /AM /APi /c forsub.for
  1225.    Link as follows:                 LINK basprog forsub/noe;
  1226.  
  1227. The following BASIC program is BASPROG.BAS:
  1228.  
  1229. DECLARE FUNCTION MAKEIT$(S$,SIZE%)
  1230. DECLARE SUB DUM1(BYVAL S1%, BYVAL S2%, BYVAL S3%, BYVAL S4%)
  1231. DIM NAM%(3000)
  1232. COMMON /NMALLOC/ NAM%()
  1233. STR1$ = MAKEIT ("TEST OF PARAMETER VALUE PASSING" ,44)
  1234. STR2$ = MAKEIT ( "STRING 2" ,43)
  1235. STR3$ = MAKEIT ("STRING 3", 14)
  1236. STR4$ = MAKEIT ("STRING 4" ,14)
  1237. CALL DUM1(SADD(STR1$), SADD(STR2$), SADD(STR3$), SADD(STR4$))
  1238. END
  1239. FUNCTION MAKEIT$ (S$,SIZE%)
  1240.    MAKEIT$ = LEFT$(S$+STRING$(80, 32),SIZE%)
  1241. END FUNCTION
  1242.  
  1243. The following FORTRAN program is FORSUB.FOR:
  1244.  
  1245.       SUBROUTINE DUM1(STR1, STR2, STR3, STR4)
  1246.       CHARACTER*14 STR3, STR4 [NEAR]
  1247.       CHARACTER*43 STR1 [NEAR]
  1248.       CHARACTER*44 STR2 [NEAR]
  1249.       WRITE (*,*) STR1, STR2, STR3, STR4
  1250.       END
  1251.  
  1252. The following is Example 2, which uses the large memory model:
  1253.  
  1254. Compile in BASIC as follows:    BC basprog/o;
  1255. Compile in FORTRAN as follows:  fl /AL /FPi /c forsub.for
  1256. Link as follows:                LINK basprog forsub/noe;
  1257.  
  1258. The following BASIC program is BASPROG.BAS:
  1259.  
  1260. DECLARE FUNCTION MAKEIT$(S$,SIZE%)
  1261. DECLARE SUB DUM1(BYVAL S1%, BYVAL S2%, BYVAL S3%, BYVAL S4%,_
  1262.                  BYVAL S5%, BYVAL S6%, BYVAL S7%, BYVAL S8%)
  1263. DIM NAM%(3000)
  1264. COMMON /NMALLOC/ NAM%()
  1265. STR1$ = MAKEIT ("TEST OF PARAMETER VALUE PASSING" ,44)
  1266. STR2$ = MAKEIT ( "STRING 2" ,43)
  1267. STR3$ = MAKEIT ("STRING 3", 14)
  1268. STR4$ = MAKEIT ("STRING 4", 14)
  1269. CLS
  1270. LOCATE 10,1
  1271. CALL DUM1(VARSEG(STR1$),SADD(STR1$), VARSEG(STR2$),SADD(STR2$),_
  1272.           VARSEG(STR3$), SADD(STR3$), VARSEG(STR4$), SADD(STR4$) )
  1273. LOCATE 24,1
  1274. END
  1275. FUNCTION MAKEIT$ (S$,SIZE%)
  1276.    MAKEIT$ = LEFT$(S$+STRING$(80, 32),SIZE%)
  1277. END FUNCTION
  1278.  
  1279. The following FORTRAN program is FORSUB.FOR:
  1280.  
  1281.       SUBROUTINE DUM1(STR1, STR2, STR3, STR4)
  1282.       CHARACTER*14 STR3, STR4 [FAR]
  1283.       CHARACTER*43 STR1 [FAR]
  1284.       CHARACTER*44 STR2  [FAR]
  1285.       WRITE (*,*) STR1, STR2, STR3, STR4
  1286.       END
  1287.  
  1288. Keywords:  H_Fortran B_BasicCom SR# S890110-32
  1289.  
  1290. COPYRIGHT Microsoft Corporation, 1989.
  1291. Updated  89/12/22 04:23
  1292. _____________________________________________________________________________
  1293. Q32788 Example of Trapping CTRL+ALT+DEL Keys in QuickBASIC
  1294. Microsoft QuickBASIC Compiler (QUICKBAS)
  1295. 4.00 4.00b 4.50
  1296. MS-DOS
  1297.  
  1298. Summary:
  1299.  
  1300. The correction below applies to the KEY statement on Page 236 of the
  1301. following manuals:
  1302.  
  1303. 1. Page 236 of "Microsoft QuickBASIC 4.0: BASIC Language Reference"
  1304.    for Versions 4.00 and 4.00b
  1305.  
  1306. 2. Page 236 of "Microsoft BASIC Compiler 6.0: BASIC Language
  1307.    Reference" for Versions 6.00 and 6.00b for MS-DOS and MS OS/2
  1308.  
  1309. 3. Page 180 of the "Microsoft BASIC 7.0: Language Reference" manual
  1310.    for Microsoft BASIC PDS Version 7.00
  1311.  
  1312. 4. Page 198 of the "Microsoft QuickBASIC: BASIC Language Reference" manual
  1313.    for QuickBASIC Version 4.50
  1314.  
  1315. The following phrase for the KEY(n) statement is incorrect:
  1316.  
  1317.    ...a keyboardflag value of &H12 would test for both CTRL and ALT
  1318.    being pressed.
  1319.  
  1320. The keyboardflag value should be &H0C on a non-extended keyboard, not
  1321. &H12, to test for both CTRL and ALT being pressed. The keyboardflag
  1322. value should be &H8C on an extended keyboard. This example incorrectly
  1323. uses decimal addition on hexadecimal numbers.
  1324.  
  1325. More Information:
  1326.  
  1327. The following BASIC program gives an example of trapping the
  1328. CTRL+ALT+DEL key sequence for both extended and non-extended
  1329. keyboards:
  1330.  
  1331.   ' This example works in QuickBASIC Versions 4.00 and later.
  1332.   ' &H80 = keyboard flag value to add for extended keyboard keys
  1333.   ' &H0C = keyboard flag for CTRL (&H04) plus ALT (&H08), pressed
  1334.   '        together.
  1335.   ' &H53 = scan code for DELETE (or DEL) key
  1336.   CLS
  1337.   KEY 15, CHR$(&HC) + CHR$(&H53)    '   Trap CTRL+ALT+DEL for
  1338.   ON KEY(15) GOSUB ctrlaltdelwhite  '   white DEL key
  1339.   KEY(15) ON
  1340.   KEY 16, CHR$(&H8C) + CHR$(&H53)   '   Trap CTRL+ALT+DELETE for
  1341.   ON KEY(16) GOSUB ctrlaltdelgrey   '   grey (extended) DELETE key
  1342.   KEY(16) ON
  1343.   DO
  1344.   LOOP UNTIL INKEY$ = "q"         '  Idle loop
  1345.   END
  1346. ctrlaltdelgrey:
  1347.   PRINT "pressed CTRL+ALT+DELETE (grey DELETE key) on extended keyboard"
  1348.   RETURN
  1349. ctrlaltdelwhite:
  1350.   PRINT "Pressed CTRL+ALT+DEL (white DEL key) on either keyboard"
  1351.   RETURN
  1352.  
  1353. Please note that when you run this program, pressing CTRL+ALT+DEL will
  1354. reboot the computer if any of the following key states are also
  1355. active:
  1356.  
  1357.    SHIFT, NUM LOCK, or CAPS LOCK
  1358.  
  1359. You must define separate ON KEY(n) statements for trapping
  1360. CTRL+ALT+DEL in combination with the different states of the SHIFT,
  1361. NUM LOCK, or CAPS LOCK keys. In the ON KEY(n) statement, n can be 15
  1362. through 25; this limits you to 11 user-defined keys.
  1363.  
  1364. The keyboardflag value &H0C in the KEY statement is obtained by adding
  1365. together the keyboardflag values from Page 236 for the CTRL and ALT
  1366. keys, as in the following example:
  1367.  
  1368.       &H04   +  &H08   =>  &H0C
  1369.       (CTRL)    (ALT)      (keyboardflag for KEY statement)
  1370.  
  1371. When adding together keyboardflag values to trap different
  1372. combinations of SHIFT, CTRL, ALT, NUM LOCK, CAPS LOCK, or
  1373. Advanced-101-keyboard extended keys, it is important to remember that
  1374. the values on Page 236 are in hexadecimal (base 16) notation, where
  1375. numbers are preceded with &H. If you wish, you can convert the number
  1376. to decimal notation (base 10) and use that value. Be sure not to use
  1377. &H in front of the value in BASIC if the value is in decimal notation.
  1378.  
  1379. Keywords:  docerr B_BasicCom
  1380.  
  1381. COPYRIGHT Microsoft Corporation, 1989.
  1382. Updated  89/12/23 04:07
  1383. _____________________________________________________________________________
  1384. Q46376 How to Pipe ( | ) Input into a QuickBASIC Program
  1385. Microsoft QuickBASIC Compiler (QUICKBAS)
  1386. 3.00 4.00 4.00b 4.50
  1387. MS-DOS
  1388.  
  1389. Summary:
  1390.  
  1391. It is possible to use DOS redirection to pipe output from a program
  1392. into a QuickBASIC program. To do this, the QuickBASIC program must
  1393. CALL INTERRUPT 21 Hex, with function 3F Hex, to get the input from the
  1394. DOS device CON.
  1395.  
  1396. This information applies to Microsoft QuickBASIC Versions 3.00, 4.00,
  1397. 4.00b, and 4.50 for MS-DOS, to Microsoft BASIC Compiler Versions 6.00
  1398. and 6.00b for MS-DOS, and to Microsoft BASIC PDS Version 7.00 for
  1399. MS-DOS.
  1400.  
  1401. More Information:
  1402.  
  1403. DOS redirection is a feature of DOS Versions 2.00 and later. It allows
  1404. you to take the output that would normally go to a device like the
  1405. terminal's screen and redirect or "pipe" the output into another
  1406. program. The program on the receiving end then takes the input and
  1407. processes or "filters" the input. This is why these programs are often
  1408. called "filters." The syntax for the DOS pipe command is the
  1409. following:
  1410.  
  1411.    DOS-PROMPT> p1 | p2
  1412.  
  1413. In this command, p1 is the program performing the output, | is called
  1414. the pipe symbol, and p2 is the program performing the input or
  1415. filtering. An example of a common use for this feature of DOS is as
  1416. follows:
  1417.  
  1418.    DOS-PROMPT> dir | sort
  1419.  
  1420. The "dir" command gives a listing of the current directory, which is
  1421. piped into the DOS "sort" program. Sort then filters the input and
  1422. displays the directory listing in sorted order.
  1423.  
  1424. However, the output from p1, the first program, can be piped into a
  1425. QuickBASIC program as well. The QuickBASIC program can then read the
  1426. input from the DOS device CON. This is possible because DOS stores the
  1427. output from the first program in a temporary file. The QuickBASIC
  1428. program can then CALL INTERRUPT 21H function 3FH to retrieve the
  1429. input. This function inputs a specific number of bytes from a file or
  1430. device, such as the CON device.
  1431.  
  1432. Interrupt 21 Hex, with function 3F hex, requires five register
  1433. parameters to be passed:
  1434.  
  1435.    AH = The function number, 3F Hex.
  1436.    BX = Handle to the file or device.
  1437.    CX = The number of bytes to read.
  1438.    DS = Segment of the buffer area. The buffer will be a string.
  1439.    DX = Offset of the buffer area.
  1440.  
  1441. For more detailed information on INTERRUPT 21 Hex and function 3F Hex,
  1442. redirection, and filters, consult "Advanced MS-DOS Programming" by Ray
  1443. Duncan, published by Microsoft Press, copyright 1988.
  1444.  
  1445. For more information on using the QuickBASIC CALL INTERRUPT, search on
  1446. the following word:
  1447.  
  1448.    QB4INT
  1449.  
  1450. Note: You can pipe information into a QuickBASIC program, but it is
  1451. more difficult to pipe information from a QuickBASIC program to
  1452. another program. QuickBASIC usually does not output information
  1453. through DOS services but accesses the hardware directly. The PRINT
  1454. statement, for example, displays text directly to video memory, not to
  1455. the DOS CON device. To direct output from a BASIC program to CON, you
  1456. must either OPEN the BASIC device "CONS" (with no colon) for output as
  1457. a file and PRINT#n all information to that file number (#n), or use
  1458. INTERRUPT 21 Hex, with function 40 Hex, to output to the CON device.
  1459. This output could be piped into another program.
  1460.  
  1461. Code Example
  1462. ------------
  1463.  
  1464. '***********************************************************
  1465. '* This program calls the DOS INTerrupt 21H function 3FH   *
  1466. '*  in order to read any input that has been redirected    *
  1467. '*  to it with the | operator from DOS. It then echoes the *
  1468. '*  input to the screen, and filters out any extra Line    *
  1469. '*  Feed characters.                                       *
  1470. '***********************************************************
  1471.  
  1472. REM $INCLUDE: 'qb.bi'
  1473. ' For BC.EXE and QBX.EXE for BASIC 7.00 use the include file 'QBX.BI'
  1474.  
  1475. DIM inregs AS RegTypeX, outregs AS RegTypeX
  1476.  
  1477. REM $DYNAMIC
  1478. DIM tempvar(10) AS STRING * 10
  1479. 'NOTE: The length of the string and the number of bytes read
  1480. '      (inregs.cx) should be the same.
  1481.  
  1482. DO
  1483.      ' Set up the parameters for the CALL INTERRUPTX
  1484.      inregs.ax = &H3F00  ' AH gets the functions number.
  1485.      inregs.bx = 0       ' The is the handle to the CON device is 0.
  1486.      inregs.cx = 10      ' Request to read 10 characters at a time.
  1487.      inregs.ds = VARSEG(tempvar(1)) ' Segment of the buffer area.
  1488.      inregs.dx = VARPTR(tempvar(1)) ' Offset of the buffer area.
  1489.  
  1490.      'INT 21H function 3FH to read a file or device.
  1491.      CALL INTERRUPTX(&H21, inregs, outregs)
  1492.  
  1493.      'The number of bytes actually read is returned in AX.
  1494.      'We requested 10, so if it reads fewer, then we are done.
  1495.      IF outregs.ax < 10 THEN EXIT DO
  1496.  
  1497.      ' Filter the string returned
  1498.      FOR i = 1 TO LEN(tempvar(1))
  1499.        a$ = MID$(tempvar(1), i, 1)
  1500.       ' DOS puts a line feed (LF) after its carriage return.
  1501.       ' We want to avoid this, because the PRINT will add an
  1502.       ' extra carriage return after this line feed.
  1503.  
  1504.        IF NOT (a$ = CHR$(10)) THEN
  1505.       PRINT a$;
  1506.        END IF
  1507.     NEXT
  1508. LOOP
  1509. END
  1510.  
  1511. Keywords:  SR# S890621-89 B_BasicCom
  1512.  
  1513. COPYRIGHT Microsoft Corporation, 1989.
  1514. Updated  89/12/28 08:08
  1515. _____________________________________________________________________________
  1516. Q31426 "Duplicate Definition" on STATIC Array in Second CALL to SUB
  1517. Microsoft QuickBASIC Compiler (QUICKBAS)
  1518. 4.00 4.00b 4.50
  1519. MS-DOS
  1520.  
  1521. Summary:
  1522.  
  1523. In the following sources, the example of using the STATIC statement
  1524. does not clearly explain what will happen with a second call to the
  1525. SUB:
  1526.  
  1527. 1. Page 80 of the "Microsoft QuickBASIC 4.0: Programming in BASIC:
  1528.    Selected Topics" manual for Versions 4.00 and 4.00b
  1529.  
  1530. 2. Page 70 of the "Microsoft QuickBASIC: Programming in BASIC" manual
  1531.    for Version 4.50
  1532.  
  1533. If SubProg2 is called more than once, the DIM statement gives you a
  1534. "Duplicate Definition" error message. This is because in a recursive
  1535. procedure, arrays are always dimensioned dynamically (that is, at run
  1536. time), and making the array retain its values between calls (with the
  1537. STATIC statement) means that the array was already dimensioned at the
  1538. second call.
  1539.  
  1540. The example should be changed as follows:
  1541.  
  1542. 1. Declare an additional STATIC variable as a flag.
  1543.  
  1544. 2. Put the DIM in an IF...END IF block that executes only upon first
  1545.    call to the routine, and not on subsequent calls, as determined by
  1546.    the flag variable.
  1547.  
  1548. This correction also applies to the following:
  1549.  
  1550. 1. Page 80 of "Microsoft BASIC Compiler Version 6.00 for MS OS/2 and
  1551.    MS-DOS: Programming in BASIC: Selected Topics" for the BASIC
  1552.    compiler Versions 6.00 and 6.00b
  1553.  
  1554. 2. Page 66 of "Microsoft BASIC 7.0: Programmer's Guide" for Microsoft
  1555.    BASIC PDS Version 7.00 for MS-DOS and MS OS/2
  1556.  
  1557. More Information:
  1558.  
  1559. Removing the array from the STATIC statement also eliminates the
  1560. "Duplicate Definition."
  1561.  
  1562. The following code demonstrates how to avoid the "Duplicate
  1563. Definition" error:
  1564.  
  1565. DECLARE SUB dummy ()
  1566. PRINT "call the subroutine"
  1567. CALL dummy
  1568. PRINT "call the routine again"
  1569. CALL dummy
  1570.  
  1571. SUB dummy
  1572. STATIC a(), FirstPassFlag   ' STATIC retains values between CALLs
  1573. ' FirstPassFlag assures that array gets DIMensioned only once.
  1574. IF FirstPassFlag = 0 THEN
  1575.    DIM a(1)
  1576.    FirstPassFlag = 1
  1577. END IF
  1578. print "continuing on"
  1579. END SUB
  1580.  
  1581. Keywords:  docerr B_BasicCom
  1582.  
  1583. COPYRIGHT Microsoft Corporation, 1989.
  1584. Updated  89/12/29 05:36
  1585. _____________________________________________________________________________
  1586. Q36806 Softkey String for KEY 10 Has 5-Character Maximum Display
  1587. Microsoft QuickBASIC Compiler (QUICKBAS)
  1588. 1.00 1.02 2.00 2.01 3.00 4.00 4.00b 4.50
  1589. MS-DOS
  1590.  
  1591. Summary:
  1592.  
  1593. The following manuals incorrectly specify that the first six
  1594. characters of the softkey string expression will be shown when the
  1595. KEY ON statement is invoked. This is true, except for KEY 10. For KEY
  1596. 10, only the first 5 characters are shown:
  1597.  
  1598. 1. Page 233 of "Microsoft QuickBASIC 4.0: BASIC Language Reference" for
  1599.    Versions 4.00 and 4.00b
  1600.  
  1601. 2. Page 233 of "Microsoft BASIC Compiler 6.0: BASIC Language
  1602.    Reference" for Versions 6.00 and 6.00b for MS-DOS and MS OS/2
  1603.  
  1604. 3. "Microsoft QuickBASIC 4.5: BASIC Language Reference" for Version 4.50
  1605.  
  1606. 4. "Microsoft BASIC 7.0: BASIC Language Reference" for BASIC PDS Version
  1607.     7.00
  1608.  
  1609. This is a design limitation. The display of KEY 10 uses 2 character
  1610. spaces to display the number "10". This second digit uses the first
  1611. available space of the string expression and leaves only 5 character
  1612. spaces for that string expression.
  1613.  
  1614. More Information:
  1615.  
  1616. The following is a code example:
  1617.  
  1618.    KEY 9, "ABCDEF"
  1619.    KEY 10, "abcdef"
  1620.    KEY ON
  1621.    10 goto 10   ' Press CTRL+BREAK to quit.
  1622.  
  1623. The following function key labels display on the bottom of the screen:
  1624.  
  1625.    1      2      3  . . .   8      9ABCDEF10abcde
  1626.  
  1627. Keywords:  docerr B_BasicCom
  1628.  
  1629. COPYRIGHT Microsoft Corporation, 1989.
  1630. Updated  89/12/29 05:36
  1631. _____________________________________________________________________________
  1632. Q45687 "Out of String Space" Concatenating Variable-Length String
  1633. Microsoft QuickBASIC Compiler (QUICKBAS)
  1634. 1.00 1.01 1.02 2.00 2.01 3.00 4.00 4.00b 4.50
  1635. MS-DOS
  1636.  
  1637. Summary:
  1638.  
  1639. For variable-length string concatenation to execute successfully, even
  1640. if only 1 byte is to be added, there must be enough available memory
  1641. [reported by FRE("")] for the length of a copy of the existing string,
  1642. plus the length of the string being added, plus its new 4-byte string
  1643. descriptor. Otherwise, you will get an "Out of String Space" error,
  1644. caused by the temporary old string remaining in memory during the
  1645. string concatenation. The old string is deallocated only after a
  1646. successful concatenation.
  1647.  
  1648. This information applies to QuickBASIC Versions 1.00, 1.01, 1.02,
  1649. 2.00, 2.01, 3.00, 4.00, 4.00b, and 4.50, and to BASIC Compiler
  1650. Versions 6.00 and 6.00b for MS-DOS and OS/2.
  1651.  
  1652. This information also applies to Microsoft BASIC PDS Version 7.00 when
  1653. using BC.EXE without the /Fs compiler switch. Inside the QBX.EXE
  1654. environment and when using /Fs compiler switch, BASIC 7.00 uses a 64K
  1655. segment for temporary string storage and procedure-level strings (that
  1656. is, strings declared inside subroutines). To see how much temporary
  1657. string space you have when using far strings, use FRE("StringLiteral"),
  1658. where StringLiteral is any constant string (for example, "Hello"). For
  1659. more information about far strings, read Chapter 11 in the "Microsoft
  1660. BASIC 7.0: Programmer's Guide" for BASIC PDS Version 7.00.
  1661.  
  1662. More Information:
  1663.  
  1664. When you concatenate a variable-length string with another string in
  1665. BASIC, a new 4-byte string descriptor is created. A copy of the
  1666. original string is moved to a new location in string space and the
  1667. string to be concatenated is appended to it. The length field in the
  1668. new string descriptor is updated to reflect the length of the
  1669. concatenated string. Only then is the memory used by the original
  1670. string and its descriptor released (deallocated).
  1671.  
  1672. New strings are allocated above existing strings and deallocated
  1673. strings in DGROUP. When deallocated strings fragment string space to
  1674. the point where a new string fills the last space at the top of
  1675. DGROUP, BASIC automatically performs string space compaction (garbage
  1676. collection) to make free string space contiguous again. Passing a
  1677. string argument (such as "", the null string) to the FRE("") function
  1678. always forces string space compaction before reporting the amount of
  1679. string space available in DGROUP.
  1680.  
  1681. For example, assume FRE("") returns 20,004. An attempt to add a single
  1682. byte to an existing string of 20,000 bytes would fail because 20,005
  1683. bytes are needed for the concatenation to be successful:
  1684.  
  1685.    Existing string   = 20,000 bytes
  1686.    String to add     =      1 byte longer
  1687.    String descriptor =      4 bytes
  1688.                     -----------
  1689.    Memory needed       20,005 bytes
  1690.  
  1691. Because only 20,004 bytes of memory are available, an "Out of String
  1692. Space" message will be generated.
  1693.  
  1694. Keywords:  SR# S890606-8 B_BasicCom
  1695.  
  1696. COPYRIGHT Microsoft Corporation, 1989.
  1697. Updated  89/12/29 05:36
  1698. _____________________________________________________________________________
  1699. Q48401 Multi-DIMensioned Arrays Are in Column Order; BC /R Row Order
  1700. Microsoft QuickBASIC Compiler (QUICKBAS)
  1701. 4.00 4.00b 4.50
  1702. MS-DOS
  1703.  
  1704. Summary:
  1705.  
  1706. By default, multidimensional arrays are stored in contiguous columns
  1707. in memory (that is, column-major order) in compiled BASIC. With
  1708. column-major order, the leftmost subscript (the row dimension)
  1709. changes the fastest.
  1710.  
  1711. You can force executable .EXE programs to store arrays in rows by
  1712. using the BC /R option. However, the /R option (for row-major order)
  1713. is not available in the QB.EXE or the QBX.EXE editor environment. With
  1714. row-major order, the rightmost subscript (the column dimension)
  1715. changes the fastest.
  1716.  
  1717. This information applies to Microsoft QuickBASIC Versions 4.00, 4.00b,
  1718. and 4.50 for MS-DOS, to Microsoft BASIC Compiler Versions 6.00 and
  1719. 6.00b for MS-DOS and MS OS/2, and to Microsoft BASIC PDS Version 7.00
  1720. for MS-DOS.
  1721.  
  1722. More Information:
  1723.  
  1724. In the DIM X(row,column) statement, arrays are stored by default in
  1725. column order in memory. When looking at a contiguous block of memory
  1726. that is storing a two-dimensional array, you'll find one column stored
  1727. after another. For example, for DIM X(2,2), the array elements are
  1728. stored by default in the following column-major order:
  1729.  
  1730.    X(0,0), X(1,0), X(2,0), X(0,1), X(1,1), X(2,1), X(0,2), X(1,2), X(2,2)
  1731.  
  1732. If you compile the program with BC /R, you get row-major order, as
  1733. follows:
  1734.  
  1735.    X(0,0), X(0,1), X(0,2), X(1,0), X(1,1), X(1,2), X(2,0), X(2,1), X(2,2)
  1736.  
  1737. An easy way to demonstrate the storage order is to BSAVE a two-
  1738. dimensional array and then BLOAD the same data into a one-dimensional
  1739. array. You then have a firsthand view of how the array is stored.
  1740.  
  1741. Unlike BASIC, Microsoft C defaults to row-major order.
  1742.  
  1743. This array-order information is taken from Page 313 of the "Microsoft
  1744. QuickBASIC 4.0: Learning and Using" manual for QuickBASIC Versions
  1745. 4.00 and 4.00b, from Page 313 of the "Microsoft BASIC Compiler 6.0:
  1746. Learning and Using Microsoft QuickBASIC" manual for Versions 6.00 and
  1747. 6.00b, and from Page 560 of the "Microsoft BASIC 7.0: Programmer's
  1748. Guide" for BASIC PDS Version 7.00.
  1749.  
  1750. Keywords:  SR# S890801-7 B_BasicCom
  1751.  
  1752. COPYRIGHT Microsoft Corporation, 1989.
  1753. Updated  89/12/29 05:36
  1754. _____________________________________________________________________________
  1755. Q45897 How to Make QuickBASIC 4.50 Recognize Custom Help Files
  1756. Microsoft QuickBASIC Compiler (QUICKBAS)
  1757. 4.50
  1758. MS-DOS
  1759.  
  1760. Summary:
  1761.  
  1762. You can use the HELPMAKE.EXE utility that is included with QuickC
  1763. Version 2.00 and Quick Pascal Version 1.00 to make customized Help
  1764. files for QuickBASIC Version 4.50. However, QuickBASIC 4.50 does not
  1765. acknowledge the "HELPFILES" environment setting. The only Help file
  1766. that it acknowledges is QB45QCK.HLP. How you implement support for
  1767. your customized Help files depends upon whether you want to replace
  1768. QuickBASIC's original Help file or merely to supplement it.
  1769.  
  1770. This information applies to QuickBASIC Version 4.50.
  1771.  
  1772. Microsoft BASIC PDS Version 7.00 includes the HELPMAKE.EXE utility. To
  1773. use HELPMAKE.EXE with QBX.EXE 7.00, see Chapter 22 of the "Microsoft
  1774. BASIC 7.0: Programmer's Guide" for Microsoft BASIC PDS Version 7.00.
  1775.  
  1776. More Information:
  1777.  
  1778. If you want to replace QuickBASIC's Help file, rename your customized
  1779. Help file as QB45QCK.HLP and place it in the directory with QB.EXE.
  1780. You can now access your own customized contexts but have no access to
  1781. the original Help screens for QuickBASIC.
  1782.  
  1783. If you want to supplement QuickBASIC's Help file, do the following:
  1784.  
  1785. 1. Use HELPMAKE to decode QuickBASIC's QB45QCK.HLP as follows:
  1786.  
  1787.       HELPMAKE /D /OQB45QCK.TXT QB45QCK.HLP
  1788.  
  1789.    (Note: There is no space when using HELPMAKE's /Odestfile switch,
  1790.    which specifies the output destination filename.)
  1791.  
  1792. 2. Load QB45QCK.TXT into a text editor or word processor.
  1793.  
  1794. 3. Append the source for your customized contexts to the end of
  1795.    QB45QCK.HLP.
  1796.  
  1797. 4. Save the file under the name QB45QCK.TXT.
  1798.  
  1799. 5. Rename QB45QCK.HLP to QB45QCK.OLD.
  1800.  
  1801. 6. Use HELPMAKE to encode the new Help file, as follows:
  1802.  
  1803.       HELPMAKE /A: /E /OQB45QCK.HLP QB45QCK.TXT
  1804.  
  1805.    (Note: The /A: switch specifies a colon (:) to be the control
  1806.    character to mark lines containing special control information
  1807.    for use by the QB.EXE application's Help system.)
  1808.  
  1809. You can now access your customized Help contexts, in addition to the
  1810. original contents of the Help screens, with QuickBASIC's Help system.
  1811.  
  1812. For more information about running HELPMAKE, please refer to Chapter 8
  1813. of the "Microsoft QuickC Tool Kit" manual for Version 2.0.
  1814.  
  1815. Keywords:  S_QuickC S_QuickPas S_UTILity
  1816.  
  1817. COPYRIGHT Microsoft Corporation, 1989.
  1818. Updated  89/12/30 05:05
  1819. _____________________________________________________________________________
  1820. Q37481 PRINT USING Statement Fails to Use Print Zones
  1821. Microsoft QuickBASIC Compiler (QUICKBAS)
  1822. 4.00 4.00b 4.50
  1823. MS-DOS
  1824.  
  1825. Summary:
  1826.  
  1827. The PRINT USING statement is not designed to print the values of an
  1828. expression list in the 14-character print zones. Instead, it ignores
  1829. the comma and treats it like a semicolon. In QuickBASIC Version 4.50,
  1830. the syntax checker correctly changes the comma to a semicolon.
  1831. However, several manuals (listed below) and the online help system
  1832. incorrectly state that the comma is syntactically legal.
  1833.  
  1834. More Information:
  1835.  
  1836. The incorrect syntax for the PRINT USING statement is as follows:
  1837.  
  1838.    PRINT USING formatstring; expressionlist [{,|;}]
  1839.  
  1840. The incorrect definition for the PRINT USING statement is as follows:
  1841.  
  1842.    The position of each printed item is determined by the punctuation
  1843.    used to separate the items in the list. BASIC divides the line into
  1844.    print zones of 14 spaces each. In the expression list, a comma
  1845.    makes the next value print at the start of the next zone. A
  1846.    semicolon makes the next value print immediately after the last
  1847.    value.
  1848.  
  1849. This incorrect syntax or definition is given in each of the following
  1850. references:
  1851.  
  1852. 1. Page 275 of the "Microsoft BASIC 7.0: BASIC Language Reference" for
  1853.    Microsoft BASIC PDS Version 7.00
  1854.  
  1855. 2. Page 335 of the "Microsoft QuickBASIC 4.0: BASIC Language
  1856.    Reference" for QuickBASIC 4.00 and 4.00b
  1857.  
  1858. 3. Page 287 of the "Microsoft QuickBASIC: BASIC Language Reference"
  1859.    for QuickBASIC 4.50
  1860.  
  1861. 4. Page 335 of the "Microsoft BASIC Compiler 6.0: BASIC Language
  1862.    Reference" for Microsoft BASIC Compiler Versions 6.00 and 6.00b
  1863.  
  1864. 5. The online help system for Microsoft QuickBASIC 4.50 under the
  1865.    entry for PRINT USING statement
  1866.  
  1867. 6. The online help system for BASIC PDS 7.00 under the entry for the
  1868.    PRINT USING statement
  1869.  
  1870. The following is a code example that demonstrates that PRINT USING
  1871. treats commas as if they were semicolons. When run in the environment,
  1872. the code example will correctly substitute a semicolon between the
  1873. variables "a" and "b" for the comma:
  1874.  
  1875.    a=3.45
  1876.    b=5.23
  1877.    PRINT USING "##.##";a,b
  1878.  
  1879. The output is as follows:
  1880.  
  1881.    3.45 5.23
  1882.  
  1883. Keywords:  docerr B_BasicCom
  1884.  
  1885. COPYRIGHT Microsoft Corporation, 1989.
  1886. Updated  90/01/13 15:50
  1887. _____________________________________________________________________________
  1888. Q40635 "Permission Denied" Is Only Error for BASIC Record/File LOCK
  1889. Microsoft QuickBASIC Compiler (QUICKBAS)
  1890. 4.00 4.00b 4.50
  1891. MS-DOS
  1892.  
  1893. Summary:
  1894.  
  1895. The only error message that you will get for locked files or records
  1896. is "Permission denied," error number 70.
  1897.  
  1898. Normally, you only get a "Bad record number" error message when
  1899. attempting to access record number zero. However, the message "Bad
  1900. record number" has nothing to do with the LOCK statement, contrary to
  1901. a statement in the documentation (listed below).
  1902.  
  1903. This information applies to Microsoft QuickBASIC Versions 4.00, 4.00b,
  1904. and 4.50, to Microsoft BASIC Compiler Versions 6.00 and 6.00b for
  1905. MS-DOS and MS OS/2, and to Microsoft BASIC PDS Version 7.00 for MS-DOS
  1906. and MS OS/2.
  1907.  
  1908. More Information:
  1909.  
  1910. This documentation error occurs in the following places. Each of these
  1911. references is in the language reference manual for that product and is
  1912. under the entry describing the LOCK... UNLOCK statement.
  1913.  
  1914. 1. Page 259 of the "Microsoft QuickBASIC 4.0: BASIC Language
  1915.    Reference" manual for QuickBASIC Versions 4.00 and 4.00b
  1916.  
  1917. 2. Page 259 of the "Microsoft BASIC Compiler 6.0: BASIC Language
  1918.    Reference" manual for Microsoft BASIC Compiler Versions 6.00 and
  1919.    6.00b
  1920.  
  1921. 3. Page 220 of the "Microsoft QuickBASIC 4.5: BASIC Language
  1922.    Reference" manual for QuickBASIC Version 4.50
  1923.  
  1924. 4. Page 200 of the "Microsoft BASIC 7.0: Language Reference" manual
  1925.    for Microsoft BASIC PDS Version 7.00
  1926.  
  1927. Each of the references above makes the following misleading statement:
  1928.  
  1929.    If you attempt to access a file that is locked, the following
  1930.    error messages may appear:
  1931.  
  1932.       Bad record number
  1933.       Permission denied
  1934.  
  1935. This same incorrect information appears in the QB Advisor online Help
  1936. system for QuickBASIC Version 4.50 and in the Microsoft Advisor online
  1937. Help system for QBX.EXE, which comes with Microsoft BASIC PDS Version
  1938. 7.00. The error occurs under the entry for the "LOCK... UNLOCK
  1939. Statement Details" in both Help systems.
  1940.  
  1941. The program example below demonstrates that a "Permission Denied"
  1942. error occurs if a program does any of the following:
  1943.  
  1944. 1. LOCKs a file that is already LOCKed.
  1945.  
  1946. 2. Reads any record from a random access file where the whole file is
  1947.    LOCKed.
  1948.  
  1949. 3. Reads any part of a sequential file where any part of that file is
  1950.    LOCKed.
  1951.  
  1952. 4. Reads the portion of a BINARY access file that was LOCKed.
  1953.  
  1954. The following is sample code:
  1955.  
  1956. OPEN "test5" FOR BINARY AS #1   'Open the same file as #1 and #2.
  1957. OPEN "test5" FOR BINARY AS #2
  1958.  
  1959. OPEN "test4" FOR RANDOM AS #3 LEN = 11   'Open as #3 and #4.
  1960. OPEN "test4" FOR RANDOM AS #4 LEN = 11
  1961.  
  1962. OPEN "test3" FOR INPUT AS #5   'Open as #5 and #6.
  1963. OPEN "test3" FOR INPUT AS #6
  1964.  
  1965. OPEN "test3" FOR INPUT AS #7   'Open the same file as #5 and #6.
  1966.  
  1967. FIELD #3, 11 AS f3$
  1968. FIELD #4, 11 AS f4$
  1969.  
  1970. LOCK #1, 30 TO 32       'Lock some bytes in #1.
  1971. LOCK #3                 'lock entire file #3
  1972. LOCK #5, 1              'Lock first record in #5.
  1973. CLS
  1974. n = 10
  1975. LOCK #7          'Permission denied attempt to lock a locked file
  1976. a$ = INPUT$(34, #2) 'Permission denied if any part is locked.
  1977. GET #4, n           'Permission denied for any n except n=0
  1978.                     'n=0 gives a bad file number
  1979. INPUT #6, a$        'Permission denied for record 1
  1980. UNLOCK #1, 30 TO 32
  1981. UNLOCK #3
  1982. UNLOCK #5, 1
  1983. CLOSE
  1984.  
  1985. Keywords:  docerr B_BasicCom SR# S881221-115
  1986.  
  1987. COPYRIGHT Microsoft Corporation, 1989.
  1988. Updated  90/01/13 15:50
  1989. _____________________________________________________________________________
  1990. Q52068 Example of Using NPV and IRR Financial Functions in BASIC 7.00
  1991. Microsoft BASIC Compiler (BASICCOM)
  1992. 7.00   | 7.00
  1993. MS-DOS | OS/2
  1994.  
  1995. Summary:
  1996.  
  1997. This article explains how to use the NPV and IRR financial functions
  1998. in Microsoft BASIC PDS (Professional Development System) Version 7.00
  1999. for MS-DOS and MS OS/2.
  2000.  
  2001. More Information:
  2002.  
  2003. Note that the NPV#, IRR#, and MIRR# functions are used for investments
  2004. that are a series of nonconstant cash payments made at equal
  2005. intervals. You pass the series of nonconstant payments in an array.
  2006. [This contrasts with the financial functions for annuity investments
  2007. (FV#, IPmt#, Rate#, NPer#, PV#, Pmt#, and PPmt#). In an annuity, each
  2008. cash payment is the same constant amount, made at equal intervals.]
  2009.  
  2010. The present value (PV) of a future cash receipt is the amount of money
  2011. that, if received today, would be considered equivalent to the future
  2012. receipt, at a given interest rate. The present value is less than the
  2013. future receipt because you can earn interest on money received today.
  2014. NPV (Net Present Value) compares (subtracts) the current value of a
  2015. series of future cash flows with an amount invested today.
  2016.  
  2017. NPV is useful to compare investment opportunities at a given discount
  2018. (interest) rate. The discount rate (rate#) can be viewed as the rate
  2019. of return you want out of your investment. If NPV is greater than or
  2020. equal to 0, the investment equals or exceeds your interest (discount)
  2021. rate requirement; if NPV is less than 0, the investment does not meet
  2022. your interest rate requirement.
  2023.  
  2024. The NPV#(rate#,valuearray#(),valuecount%,status%) function returns
  2025. Net Present Value. You input the values rate#, valuearray#(), and
  2026. valuecount% (which is the number of array elements), and get back
  2027. status% equals 0 for success, 1 for failure.
  2028.  
  2029. The IRR#(valuearray#(),valuecount%,guess#,status%) function returns
  2030. Internal Rate of Return. IRR returns the discount rate at which NPV
  2031. would return 0 (zero). For a given array of cash flow values, IRR can
  2032. be thought of as an average interest rate (which compounds at each
  2033. period). If IRR is lower than the interest rate you desire for this
  2034. investment, then it is not a good investment.
  2035.  
  2036. The first element of the input cash-flow array should usually be
  2037. negative, indicating your initial investment. A high (positive) income
  2038. early in the value array will make IRR higher than if the same high
  2039. income instead occurred later in the array. This is an example of the
  2040. time value of money.
  2041.  
  2042. Please refer to an elementary accounting textbook for more information
  2043. about these standard Accounting functions.
  2044.  
  2045. Code Example
  2046. ------------
  2047.  
  2048. You can run this program in the QuickBASIC Extended environment with
  2049. QBX /L FINANCER.QLB. To run outside this environment, you must link
  2050. with the appropriate library (FINANCER.LIB, FINANCAR.LIB,
  2051. FINANCEP.LIB, or FINANCAP.LIB).
  2052.  
  2053. REM $INCLUDE: 'FINANC.BI
  2054. DEFDBL A-Z
  2055. OPTION BASE 1
  2056. CLS
  2057. valuecount% = 5   ' = number of cash-flow values in valuearray()
  2058. ' Array holds cash flow values, one value per period (such as per
  2059. ' year):
  2060. DIM valuearray(valuecount%)
  2061. guess = .1        ' Guess the IRR (use .1 if in doubt)
  2062.  
  2063. valuearray(1) = -1000 ' 0. First value negative as initial investment.
  2064. valuearray(2) = 100   ' 1. Return on investment after 1 period.
  2065. valuearray(3) = 200   ' 2. (Positive value is return on investment.)
  2066. valuearray(4) = -300  ' 3. (Negative value is additional investment.)
  2067. valuearray(5) = 1200  ' 4. Return on investment after 4 periods.
  2068. ' For the above values, IRR returns .0514. (5.14% return per period)
  2069. status% = 0
  2070.  
  2071. irreturn = IRR(valuearray(), valuecount%, guess, status%)
  2072. IF status% THEN PRINT "IRR error occurred; try different guess";
  2073.  
  2074. discountrate = irreturn
  2075. netpresval = NPV#(discountrate, valuearray(), valuecount%, status%)
  2076.  
  2077. 'Notes for NPV#() function:
  2078. ' If discountrate = value returned by IRR(), then NPV returns zero, as
  2079. '    in the IRR example in the "Microsoft BASIC 7.0: Language
  2080. '    Reference" manual, and also as in this code example.
  2081. ' If discountrate = zero, NPV returns sum of values in valuearray().
  2082. ' If discountrate > zero, NPV returns an amount smaller than sum of
  2083. '    values in valuearray() due to the discount effect at each period.
  2084. ' If discountrate < zero, NPV returns an amount larger than the sum of
  2085. '    the values in valuearray().
  2086.  
  2087. IF status% THEN PRINT "NPV error occurred"
  2088. PRINT "IRR (fractional return on investment per period) = ";
  2089. PRINT USING "##.####"; irreturn
  2090. PRINT "NPV = ";
  2091. PRINT USING "#######.##"; netpresval
  2092.  
  2093. Output
  2094. ------
  2095.  
  2096. For the above values, IRR returns .0514 (5.14 percent return per
  2097. period). NPV returns 0 (zero), since IRR returns the discount rate at
  2098. which NPV returns 0.
  2099.  
  2100. COPYRIGHT Microsoft Corporation, 1989.
  2101. Updated  90/01/16 04:57
  2102. _____________________________________________________________________________
  2103. Q32217 Using B_OnExit Across a CHAIN Hangs System; Compiled BASIC
  2104. Microsoft BASIC Compiler (BASICCOM)
  2105. 6.00 6.00b 7.00 | 6.00 6.00b 7.00
  2106. MS-DOS          | OS/2
  2107.  
  2108. Summary:
  2109.  
  2110. Chaining to and from programs that use B_OnExit causes the system to
  2111. hang.
  2112.  
  2113. Microsoft has confirmed this to be a problem in Microsoft QuickBASIC
  2114. Versions 4.00 and 4.00b (buglist4.00, buglist4.00b), in Microsoft
  2115. BASIC Compiler Version 6.00 and 6.00b for MS-DOS and MS OS/2, and in
  2116. Microsoft BASIC Professional Development System (PDS) Version 7.00 for
  2117. MS-DOS and MS OS/2. We are researching this problem and will post new
  2118. information here as it becomes available.
  2119.  
  2120. More Information:
  2121.  
  2122. Please note that the B_OnExit routine is documented on Pages 319-321
  2123. of the "Microsoft QuickBASIC 4.0: Learning and Using" manual for
  2124. Microsoft QuickBASIC Versions 4.00 and 4.00b (this is the same manual
  2125. for Microsoft BASIC Compiler Versions 6.00 and 6.00b), and in the
  2126. "Microsoft BASIC 7.0: Programmer's Guide" on Pages 474-475.
  2127.  
  2128. The following steps reproduce the problem using source code provided
  2129. farther below:
  2130.  
  2131. 1. Use the following software to reproduce the problem:
  2132.  
  2133.    a. Microsoft QuickBASIC Versions 4.00, 4.00b, Microsoft BASIC
  2134.       Compiler Version 6.00 or 6.00b, or Microsoft BASIC PDS Version
  2135.       7.00.
  2136.  
  2137.    b. Microsoft C Compiler Version 5.10
  2138.  
  2139. 2. Type the following command lines:
  2140.  
  2141.       BC BUGTEST.BAS;
  2142.       BC BUGNEXT.BAS;
  2143.       CL /c /AM BUGC.C
  2144.       LINK /NOE BUGTEST+BUGC;
  2145.       LINK /NOE BUGNEXT+BUGC;
  2146.  
  2147. 3. Run BUGTEST.EXE from the DOS prompt.
  2148.  
  2149. 4. At the "CHAIN Y/N?" prompt, type Y.
  2150.  
  2151. The system locks up when BUGNEXT exits.
  2152.  
  2153. Please note the following:
  2154.  
  2155. 1. You must link BUGC.OBJ with BUGNEXT.OBJ even though it is not
  2156.    called.
  2157.  
  2158. 2. Both programs apparently run correctly until you exit BUGNEXT.
  2159.  
  2160. Code Example
  2161. ------------
  2162.  
  2163. 'BUGTEST.BAS
  2164.  
  2165.         DECLARE SUB IntProc CDECL
  2166.         DEFINT A-Z
  2167.         PRINT "[***** ENTRY TO MAIN  *****]"
  2168.         CALL InProc
  2169.         INPUT "CHAIN Y/N";T$
  2170.         IF T$="Y" OR T$="y" THEN
  2171.            CHAIN "BUGNEXT.EXE"
  2172.         END IF
  2173.         SYSTEM
  2174.         END
  2175.  
  2176. 'BUGNEXT.BAS
  2177.  
  2178.         DEFINT A-Z
  2179.         PRINT "[***** CHAIN *****]"
  2180.         SYSTEM
  2181.         END
  2182.  
  2183.  
  2184. /* BUGC.C */
  2185.  
  2186. #include <malloc.h>
  2187. extern pascal far B_OnExit();  /* Declare the routine */
  2188.  
  2189. void IntProc()
  2190. {
  2191.   void TermProc();             /* Declare TermProc routine */
  2192.   printf ("\nIn the C IntProc routine\n");
  2193.   B_OnExit(TermProc);          /* Log termination routine with BASIC */
  2194. }
  2195.  
  2196. void TermProc()                         /* The TermProc function is */
  2197. {                                       /* called before any restarting */
  2198.   printf ("\nIn C TermProc routine\n"); /* or termination of the program. */
  2199. }
  2200.  
  2201. Keywords:  buglist6.00 buglist6.00b buglist7.00 B_QuickBas
  2202.  
  2203. COPYRIGHT Microsoft Corporation, 1989.
  2204. Updated  90/01/18 03:45
  2205. _____________________________________________________________________________
  2206. Q57866 BASIC PDS 7.00 Supports Short-Circuit Boolean Expressions
  2207. Microsoft BASIC Compiler (BASICCOM)
  2208. 7.00   | 7.00
  2209. MS-DOS | OS/2
  2210.  
  2211. Summary:
  2212.  
  2213. Microsoft BASIC Professional Development System (PDS) Version 7.00
  2214. supports "short-circuit" optimization of Boolean expressions, as
  2215. described below. To take advantage of this speed optimization in
  2216. complex IF, WHILE, DO LOOP WHILE, or DO LOOP UNTIL statements, the
  2217. quickest Boolean conditions should appear first.
  2218.  
  2219. Microsoft QuickBASIC Versions 1.00, 1.01, 1.02, 2.00, 2.01, 3.00,
  2220. 4.00, 4.00b, and 4.50 and Microsoft BASIC Compiler Versions 6.00 and
  2221. 6.00b DON'T support short-circuit Boolean expressions.
  2222.  
  2223. More Information:
  2224.  
  2225. Boolean expressions are those expressions in BASIC that evaluate to
  2226. true or false. In BASIC, the IF, WHILE, and DO LOOP {WHILE | UNTIL}
  2227. statements all require Boolean expressions as part of their syntax.
  2228.  
  2229. A "short-circuit" Boolean expression is a unique kind of Boolean
  2230. expression. If a Boolean expression consists of more than one part,
  2231. not all the parts may be evaluated. The evaluation of the expression
  2232. may stop, or "short circuit," partway through. Consider the following
  2233. two-part Boolean expression:
  2234.  
  2235.    IF <condition1> AND <condition2> THEN
  2236.  
  2237. If <condition1> evaluates to false, it isn't necessary to evaluate
  2238. <condition2>, because "false" AND "anything else" is still false.
  2239. Therefore, we can short circuit the expression and not evaluate
  2240. <condition2>.
  2241.  
  2242. The same rule applies to the following expression:
  2243.  
  2244.    IF <condition1> OR <condition2> THEN
  2245.  
  2246. If <condition1> is true, we do not need to evaluate <condition2>
  2247. because "true" OR "anything else" always evaluates to true.
  2248.  
  2249. Short-circuit Boolean expressions are desirable for two reasons.
  2250. First, they allow you to optimize code by evaluating only as much of
  2251. the Boolean expression as necessary. This can generate faster, more
  2252. efficient code. In the examples above, if <condition2> were very
  2253. complex, a short-circuit Boolean might speed up program execution by
  2254. evaluating the whole expression only when absolutely necessary.
  2255. Second, short-circuit Booleans can be used to prevent error
  2256. conditions. In the code example below, BASIC PDS 7.00 prevents the
  2257. "Division by zero" error in .EXE programs since it supports
  2258. short-circuit Booleans. QBX.EXE programs in BASIC 7.00, and QB.EXE and
  2259. .EXE programs in QuickBASIC 4.00, 4.00b, and 4.50, give the "Division by
  2260. zero" error.
  2261.  
  2262. BASIC 7.00 will short circuit IF expressions as long as doing so does
  2263. not change the semantics of the statement. The following is an
  2264. example:
  2265.  
  2266.    IF (a% < b%) OR (c! < d!) THEN PRINT
  2267.  
  2268. The compiler compares a% and b%. If a% is less than b%, the compiler
  2269. skips the floating-point comparison. On the other hand, consider the
  2270. following statements:
  2271.  
  2272.    DECLARE FUNCTION Foo! (p!)
  2273.    IF (a% < b%) OR (c! < Foo!(d!)) THEN PRINT
  2274.  
  2275. The compiler avoids the floating-point comparison when a% is less
  2276. than b%, but it still calls the function Foo. This is because existing
  2277. programs may rely on the side effects of the function Foo.
  2278.  
  2279. This feature affects the best way to write code in BASIC PDS 7.00.
  2280. Specifically, in complex IF, WHILE, DO LOOP WHILE, or DO LOOP UNTIL
  2281. conditions, the quickest conditions should appear first.
  2282.  
  2283. Code Example
  2284. ------------
  2285.  
  2286. The following program determines if a compiler supports short-circuit
  2287. Boolean optimization for an IF statement. Since it supports
  2288. short-circuit Booleans, BASIC PDS Version 7.00 prevents the "Division
  2289. by zero" error in the .EXE program. QBX.EXE programs in BASIC 7.00,
  2290. and QB.EXE and .EXE programs in QuickBASIC 4.00, 4.00b, and 4.50, give
  2291. the "Division by zero" error.
  2292.  
  2293. DEFINT A-Z
  2294. ON ERROR GOTO errorhandle
  2295. a = 1
  2296. b = 1
  2297. c = 0
  2298. CLS
  2299. LOCATE 10, 10
  2300.  
  2301. ' In the following IF statement, b / c is not executed if
  2302. ' short-circuit Booleans are supported because a = 1 evaluates to
  2303. ' true, and therefore, the whole expression is true. This is
  2304. ' because (true OR <anything>) evaluates to true.
  2305.  
  2306. IF (a = 1 OR ((b / c) = 1)) THEN
  2307.    ' If this PRINTs, then short-circuit Booleans are supported.
  2308.    PRINT "This compiler supports short-circuit Booleans"
  2309. END IF
  2310. terminate:
  2311. PRINT "End of program reached"
  2312. END
  2313. errorhandle:
  2314.    IF ERR = 11 THEN PRINT "Division by zero, Error="; ERR
  2315.    LOCATE 11, 10
  2316.    PRINT "This compiler does not support short-circuit Booleans"
  2317.    RESUME terminate     ' End the program.
  2318.  
  2319. Keywords:  B_QuickBas SR# S890703-44
  2320.  
  2321. COPYRIGHT Microsoft Corporation, 1989.
  2322. Updated  90/01/22 03:09
  2323. _____________________________________________________________________________
  2324. Q58122 CHAIN Line-Number Option Is in BASICA, Not in QuickBASIC
  2325. Microsoft QuickBASIC Compiler (QUICKBAS)
  2326. 4.00 4.00b 4.50
  2327. MS-DOS
  2328.  
  2329. Summary:
  2330.  
  2331. The documentation for the CHAIN statement misleadingly refers to the
  2332. line-number option. The line-number option is supported in the BASICA
  2333. and GW-BASIC Interpreters, but not in compiled BASICs. This fact is
  2334. documented in the same section, "Differences from BASICA," but not in
  2335. the same paragraph, and thus might cause confusion. References to the
  2336. line-number option apply only to modifying BASICA and GW-BASIC code.
  2337.  
  2338. This information applies to the following manuals:
  2339.  
  2340. 1. Page 94 of the "Microsoft QuickBASIC 4.0: BASIC Language Reference"
  2341.    manual for QuickBASIC Versions 4.00 and 4.00b for MS-DOS
  2342.  
  2343. 2. Page 94 of the "Microsoft BASIC Compiler 6.0: BASIC Language
  2344.    Reference" manual for Versions 6.00 and 6.00b for MS OS/2 and
  2345.    MS-DOS
  2346.  
  2347. 3. Page 38 of the "Microsoft BASIC 7.0: Language Reference" manual for
  2348.    Microsoft BASIC Professional Development System (PDS) Version 7.00
  2349.    for MS-DOS and MS OS/2
  2350.  
  2351. More Information:
  2352.  
  2353. The last two paragraphs of the "Differences from BASICA" section read
  2354. as follows:
  2355.  
  2356.    BASIC does not support the ALL, MERGE, or DELETE, OPTIONS available
  2357.    in BASICA, nor does it allow the specification of a line number.
  2358.  
  2359.    Without the line-number option, execution always starts at the
  2360.    beginning of the chained-to program. Thus, a chained-to program
  2361.    that chains back to a carelessly written chaining program can cause
  2362.    an endless loop.
  2363.  
  2364. Keywords:  SR# S900125-125 B_BasicCom B_GWBasicI
  2365.  
  2366. COPYRIGHT Microsoft Corporation, 1989.
  2367. Updated  90/01/31 04:08
  2368. _____________________________________________________________________________
  2369. Q57890 Overhead for /V and /W Event Trapping Is Reduced in BASIC 7.00
  2370. Microsoft BASIC Compiler (BASICCOM)
  2371. 6.00 6.00b 7.00 | 6.00 6.00b 7.00
  2372. MS-DOS          | OS/2
  2373.  
  2374. Summary:
  2375.  
  2376. The code overhead for BC /V is only 3 bytes per statement, and the
  2377. code overhead for BC /W is only 3 bytes per labeled or numbered line,
  2378. in Microsoft BASIC Professional Development System (PDS) Version 7.00
  2379. for MS-DOS and MS OS/2.
  2380.  
  2381. The overhead for these event trapping options is 5 bytes in Microsoft
  2382. QuickBASIC Versions 4.00, 4.00b, and 4.50 for MS-DOS, and in Microsoft
  2383. BASIC Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2.
  2384.  
  2385. More Information:
  2386.  
  2387. Event trapping for the ON <event> GOSUB statements is handled by
  2388. polling. The <event> can be COM(n), KEY(n), PEN, PLAY(), STRIG, and
  2389. TIMER. In BASIC 6.00, 6.00b, and 7.00, you can also use ON SIGNAL and
  2390. ON UEVENT.
  2391.  
  2392. At various points in your code, as controlled by the /V and /W options
  2393. and the <event> ON and <event> OFF statements, the compiler places a
  2394. call instruction to a routine that checks for events. /V places the
  2395. call on every statement in the module. /W only places the call on
  2396. every numbered or labeled line in the module. In QuickBASIC Versions
  2397. 4.00, 4.00b, and 4.50 and in Microsoft BASIC Compiler 6.00 and 6.00b,
  2398. this call occupies 5 bytes. In BASIC 7.00, this has been reduced to 3
  2399. bytes per call.
  2400.  
  2401. COPYRIGHT Microsoft Corporation, 1989.
  2402. Updated  90/02/01 05:04
  2403. _____________________________________________________________________________
  2404. Q33178 Example to Load OS/2 Disk Directory into String Array
  2405. Microsoft BASIC Compiler (BASICCOM)
  2406. 6.00 6.00b 7.00
  2407. OS/2
  2408.  
  2409. Summary:
  2410.  
  2411. This article discusses two methods to put a disk directory listing
  2412. into a string array under OS/2 protected mode. (Note: This article was
  2413. written because the FILES statement in BASIC only outputs to the
  2414. screen, not to a file or to string variables.)
  2415.  
  2416. Example 1 shows a simple method to SHELL to the DIR command, redirect
  2417. the output to a file, and input from the file into string variables.
  2418. (Example 1 also works correctly in MS-DOS.)
  2419.  
  2420. Example 2 shows how to invoke OS/2 API functions (DosFindFirst and
  2421. DosFindNext) to retrieve a disk directory into string variables.
  2422.  
  2423. This article applies to Microsoft BASIC Compiler Versions 6.00 and
  2424. 6.00b for MS-DOS and MS OS/2 and to Microsoft BASIC Professional
  2425. Development System (PDS) Version 7.00 for MS-DOS and MS OS/2.
  2426.  
  2427. Note: In Microsoft BASIC PDS 7.00, the DIR$ function can be used to
  2428. accomplish the same thing as these two routines show. The use of DIR$
  2429. is documented on Page 107 of the "Microsoft BASIC 7.0: Language
  2430. Reference" manual.
  2431.  
  2432. For an article about how to invoke MS-DOS (or OS/2 real mode)
  2433. functions to accomplish the same thing, query in this Knowledge Base
  2434. on the following keywords:
  2435.  
  2436.    INTERRUPT and FINDFIRST and FINDNEXT
  2437.  
  2438. More Information:
  2439.  
  2440. In MS OS/2 protected mode, you can use the API CALLs DosFindFirst and
  2441. DosFindNext to retrieve a disk directory listing and load it into a
  2442. string array, as shown in Example 2 below. Example 2 does NOT apply to
  2443. QuickBASIC Versions 4.50 and earlier because they cannot compile
  2444. programs for OS/2 protected mode.
  2445.  
  2446. Example 1 (the simplest technique) is as follows:
  2447.  
  2448. ' Works in QuickBASIC 2.00, 2.01, 3.00, 4.00, 4.00b, 4.50, and
  2449. ' BASIC compiler 6.00 and 6.00b.
  2450. nf = 200   ' Handles directory listing up to 200 lines.
  2451. DIM buffer$(nf)
  2452. INPUT "Enter Search Path: ", path$   ' Enter path such as c:
  2453. SHELLSTRING$ = "dir " + path$ + " >dirfile.dat"
  2454. SHELL SHELLSTRING$   ' SHELL to the MS-DOS DIRectory command.
  2455. OPEN "dirfile.dat" FOR INPUT AS #1
  2456. pntr% = 0
  2457. WHILE NOT EOF(1) AND pntr% < nf
  2458.   pntr% = pntr% + 1
  2459.   INPUT #1, buffer$(pntr%)  ' Inputs one directory line at a time.
  2460.   PRINT buffer$(pntr%)
  2461. WEND
  2462. CLOSE #1
  2463. KILL "dirfile.dat"
  2464. END
  2465.  
  2466. Example 2 is as follows:
  2467.  
  2468. The following sample program is for MS OS/2 protected mode (to be
  2469. compiled only in BASIC compiler Version 6.00 or 6.00b in MS OS/2
  2470. protected mode or BASIC PDS Version 7.00 in MS OS/2 protected mode):
  2471.  
  2472. 'The TYPE below is taken from the following include file: BSEDOSFL.BI
  2473. TYPE FILEFINDBUF
  2474.         fdateCreation   AS INTEGER
  2475.         ftimeCreation   AS INTEGER
  2476.         fdateLastAccess AS INTEGER
  2477.         ftimeLastAccess AS INTEGER
  2478.         fdateLastWrite  AS INTEGER
  2479.         ftimeLastWrite  AS INTEGER
  2480.         cbFile          AS LONG
  2481.         cbFileAlloc     AS LONG
  2482.         attrFile        AS INTEGER
  2483.         cchName         AS STRING * 1
  2484.         achName         AS STRING * 13
  2485. END TYPE
  2486.  
  2487. DECLARE FUNCTION DosFindFirst%( _
  2488.         BYVAL P1s AS INTEGER,_
  2489.         BYVAL P1o AS INTEGER,_
  2490.         SEG   P2  AS INTEGER,_
  2491.         BYVAL P3  AS INTEGER,_
  2492.         SEG   P4  AS FILEFINDBUF,_
  2493.         BYVAL P5  AS INTEGER,_
  2494.         SEG   P6  AS INTEGER,_
  2495.         BYVAL P7  AS LONG)
  2496.  
  2497. DECLARE FUNCTION DosFindNext%( _
  2498.         BYVAL P1 AS INTEGER,_
  2499.         SEG   P2 AS FILEFINDBUF,_
  2500.         BYVAL P3 AS INTEGER,_
  2501.         SEG   P4 AS INTEGER)
  2502.  
  2503. DEFINT a-z
  2504.  
  2505. DIM buffer AS FileFindBuf
  2506. DIM filelist(255) as string*13
  2507. DIM reserved  AS LONG
  2508.  
  2509. CLS
  2510.  
  2511. INPUT "Enter the Filename(s) : ";flname$
  2512. flname$=flname$+chr$(0)
  2513.  
  2514. atr= 0+2+4+16    'normal + hidden + system + subdirectory
  2515. dirh=1
  2516. searchcount=1
  2517. bufflen=36
  2518. x=DosFindFirst%(varseg(flname$),sadd(flname$),_
  2519.                 dirh,atr,buffer,bufflen,searchcount,reserved)
  2520. IF (X=0) THEN
  2521.    DO
  2522.      counter=counter+1
  2523.      filelist(counter)=buffer.achName
  2524.      buffer.achName=string$(13,32)  'assign blanks
  2525.    LOOP WHILE (DosFindNext%(dirh,buffer,bufflen,searchcount) = 0 )
  2526. ELSE
  2527.     PRINT "No MATCH was found"
  2528.     END
  2529. END IF
  2530.  
  2531. for i = 1 to counter
  2532.     print filelist(i)
  2533. next i
  2534.  
  2535. END
  2536.  
  2537. COPYRIGHT Microsoft Corporation, 1989.
  2538. Updated  90/02/01 05:04
  2539. _____________________________________________________________________________
  2540. Q36023 "Statement Illegal in TYPE block" Due to Line Identifier
  2541. Microsoft QuickBASIC Compiler (QUICKBAS)
  2542. 4.00 4.00b 4.50
  2543. MS-DOS
  2544.  
  2545. Summary:
  2546.  
  2547. Line labels and line numbers are not permitted within TYPE ... END
  2548. TYPE statement blocks. A "Statement illegal in TYPE block" error
  2549. message appears if this is attempted.
  2550.  
  2551. Under the TYPE ... END TYPE  statement (listed alphabetically) in the
  2552. "Microsoft QuickBASIC 4.0: BASIC Language Reference" manual for
  2553. QuickBASIC Versions 4.00 and 4.00b, in the "Microsoft QuickBASIC 4.5:
  2554. BASIC Language Reference" manual for QuickBASIC Version 4.50, and in
  2555. the "Microsoft BASIC Compiler 6.0: BASIC Language Reference" manual
  2556. for Microsoft BASIC Compiler Versions 6.00 and 6.00b, it needs to
  2557. mention that line identifiers are forbidden in TYPE ... END TYPE
  2558. statements.
  2559.  
  2560. This documentation omission has been corrected in the "Microsoft BASIC
  2561. 7.0: Language Reference" for Microsoft BASIC Professional Development
  2562. System (PDS) Version 7.00 for MS-DOS and MS OS/2.
  2563.  
  2564. More Information:
  2565.  
  2566. The BC.EXE compiler correctly gives the following error message in all
  2567. of the above products when you compile the code example farther below:
  2568.  
  2569.  10        partnumber AS STRING * 6
  2570.  ^ Identifier expected
  2571.  ^ Skipping forward to END TYPE statement
  2572.  DIM stockrecord AS stockitem
  2573.                     ^ TYPE not defined
  2574.  
  2575. Code Example
  2576. ------------
  2577.  
  2578. 'This gives "Statement illegal in TYPE block message,
  2579. 'due to the presence of line identifiers.
  2580. TYPE stockitem
  2581. 10        partnumber AS STRING * 6
  2582.           description AS STRING * 20
  2583.           unitprice AS SINGLE
  2584. abcd:     quantity   AS INTEGER
  2585. END TYPE
  2586. DIM stockrecord AS stockitem
  2587.  
  2588. Keywords:  docerr B_BasicCom
  2589.  
  2590. COPYRIGHT Microsoft Corporation, 1989.
  2591. Updated  90/02/01 05:04
  2592. _____________________________________________________________________________
  2593. Q39361 Sample Program; BASIC Invoking C Function That Returns String
  2594. Microsoft BASIC Compiler (BASICCOM)
  2595. 4.00 4.00b 4.50
  2596. MS-DOS
  2597.  
  2598. Summary:
  2599.  
  2600. The sample program below demonstrates a BASIC program calling a C
  2601. routine that returns a BASIC string descriptor. This programming
  2602. example is a variation of the sample program located on Page 310 of
  2603. the "Microsoft QuickBASIC 4.0: Learning and Using" manual.
  2604.  
  2605. This information applies to Microsoft QuickBASIC Versions 4.00, 4.00b,
  2606. and 4.50, to Microsoft BASIC Compiler Versions 6.00 and 6.00b for
  2607. MS-DOS and MS OS/2, and to Microsoft BASIC Professional Development
  2608. System (PDS) Version 7.00 for MS-DOS and MS OS/2.
  2609.  
  2610. More Information:
  2611.  
  2612. Note: The Microsoft C medium-memory model should be used to ensure
  2613. that the C string is in DGROUP.
  2614.  
  2615. Note: This information does not apply if using far string support in
  2616. BASIC PDS Version 7.00 or when running inside the QuickBASIC extended
  2617. (QBX.EXE) environment with BASIC PDS Version 7.00. For information on
  2618. programming with mixed-languages using far strings refer to Chapter
  2619. 13, "Mixed-Language Programming with Far Strings," in the "Microsoft
  2620. BASIC 7.0: Programmer's Guide."
  2621.  
  2622. The COMPILE and LINK instructions are as follows:
  2623.  
  2624.    BC test.bas;
  2625.    CL /AM /c tc.c
  2626.    LINK test tc /noe;
  2627.  
  2628. The BASIC routine is as follows:
  2629.  
  2630.    DECLARE FUNCTION t1$()
  2631.    a$ = t1$
  2632.    PRINT a$
  2633.  
  2634. The C function is as follows:
  2635.  
  2636.    struct bas_str{
  2637.            int sd_len;
  2638.            char *sd_addr;
  2639.            };
  2640.    char cstr[]="ABC";
  2641.    struct bas_str pascal t1()
  2642.    {
  2643.       struct bas_str str_des;
  2644.       str_des.sd_addr = cstr;
  2645.       str_des.sd_len = strlen(cstr);
  2646.       return (str_des);
  2647.    }
  2648.  
  2649. Keywords:  B_BasicCom SR# S881207-17
  2650.  
  2651. COPYRIGHT Microsoft Corporation, 1989.
  2652. Updated  90/02/02 05:05
  2653. _____________________________________________________________________________
  2654. Q45420 LPOS(0) and LPOS(1) Both Return Print Head Position for LPT1
  2655. Microsoft BASIC Compiler (BASICCOM)
  2656. 6.00 6.00b | 6.00 6.00b
  2657. MS-DOS     | OS/2
  2658.  
  2659. Summary:
  2660.  
  2661. The LPOS(0) and LPOS(1) functions both return the current position of
  2662. the print head within the printer buffer for LPT1. LPOS(2) returns
  2663. the current print position for LPT2.
  2664.  
  2665. On Page 263 of the "Microsoft BASIC Compiler 6.0: BASIC Language
  2666. Reference" manual for Versions 6.00 and 6.00b for MS OS/2 and MS-DOS,
  2667. the program example uses LPOS(0) to return the current position of the
  2668. line printer's print head within the print buffer, but no mention is
  2669. made of LPOS(0) in the function description. LPOS(0) operates the same
  2670. as LPOS(1), and there is no difference between the two functions.
  2671.  
  2672. This information applies also to Page 263 of the "Microsoft QuickBASIC
  2673. 4.0: BASIC Language Reference" manual for QuickBASIC Versions 4.00 and
  2674. 4.00b, to Page 224 of the "Microsoft QuickBASIC 4.5: BASIC Language
  2675. Reference" for Version 4.50, and to the QuickBASIC Version 4.50 QB
  2676. Advisor online Help system.
  2677.  
  2678. This documentation error was corrected on Page 204 of the "Microsoft
  2679. BASIC 7.0: Language Reference" manual for Microsoft BASIC Professional
  2680. Development System (PDS) Version 7.00.
  2681.  
  2682. Keywords:  docerr B_QuickBas
  2683.  
  2684. COPYRIGHT Microsoft Corporation, 1989.
  2685. Updated  90/02/03 04:18
  2686. _____________________________________________________________________________
  2687. Q58025 DRAW Statement's Scale (S) Command Has Default Scale Factor 4
  2688. Microsoft QuickBASIC Compiler (QUICKBAS)
  2689. 2.00 2.01 3.00 4.00 4.00b 4.50
  2690. MS-DOS
  2691.  
  2692. Summary:
  2693.  
  2694. The DRAW statement can scale the lines that it draws. The scale factor
  2695. is specified by including the "S" command, followed by a number from 1
  2696. to 255, before the commands that actually draw the lines.
  2697.  
  2698. Certain manuals listed below fail to state that the default DRAW scale
  2699. factor is 4, and they give the wrong formula to calculate the actual
  2700. distance drawn.
  2701.  
  2702. A scale factor of 8 must follow the "S" command to make a drawing
  2703. twice as large. A scale factor of 2 makes a drawing half as large (4 *
  2704. 1/2 = 2).
  2705.  
  2706. More Information:
  2707.  
  2708. The following is the corrected formula for the DRAW "S n" (set Scale
  2709. factor n) command:
  2710.  
  2711.    The default scale factor n is 4, which causes no scaling. The scale
  2712.    factor multiplied by movement-command arguments (U, D, L, R, or
  2713.    relative M commands) divided by 4 gives the actual distance moved.
  2714.  
  2715. This correction applies to the DRAW "S n" command in the following
  2716. manuals:
  2717.  
  2718. 1. Page 138 of the "Microsoft QuickBASIC 4.5: BASIC Language
  2719.    Reference" manual for Version 4.50
  2720.  
  2721.    Note: The QB Advisor online Help of QuickBASIC 4.50 correctly
  2722.    includes the fact that 4 is the default scale factor.
  2723.  
  2724. 2. Page 165 of the "Microsoft QuickBASIC 4.0: BASIC Language
  2725.    Reference" manual for Versions 4.00 and 4.00b
  2726.  
  2727. 3. Page 165 of the "Microsoft BASIC Compiler 6.0: BASIC Language
  2728.    Reference" manual for Versions 6.00 and 6.00b
  2729.  
  2730. 4. Page 255 of the "Microsoft QuickBASIC Compiler" Version 2.0x and
  2731.    3.00 manual
  2732.  
  2733. This documentation error was corrected in the "Microsoft BASIC 7.0:
  2734. Language Reference" manual, provided with Microsoft BASIC Professional
  2735. Development System (PDS) Version 7.00 for MS-DOS and MS OS/2.
  2736.  
  2737. Knowing that the default scale factor is 4, it is easy to calculate
  2738. the length of any line given any possible scale factor. The following
  2739. formula can be used to do this:
  2740.  
  2741.    <scaled line length> = (<scale factor> / 4) * <unscaled line length>
  2742.  
  2743. Here <unscaled line length> is the unscaled distance that is given
  2744. immediately after the drawing commands.
  2745.  
  2746. Code Example
  2747. ------------
  2748.  
  2749. The following program examples illustrate the correct use of the "S"
  2750. command and how some scale factors affect what will be drawn. This
  2751. example requires an EGA or VGA card. If you have a different card,
  2752. change the SCREEN statement to an appropriate SCREEN mode.
  2753.  
  2754. SCREEN 9
  2755. 'The "R" command of the DRAW statement draws a line to the right of
  2756. 'the current pixel position. The distance traveled is the number
  2757. 'entered after the command.
  2758. DRAW "R10"     'No scale factor, line is 10 pixels long.
  2759. DRAW "S1R10"   '(1/4) * 10 = 3 pixels long (rounded up).
  2760. DRAW "S2R10"   '(2/4) * 10 = 5 pixels long.
  2761. DRAW "S3R10"   '(3/4) * 10 = 8 pixels long (rounded up).
  2762. DRAW "S4R10"   '(4/4) * 10 = 10 pixels long.
  2763. DRAW "S5R10"   '(5/4) * 10 = 13 pixels long (rounded up.
  2764. DRAW "S6R10"   '(6/4) * 10 = 15 pixels long.
  2765. DRAW "S7R10"   '(7/4) * 10 = 18 pixels long (rounded up).
  2766. DRAW "S8R10"   '(8/4) * 10 = 20 pixels long.
  2767.  
  2768. Keywords:  docerr B_BasicCom SR# S891228-74
  2769.  
  2770. COPYRIGHT Microsoft Corporation, 1989.
  2771. Updated  90/02/06 03:46
  2772. _____________________________________________________________________________
  2773. Q44034 How Bits in PAINT Tiling String Represent Pixels in BASIC
  2774. Microsoft QuickBASIC Compiler (QUICKBAS)
  2775. 2.00 2.01 3.00 4.00 4.00b 4.50
  2776. MS-DOS
  2777.  
  2778. Summary:
  2779.  
  2780. For the best explanation of tiling with the PAINT statement, please
  2781. refer to one of the following manuals:
  2782.  
  2783. 1. Pages 181 to 191 (Section 5.8.2, "Painting with Patterns: Tiling")
  2784.    of the "Microsoft QuickBASIC 4.5: Programming in BASIC" manual for
  2785.    Version 4.50
  2786.  
  2787. 2. Pages 228 to 239 (Section 5.8.2, "Painting with Patterns: Tiling")
  2788.    of the "Microsoft QuickBASIC 4.0: Programming in BASIC: Selected
  2789.    Topics" manual for Versions 4.00 and 4.00b
  2790.  
  2791. 3. Pages 228 to 239 (Section 5.8.2, "Painting with Patterns: Tiling")
  2792.    of "Microsoft BASIC Compiler 6.0: Programming in BASIC: Selected
  2793.    Topics" for Versions 6.00 and 6.00b for MS OS/2 and MS-DOS
  2794.  
  2795. 4. Pages 179 to 189 ("Painting with Patterns: Tiling") of "Microsoft
  2796.    BASIC 7.0: Programmer's Guide" for Microsoft BASIC Professional
  2797.    Development System (PDS) Version 7.00 for MS OS/2 and MS-DOS
  2798.  
  2799. The tiling information on these pages also applies to QuickBASIC 2.00,
  2800. 2.01, and 3.00 (which support only SCREENs 0, 1, 2, 7, 8, 9, 10).
  2801.  
  2802. Please also see a separate article in this Knowledge Base, which can be
  2803. found by querying on the following words:
  2804.  
  2805.    PAINT and tiling and QuickBASIC
  2806.  
  2807. More Information:
  2808.  
  2809. Consider the following sentence taken from the PAINT statement in the
  2810. language reference manual:
  2811.  
  2812.    In the tile string, each byte masks eight bits along the x-axis
  2813.    when putting down points.
  2814.  
  2815. The effect of each bit on screen pixels depends upon how many
  2816. attributes are in that screen mode. On two-attribute screen modes
  2817. (SCREENs 2, 3, 4, 11), each bit in the tile string directly represents
  2818. a pixel, and each byte in the tile string represents 8 pixels along
  2819. the x-axis. In graphics screens with more than two attributes (1, 7,
  2820. 8, 9, 10, 12, 13), each pixel is represented by more than 1 bit (in
  2821. order to carry the extra color information). In SCREEN 13, which has 8
  2822. bits per pixel, tiling is not very useful. Tiling is most flexible in
  2823. SCREENs 2, 3, 4, and 11.
  2824.  
  2825. Keywords:  SR# S890427-81 B_BasicCom
  2826.  
  2827. COPYRIGHT Microsoft Corporation, 1989.
  2828. Updated  90/02/08 04:25
  2829. _____________________________________________________________________________
  2830. Q58567 Any EGA/VGA Video RAM Above 256K Not Usable in Compiled BASIC
  2831. Microsoft QuickBASIC Compiler (QUICKBAS)
  2832. 2.00 2.01 3.00 4.00 4.00b 4.50
  2833. MS-DOS
  2834.  
  2835. Summary:
  2836.  
  2837. Any RAM above 256K on an EGA or VGA video card cannot be used to store
  2838. screen pages during the execution of a compiled BASIC program.
  2839.  
  2840. This information applies to Microsoft QuickBASIC Versions 2.00, 2.01,
  2841. 3.00, 4.00, 4.00b, and 4.50 for MS-DOS, to Microsoft BASIC Compiler
  2842. Versions 6.00 and 6.00b for MS-DOS, and to Microsoft BASIC
  2843. Professional Development System (PDS) Version 7.00 for MS-DOS.
  2844.  
  2845. These compilers are compatible with video cards that conform to the
  2846. IBM standard. Accessing video RAM above 256K is not part of this
  2847. standard.
  2848.  
  2849. More Information:
  2850.  
  2851. For example, when reading the documentation on the SCREEN statement in
  2852. either the manuals or online Help included with the above products, it
  2853. may appear that more than 2 pages of screen memory are available to a
  2854. 512K VGA card operating in screen mode 9. Footnote 2 on the bottom of
  2855. Page 314 of the "Microsoft BASIC 7.0: Language Reference" manual
  2856. states the following:
  2857.  
  2858.    Pages = Screen memory divided by page size. Eight page maximum,
  2859.            one page minimum.
  2860.  
  2861. The page size of screen 9 for VGA is 128K. Applying the above formula,
  2862. we get the following:
  2863.  
  2864.    Pages = 512K / 128K = 4 pages
  2865.  
  2866. However, 4 pages is incorrect because all the memory above 256K on
  2867. the VGA card is not usable. Therefore, the maximum number of pages is
  2868. as follows:
  2869.  
  2870.    Pages = 256K / 128K = 2 pages
  2871.  
  2872. Keywords:  SR# S900201-17 B_BasicCom
  2873.  
  2874. COPYRIGHT Microsoft Corporation, 1989.
  2875. Updated  90/02/14 04:06
  2876. _____________________________________________________________________________
  2877. Q58123 "Feature Unavailable" Using FRE(-3) in .EXE Compiled in 7.00
  2878. Microsoft BASIC Compiler (BASICCOM)
  2879. 7.00
  2880. MS-DOS
  2881.  
  2882. Summary:
  2883.  
  2884. The FRE(-3) function, which returns available expanded memory in the
  2885. QuickBASIC Extended (QBX.EXE) environment, normally gives a "Feature
  2886. Unavailable" (run-time error 73) in .EXE files created with BC.EXE. An
  2887. exception is if an executable .EXE file is linked with overlays that
  2888. are each no larger than 64K, and if a LIM 4.0 EMS expanded memory
  2889. driver (defined below) is installed, then the FRE(-3) function returns
  2890. a value for the amount of free expanded memory. This information
  2891. applies to Microsoft BASIC Professional Development System (PDS)
  2892. Version 7.00 for MS-DOS.
  2893.  
  2894. More Information:
  2895.  
  2896. The FRE(-3) function returns the amount of free LIM 4.0 EMS expanded
  2897. memory available for arrays, SUBs, and functions in the QBX.EXE
  2898. environment.
  2899.  
  2900. Note that the only way that compiled BASIC .EXE applications can take
  2901. advantage of expanded memory is with linked overlays, but then only if
  2902. each overlay is smaller than 64K. (If expanded memory is not
  2903. accessible, overlays just swap to disk.) The FRE(-3) function returns
  2904. a value for an .EXE program only when a LIM 4.0 EMS driver is
  2905. installed and the .EXE program is able to successfully store its
  2906. overlays in expanded memory.
  2907.  
  2908. To check the amount of available expanded memory from an EXE program,
  2909. see Pages 204-206 in Ray Duncan's "Advanced MS-DOS Programming, 2nd
  2910. Edition" (Microsoft Press, 1988). The method described there uses
  2911. assembly language and interrupts.
  2912.  
  2913. Note: LIM 4.0 EMS is defined as follows:
  2914.  
  2915.    LIM  = Lotus, Intel, Microsoft
  2916.    4.0  = Version number 4.0 (of the standard LIM EMS)
  2917.    EMS  = Expanded Memory Specification, a standard for addressing
  2918.           expanded memory
  2919.  
  2920. For more information about linker overlays in BASIC PDS 7.00, search
  2921. for a separate article with the following keywords:
  2922.  
  2923.    BASIC and 7.00 and linker and overlays and modules
  2924.  
  2925. Also see Pages 612-614 of the "Microsoft BASIC 7.0: Programmer's
  2926. Guide," in the section "Linking with Overlays".
  2927.  
  2928. Keywords:  SR# S900125-132
  2929.  
  2930. COPYRIGHT Microsoft Corporation, 1989.
  2931. Updated  90/02/27 06:36
  2932. _____________________________________________________________________________
  2933. Q58125 "Error Loading File (x.QLB)" After QBX /L x; Must Compile /Fs
  2934. Microsoft BASIC Compiler (BASICCOM)
  2935. 7.00
  2936. MS-DOS
  2937.  
  2938. Summary:
  2939.  
  2940. The error "Error in loading file (xxx.QLB )" occurs when loading a
  2941. Quick library into QBX.EXE if the Quick library contains BASIC modules
  2942. compiled without the BC /Fs (far strings) option. The BC /Fs option is
  2943. needed because far strings are always used in the QuickBASIC Extended
  2944. (QBX) environment.
  2945.  
  2946. To create a Quick library that is usable in QBX, recompile with the BC
  2947. /Fs option and relink (LINK /QU) to make a new Quick library.
  2948.  
  2949. This information applies to Microsoft BASIC Professional Development
  2950. System (PDS) Version 7.00 for MS-DOS.
  2951.  
  2952. The necessity of using the /Fs option to make Quick libraries is
  2953. documented on Page 617 of the "Microsoft BASIC 7.0: Programmer's
  2954. Guide." For more information on Quick libraries, see Chapter 19,
  2955. "Creating and Using Quick Libraries."
  2956.  
  2957. Keywords:  SR# S900126-5
  2958.  
  2959. COPYRIGHT Microsoft Corporation, 1989.
  2960. Updated  90/02/27 06:36
  2961. _____________________________________________________________________________
  2962. Q32787 "Overflow," "Subscript Out of Range," >32,767 Array Elements
  2963. Microsoft QuickBASIC Compiler (QUICKBAS)
  2964. 4.00 4.00b 4.50
  2965. MS-DOS
  2966.  
  2967. Summary:
  2968.  
  2969. Page 156 of the "Microsoft QuickBASIC 4.0: BASIC Language Reference"
  2970. for Versions 4.00 and 4.00b and the "Microsoft BASIC Compiler 6.0:
  2971. BASIC Language Reference" for Versions 6.00 and 6.00b for MS-DOS and
  2972. MS OS/2 correctly states that an array dimension can have subscripts
  2973. from -32,768 to 32,767. This is also stated on Page 103 of the
  2974. "Microsoft BASIC 7.0: Language Reference" manual for Microsoft BASIC
  2975. Professional Development System (PDS) Version 7.00. For example DIM
  2976. Z%(-2000 TO 3000), which has 5001 elements, is legal.
  2977.  
  2978. However, these pages fail to mention that the TOTAL NUMBER of elements
  2979. in any one dimension of an array cannot exceed 32,767 (32K minus one).
  2980. For example, the following DIM statements are not allowed because they
  2981. make an array with more than 32,767 elements in one dimension:
  2982.  
  2983.    DIM X(-10000 TO 25000)  ' 35,001 elements is too many.
  2984.    DIM A%(0 TO 32767)  ' 32,768 elements is one too many.
  2985.  
  2986. To make an array that exceeds 32,767 total elements, you must
  2987. dimension it with two or more dimensions (making sure that no one
  2988. dimension has more than 32,767 elements; you must also compile with
  2989. the /AH option).
  2990.  
  2991. Below is an explanation of array usages that could give one of the
  2992. following errors:
  2993.  
  2994.    "Overflow," "Math Overflow," "Subscript Out of Range,"
  2995.    "Array Too Big," "Out of Memory"
  2996.  
  2997. More Information:
  2998.  
  2999. To dimension an array larger than 64K, you must make the array dynamic
  3000. and compile with the /AH (huge array) option, as in the following
  3001. example:
  3002.  
  3003.    REM This program must be compiled with the /AH option
  3004.    ' $DYNAMIC
  3005.    OPTION BASE 1
  3006.    DIM A%(20000, 2)  ' 40000 elements, taking 80000 bytes in memory.
  3007.    DIM B%(20000, 4)  ' 80000 elements, taking 160000 bytes in memory.
  3008.  
  3009. The following is a list of array-related error messages and their
  3010. possible causes:
  3011.  
  3012. 1. Compiling an array that has a subscript larger than +32,767 or
  3013.    smaller than -32,768 in the DIM statement causes an "Overflow"
  3014.    error in the QB.EXE editor. If you compile it with BC.EXE, you
  3015.    receive a "Math Overflow" error, as follows:
  3016.  
  3017.       ' $DYNAMIC
  3018.       DIM s%(33000)  ' produces "overflow" error in QB.EXE editor
  3019.                         ' and "math overflow" error in BC.EXE.
  3020.  
  3021. 2. A "Subscript out of range" error occurs in the QB.EXE editor at
  3022.    run time if you DIMension more than 32,767 elements in one
  3023.    dimension, as in the following example (invoke QB /AH):
  3024.  
  3025.       ' $DYNAMIC
  3026.       DIM X%(-10000 TO 25000) ' Cannot use 35,000 elements in
  3027.                                  ' one dimension.
  3028.  
  3029.    Compiling the above program with BC.EXE does not cause a compile
  3030.    error, but gives a "Subscript Out of Range" error at run time in
  3031.    the .EXE program. (Be sure to compile with the BC /D (debug) option
  3032.    to properly trap array-bounds errors.)
  3033.  
  3034.    Note that if the array has exactly 32,768 elements, the error will
  3035.    not occur on the DIM statement in QB.EXE or a compiled .EXE program;
  3036.    the error will occur only when an array element is used later:
  3037.  
  3038.    REM $DYNAMIC
  3039.    DIM Y%(0 TO 32767)  ' Cannot use 32768 elements in one dimension.
  3040.    PRINT Y%(2000)  ' "Subscript Out of Range" occurs here, not on DIM.
  3041.  
  3042. 3. An "Array Too Big" or "Subscript Out of Range" error will
  3043.    display if the array exceeds 64K, is not dynamic, and was not
  3044.    compiled with the /AH option. You must either make the array
  3045.    dynamic and compile with /AH or make the array smaller than 64K.
  3046.    If a dynamic array is larger than 128K, its array elements must
  3047.    have a size that is a power of 2 (2, 4, 8, 16, 32, 64, 128, 256,
  3048.    512, etc.) so that array elements do not overlap on boundaries
  3049.    that are divisible by 64K.
  3050.  
  3051. 4. An "Out of Memory" error means you have exceeded available RAM
  3052.    at run time. You should reduce the size of arrays or code, or
  3053.    try running the program as an .EXE program instead of inside the
  3054.    QB.EXE environment. You can use the FRE function to determine
  3055.    run-time memory usage.
  3056.  
  3057. Note that QuickBASIC Versions 2.00, 2.01, and 3.00 are limited to
  3058. arrays that do not exceed 64K in size or 32,767 elements per
  3059. dimension.
  3060.  
  3061. Note: 1K is equal to 1024 bytes.
  3062.  
  3063. Keywords:  B_BasicCom docerr
  3064.  
  3065. COPYRIGHT Microsoft Corporation, 1989.
  3066. Updated  90/02/27 06:36
  3067. _____________________________________________________________________________
  3068. Q57385 INT86OLD & INT86XOLD Not in QB 4.50 or BASIC 7.00 Help, Manual
  3069. Microsoft QuickBASIC Compiler (QUICKBAS)
  3070. 4.50
  3071. MS-DOS
  3072.  
  3073. Summary:
  3074.  
  3075. The "Microsoft BASIC 7.0: BASIC Language Reference" manual fails to
  3076. document the INT86OLD and INT86XOLD routines.
  3077.  
  3078. Also, CALL INT86OLD and CALL INT86XOLD are not documented in the
  3079. online Help systems for either QB.EXE in QuickBASIC 4.50 or for
  3080. QBX.EXE, which comes with Microsoft BASIC Professional Development
  3081. System (PDS) Version 7.00.
  3082.  
  3083. A complete description of INT86OLD and INT86XOLD are provided below
  3084. for owners of BASIC PDS 7.00, and for owners of QuickBASIC 4.50 who do
  3085. not own a copy of the "Microsoft QuickBASIC 4.5: BASIC Language
  3086. Reference."
  3087.  
  3088. This information applies to Microsoft BASIC PDS 7.00 for MS-DOS and to
  3089. Microsoft QuickBASIC 4.50 for MS-DOS.
  3090.  
  3091. More Information:
  3092.  
  3093. Note that CALL INT86OLD and CALL INT86XOLD are documented in the
  3094. "Microsoft QuickBASIC 4.5: BASIC Language Reference" manual for
  3095. QuickBASIC 4.50. The following description of INT86OLD and INT86XOLD
  3096. is taken from Page 72 of that manual [additional comments are in
  3097. brackets ([])]:
  3098.  
  3099.                       CALL INT86OLD Statements
  3100.  
  3101. ACTION: Allows programs to perform DOS system calls
  3102.  
  3103. SYNTAX: CALL INT86OLD (intno, inarray(), outarray())
  3104.         CALL INT86XOLD (intno, inarray(), outarray())
  3105.  
  3106. REMARKS: The CALL INTERRUPT statement provides an easier way to make
  3107.          DOS system calls. See the entry for CALL INTERRUPT for more
  3108.          information. The following list describes the arguments to
  3109.          INT86OLD and INT86XOLD:
  3110.  
  3111. Argument    Description
  3112. -----------------------
  3113. intno       The DOS interrupt to perform. It is an integer between 0
  3114.             and 255. See your DOS documentation for the interrupt
  3115.             numbers.
  3116.  
  3117. inarray()   An integer array specifying the register values when the
  3118.             interrupt is performed.
  3119.  
  3120.             INT86OLD uses an eight-element array, while INT86XOLD
  3121.             uses a ten-element array. Table R.1 lists the array
  3122.             elements and the corresponding registers.
  3123.  
  3124. outarray()  Contains the post-interrupt register values. It has the
  3125.             same structure as inarray().
  3126.  
  3127. If an error occurs, intno = -1 and values in outarray are
  3128. unchanged. Errors are caused by in_no not being in the range 0 - 255.
  3129.  
  3130. Table R.1 INT86OLD and INT86XOLD Register Values
  3131. ------------------------------------------------
  3132. Array Element         Register
  3133. ------------------------------------------------
  3134. inarray(x)              AX
  3135. inarray(x+1)            BX
  3136. inarray(x+2)            CX
  3137. inarray(x+3)            DX
  3138. inarray(x+4)            BP
  3139. inarray(x+5)            SI
  3140. inarray(x+6)            DI
  3141. inarray(x+7)            FLAGS
  3142. inarray(x+8)*           DS
  3143. inarray(x+9)*           ES
  3144. ------------------------------------------------
  3145. *  These array elements are used only by INT86XOLD. To use the
  3146.    current run-time values of DS and ES, assign the value -1 to array
  3147.    elements 8 and 9.
  3148.  
  3149. The INT86OLD and INT86XOLD routines alter all registers except
  3150. BP and DS.
  3151.  
  3152. INT86OLD and INT86XOLD provide compatibility with older [QuickBASIC
  3153. 2.00, 2.01, or 3.00] programs using INT86 and INT86X. Like the INT86
  3154. and INT86X routines, INT86OLD and INT86XOLD are distributed in a Quick
  3155. library [QB.QLB for QB.EXE and QBX.QLB for QBX. EXE] and in a
  3156. conventional library [QB.LIB for QuickBASIC 4.x and QBX.LIB for BASIC
  3157. PDS 7.00] on the distribution disks. The disks also contain a header
  3158. file [QB.BI for QuickBASIC 4.x or QBX.BI for BASIC PDS 7.00] for use
  3159. with the procedures. See the disk-contents list for specific
  3160. information.
  3161.  
  3162. Note that INT86OLD and INT86XOLD do not require the use of VARPTR.
  3163. Also, the register values are stored in the arrays beginning with the
  3164. first array element.
  3165.  
  3166. EXAMPLE
  3167. -------
  3168.  
  3169. 'This example uses INT86OLD to open a file and place some text in it.
  3170.  
  3171. ' Note: To use CALL INTERRUPT, you must load the Quick library QB.LIB
  3172. '       with QuickBASIC. The program also uses the QB.BI header file.
  3173.  
  3174. ' Include header file for INT86OLD, etc.
  3175. $INCLUDE:'QB.BI'
  3176.  
  3177. DIM INARY%(7),OUTARY%(7)          'Define input and output
  3178.                                   'arrays for INT86.
  3179. '
  3180. ' Define register-array indices to
  3181. ' make program easier to understand.
  3182. CONST AX=0, BX=1, CX=2, DX=3, BP=4, SI=5, DI=6, FL=7
  3183. '
  3184. INARY%(AX) = &H3C00               'DOS function to create a file.
  3185. INARY%(CX) = 0                    'DOS attribute for created file.
  3186. TEMP$="FOO.TXT"+CHR$(0)
  3187. INARY%(DX) = SADD(TEMP$)
  3188.                                   'Pointer to file-name string
  3189.                                   'with zero byte termination.
  3190.  
  3191. CALL INT86OLD(&H21,INARY%(),OUTARY%())
  3192.                                   'Perform the creation.
  3193. '
  3194. INARY%(BX) = OUTARY%(AX)         'Move created file handle for write.
  3195. INARY%(AX) = &H4000               'DOS function to write to file.
  3196. TEXT$ = "hello, world"+CHR$(13)+CHR$(10)
  3197.                                   'Define text to write to file.
  3198. INARY%(CX) = LEN(TEXT$)           'Get length of text string.
  3199. INARY%(DX) = SADD(TEXT$)          'Get address of text string.
  3200. CALL INT86OLD(&H21,INARY%(),OUTARY%())
  3201.                                   'Perform the write.
  3202. '
  3203. INARY%(AX) = &H3E00               'DOS function to close a file.
  3204. CALL INT86OLD(&H21,INARY%(),OUTARY%())
  3205.                                   'Perform the close.
  3206.  
  3207. Keywords:  SR# S891226-2 docerr B_BasicCom
  3208.  
  3209. COPYRIGHT Microsoft Corporation, 1989.
  3210. Updated  90/02/27 06:36
  3211. _____________________________________________________________________________
  3212. Q58790 Limits for Nesting Arrays in TYPE Statements in BASIC 7.00
  3213. Microsoft BASIC Compiler (BASICCOM)
  3214. 7.00   | 7.00
  3215. MS-DOS | OS/2
  3216.  
  3217. Summary:
  3218.  
  3219. In the QBX.EXE (QuickBASIC Extended) environment for MS-DOS, you can
  3220. have up to 16 nested-array TYPE definitions (see Code Example 1,
  3221. below). If you exceed 16 nestings, you get a "Subscript out of range"
  3222. error.
  3223.  
  3224. In the QBX.EXE environment, nonarray nested TYPEs (see Code Example 2,
  3225. below) can be nested until you run out of memory.
  3226.  
  3227. As for the BC.EXE compiler, the limit on the number of TYPE statements
  3228. for one module is 240 whether they are nested or nonnested TYPE
  3229. definitions. If the number of TYPEs of all kinds exceeds 240, the
  3230. BC.EXE compiler gives an error of "Too Many Type statements".
  3231.  
  3232. This information applies to Microsoft BASIC Professional Development
  3233. System (PDS) Version 7.00 for MS-DOS and MS OS/2.
  3234.  
  3235. More Information:
  3236.  
  3237. (This information does not apply to versions of Microsoft BASIC
  3238. earlier than 7.00 because they do not support arrays in user-defined
  3239. TYPEs.)
  3240.  
  3241. Note that only static (nondynamic) arrays can be placed in TYPE
  3242. statements in BASIC PDS 7.00.
  3243.  
  3244. Code Example 1 (Arrays of Nested TYPEs)
  3245. ---------------------------------------
  3246.  
  3247. OPTION BASE 1
  3248.  
  3249. TYPE test1
  3250.    a AS STRING * 1
  3251. END TYPE
  3252.  
  3253. TYPE test2
  3254.    b2(1) AS test1        'Nest it as the first TYPE
  3255. END TYPE
  3256. .
  3257. .
  3258. .
  3259. TYPE test15
  3260.    b15(1) AS test14
  3261. END TYPE
  3262.  
  3263. TYPE test16
  3264.    b16(1) AS test15
  3265. END TYPE
  3266.  
  3267. DIM temp(1000) AS test16
  3268.  
  3269.  
  3270. Code Example 2 (Nonarray Variables of Nested TYPEs)
  3271. ---------------------------------------------------
  3272.  
  3273. TYPE test1
  3274.    a AS INTEGER
  3275. END TYPE
  3276.  
  3277. TYPE test2
  3278.    b2 AS test1
  3279. END TYPE
  3280.  
  3281. TYPE test3
  3282.    b3 AS test2
  3283. END TYPE
  3284. .
  3285. .
  3286. .
  3287. TYPE test237
  3288.    b237 AS test236
  3289. END TYPE
  3290.  
  3291. TYPE test238
  3292.    b238 AS test237
  3293. END TYPE
  3294.  
  3295. TYPE new
  3296.    none AS INTEGER    'Put in to see if the TYPEs had to be nested
  3297. END TYPE
  3298.  
  3299. TYPE new2
  3300.    none2 AS INTEGER
  3301. END TYPE
  3302.  
  3303. DIM temp(100) as test238
  3304.  
  3305. COPYRIGHT Microsoft Corporation, 1989.
  3306. Updated  90/03/01 07:19
  3307. _____________________________________________________________________________
  3308. Q38278 User-Defined TYPE vs. FIELD & MKS in Random-Access File PUT#
  3309. Microsoft QuickBASIC Compiler (QUICKBAS)
  3310. 4.00 4.00b 4.50
  3311. MS-DOS
  3312.  
  3313. Summary:
  3314.  
  3315. When a numeric data type (INTEGER, LONG, SINGLE, DOUBLE, or CURRENCY)
  3316. stored in a user-defined TYPE is PUT directly to a random-access file
  3317. as the third argument of the PUT statement, the values stored in the
  3318. file are stored the same as those written with PUT using variables
  3319. defined in a FIELD statement and initialized with LSET A$ = MKI$(i).
  3320.  
  3321. This is true for all TYPEs, except if you compile with the /MBF
  3322. option. When you compile with /MBF, SINGLE or DOUBLE user-defined
  3323. TYPEs still store on disk in IEEE format instead of in MBF format,
  3324. which is not what you desire when you compile /MBF.
  3325.  
  3326. This information applies to QuickBASIC Versions 4.00, 4.00b, and 4.50,
  3327. to Microsoft BASIC Compiler Versions 6.00 and 6.00b for MS-DOS and MS
  3328. OS/2, and to Microsoft BASIC Professional Development System (PDS)
  3329. Version 7.00 for MS-DOS and MS OS/2.
  3330.  
  3331. More Information:
  3332.  
  3333. When you compile with the /MBF compiler option, you cannot use a
  3334. SINGLE or DOUBLE declaration in user-defined variables that are used
  3335. as the third argument of a random-access PUT. When compiling /MBF, you
  3336. must use STRING*4 and STRING*8 to PUT single- and double-precision
  3337. numbers that are in a user-defined TYPE; this requires using MKS, MKD,
  3338. CVS, and CVD for conversion of those numbers between string and
  3339. numeric TYPEs.
  3340.  
  3341. More information on this subject can be found under "Using
  3342. Random-Access Files" on Pages 126-134 in the "Microsoft QuickBASIC
  3343. 4.0: Programming in BASIC: Selected Topics" manual supplied with
  3344. QuickBASIC Version 4.00 or 4.00b and in the "Microsoft BASIC Compiler
  3345. 6.0: Programming in BASIC: Selected Topics" manual supplied with
  3346. Microsoft BASIC Compiler Version 6.00 or 6.00b, or starting on Page
  3347. 102 in the "Microsoft BASIC 7.0: Programmer's Guide" for Microsoft
  3348. BASIC PDS 7.00.
  3349.  
  3350. User-defined TYPEs are not available in earlier versions.
  3351.  
  3352. If you define an integer, such as in a user-defined TYPE, it is stored
  3353. as 2 bytes. A long integer is stored as 4 bytes. A single-precision
  3354. variable is stored as 4 bytes. A double-precision variable is stored
  3355. as 8 bytes. Fixed-length strings are stored with 1 byte per character.
  3356.  
  3357. Variable-length-string variables (such as x$ AS STRING) cannot be
  3358. placed in a user-defined TYPE record. For information about the
  3359. special way variable-length strings are stored on disk when written
  3360. directly as the third argument of the PUT# statement, search for a
  3361. separate article with the following words:
  3362.  
  3363.    PUT and THIRD and "BAD RECORD LENGTH" and VARIABLE and STRING
  3364.  
  3365. Code Example
  3366. ------------
  3367.  
  3368. The code example below shows two equivalent methods of reading and
  3369. writing to random files when you compile without the /MBF option. One
  3370. method uses user-defined-TYPE records, and the other (older) method
  3371. uses variable-length strings in a FIELD statement to define the file
  3372. record. Note how much simpler your code is when you use user-defined
  3373. TYPE records instead of records defined by a FIELD statement.
  3374.  
  3375.    ' Note: This program is NOT compatible with the /MBF compiler
  3376.    ' option because of the single- and double-precision TYPEs in the
  3377.    ' user-defined TYPE. When compiling /MBF, you must use STRING*4
  3378.    ' and STRING*8 to PUT single- and double-precision numbers that
  3379.    ' are in a user-defined TYPE, which requires rewriting this program
  3380.    ' to use MKS, MKD, CVS, and CVD for conversion of those numbers.
  3381.    ' INTEGER, LONG, and STRING TYPEs are independent of the /MBF option.
  3382.    TYPE Users
  3383.        i AS INTEGER
  3384.        l AS LONG
  3385.        s AS SINGLE
  3386.        d AS DOUBLE
  3387.        a AS STRING * 15
  3388.    END TYPE
  3389.    DIM dat AS Users
  3390.    dat.i = 32000
  3391.    dat.l = 21345678
  3392.    dat.s = 1234.567
  3393.    dat.d = 98765.54321#
  3394.    dat.a = "first data set"
  3395.    CLS
  3396.  
  3397.    ' The following outputs a user-defined-TYPE record to the file all
  3398.    ' at once:
  3399.  
  3400.    OPEN "test.dat" FOR RANDOM AS #1 LEN = LEN(dat)
  3401.    PUT #1, 1, dat
  3402.    CLOSE
  3403.  
  3404.    ' The following inputs from the file into FIELDed variables:
  3405.  
  3406.    OPEN "test.dat" FOR RANDOM AS #1 LEN = 33
  3407.    FIELD #1, 2 AS a$, 4 AS B$, 4 AS C$, 8 AS d$, 15 AS e$
  3408.    GET #1, 1
  3409.    i1% = CVI(a$)
  3410.    l1& = CVL(B$)
  3411.    s1! = CVS(C$)
  3412.    d1# = CVD(d$)
  3413.    PRINT i1%, l1&, s1!, d1#, e$
  3414.  
  3415.    ' The following outputs a new record using the FIELDed variables:
  3416.  
  3417.    LSET e$ = "New data "
  3418.    PUT #1, 2
  3419.    CLOSE
  3420.  
  3421.    ' The following inputs from the file into a user-defined variable:
  3422.  
  3423.    OPEN "test.dat" FOR RANDOM AS #1 LEN = 33
  3424.    GET #1, 2, dat
  3425.    PRINT dat.i, dat.l, dat.s, dat.d, dat.a
  3426.    CLOSE
  3427.  
  3428. Keywords:  B_BasicCom
  3429.  
  3430. COPYRIGHT Microsoft Corporation, 1989.
  3431. Updated  90/03/03 05:29
  3432. _____________________________________________________________________________
  3433. Q58105 Explanation of Tiling in BASIC; PAINTing with Patterns
  3434. Microsoft QuickBASIC Compiler (QUICKBAS)
  3435. 1.00 1.01 1.02 2.00 2.01 3.00 4.00 4.00b 4.50
  3436. MS-DOS
  3437.  
  3438. Summary:
  3439.  
  3440. The QuickBASIC PAINT statement can be used to paint a region of the
  3441. screen in a particular color or pattern. PAINTing with a pattern is
  3442. called "tiling."
  3443.  
  3444. The syntax for the paint statement is as follows:
  3445.  
  3446.    PAINT [STEP] (x,y) [,[paint] [,[bordercolor] [,[background]]]
  3447.  
  3448. The variable labeled "paint" is used to control the color of the
  3449. painted region. If it is a numeric value, then the number must be a
  3450. valid color attribute. The corresponding color is used to paint the
  3451. area. If paint is left blank, then the foreground color attribute is
  3452. used.
  3453.  
  3454. However, if you use a string in this part of the PAINT statement, then
  3455. this string is used to do "tiling." This article describes how to do
  3456. tiling in different screen modes.
  3457.  
  3458. For an in-depth explanation of tiling, please see the following
  3459. manuals:
  3460.  
  3461. 1. "Microsoft QuickBASIC 4.5: Programming in BASIC," Pages 181-191
  3462.  
  3463. 2. "Microsoft QuickBASIC 4.0: Programming in BASIC: Selected Topics,"
  3464.    Pages 226-239
  3465.  
  3466. 3. "Microsoft BASIC 7.0: Programmer's Guide," Pages 179-189
  3467.  
  3468. 4. "Microsoft BASIC Compiler 6.0: Programming in BASIC: Selected
  3469.    Topics," Pages 226-239
  3470.  
  3471. 5. "Microsoft QuickBASIC Compiler" manual for Versions 2.00, 2.01, and
  3472.    3.00, Pages 380-382
  3473.  
  3474. This information applies to Microsoft QuickBASIC Versions 1.00, 1.01,
  3475. 1.02, 2.00, 2.01, 3.00, 4.00, 4.00b, 4.50 for MS-DOS; to Microsoft
  3476. BASIC Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2; and to
  3477. Microsoft BASIC Professional Development System (PDS) Version 7.00 for
  3478. MS-DOS and MS OS/2.
  3479.  
  3480. More Information:
  3481.  
  3482. Each tile for a pattern is composed of a rectangular grid of pixels.
  3483. This tile grid can have up to 64 rows in all screen modes. However,
  3484. the number of pixels in each row depends on the screen mode. This is
  3485. because, depending on the number of color attributes per screen, each
  3486. pixel can be represented by a varying number of bits.
  3487.  
  3488. The formula for the number of bits per pixel is as follows:
  3489.  
  3490.    Bits-per-pixel = Log (base 2) of the number-of-attributes
  3491.  
  3492. The number-of-attributes is the number of color attributes in that
  3493. screen mode.
  3494.  
  3495. The following table gives the bits-per-pixel and length-of-tile-row
  3496. for each screen mode:
  3497.  
  3498.    Screen Mode      Bits-per-Pixel       Length-of-Tile-Row
  3499.    -----------      --------------       ------------------
  3500.  
  3501.     1                     1                     8 pixels
  3502.     2                     2                     4 pixels
  3503.     3                     1                     8 pixels
  3504.     4                     1                     8 pixels
  3505.     7                     4                     2 pixels
  3506.     8                     4                     2 pixels
  3507.     9                     2                     4 pixels
  3508.    10                     2                     4 pixels
  3509.    11                     1                     8 pixels
  3510.    12                     4                     2 pixels
  3511.    13                     8                     1 pixel
  3512.  
  3513. The easiest way to define a tile row is with the CHR$() function. This
  3514. function defines one byte (8 bits) in the tiling string. It is also
  3515. easiest to use two hexadecimal digits per byte since they are easily
  3516. converted to 4 bits per digit. For instance, the following line
  3517.  
  3518.    TILE$ = CHR$(&HF0)
  3519.  
  3520. sets up a tiling string with the value 11110000. It is used in a
  3521. PAINT statement, such as the following:
  3522.  
  3523.    PAINT (100,100), TILE$
  3524.  
  3525. SCREENS 2, 3, 4, and 11
  3526. -----------------------
  3527.  
  3528. In screen modes with only two attributes (modes 2, 3, 4, and 11), the
  3529. tiling string is very simple since each bit equals one pixel. A one
  3530. (1) means that the pixel is on and a zero (0) means that the pixel is
  3531. off.
  3532.  
  3533. SCREENS 1, 9, and 10
  3534. --------------------
  3535.  
  3536. In screen modes with four attributes (modes 1, 9, and 10), the tiling
  3537. is only a little more complicated since a pixel is represented by two
  3538. bits. For instance, if the two bits were 01, then the pixel would be
  3539. drawn in color 1. If they were 11, then the pixel would be color 3.
  3540. One byte would equal 4 pixels. The byte 00011011 would draw 4 pixels
  3541. in color 0, 1, 2, and 3 consecutively. The tiling string for 00011011
  3542. would be the following:
  3543.  
  3544.    TILE$ = CHR$(&H1B)   '0001 = &H1, 1101 = &HB
  3545.  
  3546. SCREENS 7, 8, and 12
  3547. --------------------
  3548.  
  3549. Tiling in EGA and VGA screen modes with more than 4 colors is a lot
  3550. more complicated. In these modes, it takes more than one row (byte) to
  3551. define a tiling row. This is because each pixel is represented
  3552. three-dimensionally in a stack of "bit planes," rather than
  3553. sequentially in a single plane.
  3554.  
  3555. Below is an example of how to define a multicolored pattern consisting
  3556. of rows of alternating yellow and magenta in a screen mode with 16
  3557. color attributes (modes 7, 8, and 12). The following table shows how
  3558. the colors are defined for each pixel and how to arrange them into
  3559. CHR$() statements:
  3560.  
  3561.               Column
  3562.           1 2 3 4 5 6 7 8
  3563.         -------------------
  3564. Row 1     1 1 0 0 0 0 1 1   =    CHR$(&HC3)
  3565. Row 2     0 0 1 1 1 1 0 0   =    CHR$(&H3C)
  3566. Row 3     1 1 1 1 1 1 1 1   =    CHR$(&HFF)
  3567. Row 4     0 0 1 1 1 1 0 0   =    CHR$(&H3C)
  3568.  
  3569.      TILE$ = CHR$(&HC3)+CHR$(&H3C)+CHR$(&HFF)+CHR$(&H3C)
  3570.  
  3571. The preceding line defines 8 pixels of the colors magenta, magenta,
  3572. yellow, yellow, yellow, yellow, magenta, magenta. This combination
  3573. results in alternating stripes of magenta and yellow. You can get the
  3574. color by reading each column from BOTTOM to TOP. For instance, the
  3575. first pixel is defined in column 1 by the color number 0101. This is
  3576. color 5, which defaults to magenta. The sixth pixel is defined by the
  3577. number 1110, or color 14, which is yellow in the default palette.
  3578.  
  3579. To paint a circle with this pattern, you would do the following:
  3580.  
  3581.    SCREEN 12
  3582.    TILE$ = CHR$(&HC3)+CHR$(&H3C)+CHR$(&HFF)+CHR$(&H3C)
  3583.    CIRCLE (100,100),50       'a circle of radius 50
  3584.    PAINT (100,100),TILE$
  3585.    END
  3586.  
  3587. SCREEN 13
  3588. ---------
  3589.  
  3590. Screen mode 13, which has 256 attributes, works differently than the
  3591. other EGA and VGA modes. You have a lot less flexibility with screen
  3592. 13 than you do with even the two-color screens. The most that you can
  3593. do with screen 13 tiling is to create horizontal lines of different
  3594. colors. This is very simple since one byte is equal to one pixel
  3595. color. Therefore, one CHR$() statement defines one line or row.
  3596.  
  3597. To paint a circle with alternating lines of color 5 (magenta) and
  3598. color 14 (yellow), you would do the following:
  3599.  
  3600.    SCREEN 13
  3601.    TILE$ = CHR$(&H5) + CHR$(&HE)   'colors 5 and 14
  3602.    CIRCLE (100,100),50
  3603.    PAINT (100,100),TILE$
  3604.    END
  3605.  
  3606. Keywords:  SR# S900114-17 B_BasicCom
  3607.  
  3608. COPYRIGHT Microsoft Corporation, 1989.
  3609. Updated  90/03/06 04:31
  3610. _____________________________________________________________________________
  3611. Q58825 How BASIC Can Determine VGA Palette Colors with BIOS Interrupt
  3612. Microsoft QuickBASIC Compiler (QUICKBAS)
  3613. 4.00 4.00b 4.50
  3614. MS-DOS
  3615.  
  3616. Summary:
  3617.  
  3618. The easiest way to determine the color value associated with a given
  3619. VGA palette register is to use BIOS Interrupt 10 Hex, with Function 10
  3620. Hex, and Subfunction 15 Hex. This information applies only to machines
  3621. that have VGA adapters and return information only on the VGA palette.
  3622. This interrupt does not supply information on the EGA or CGA palettes.
  3623.  
  3624. The sample program below applies only to Microsoft QuickBASIC Versions
  3625. 4.00, 4.00b, and 4.50, to Microsoft BASIC Compiler Versions 6.00 and
  3626. 6.00b, and to Microsoft BASIC Professional Development System (PDS)
  3627. Version 7.00 under MS-DOS. It does not apply to earlier versions of
  3628. QuickBASIC or BASIC compiler because they do support VGA SCREEN modes.
  3629. (However, the information on Interrupt 10 Hex, with Function 10 Hex
  3630. applies to any language with the ability to call BIOS routines,
  3631. including QuickBASIC Versions 2.00, 2.01, and 3.00.)
  3632.  
  3633. More Information:
  3634.  
  3635. Interrupt 10 hex (16 decimal) contains all of the advanced video
  3636. services available through the BIOS of the PC. Function 10 hex (16
  3637. decimal) of interrupt 10 hex contains the color or palette services.
  3638. These include services for setting or retrieving color information.
  3639. Subfunction 15 hex (21 decimal) of these services returns the red,
  3640. green, and blue intensities associated with a particular palette
  3641. register. From this, you can determine the color number associated
  3642. with that attribute.
  3643.  
  3644. There are 16 (0-15) attributes in VGA Screen 12, and 256 (0-255)
  3645. attributes in VGA Screen 13. Screen 11 has only 1. Each of these
  3646. attributes has a corresponding palette register. When you do a PALETTE
  3647. or PALETTE USING statement, you change the values in one or all of
  3648. these registers. However, BASIC has no built-in procedure for reading
  3649. these registers. Therefore, you must use CALL INTERRUPT.
  3650.  
  3651. The sample program below uses CALL INTERRUPT to find the default
  3652. values for all of the palette registers associated with screen mode
  3653. 12. This program can easily be modified to find all 256 registers
  3654. available in screen mode 13 by looping 256 times instead of 16. The
  3655. output of the program lists the register number and the red, green,
  3656. and blue intensity values for each palette register. It also
  3657. calculates the corresponding color number with the following formula:
  3658.  
  3659.    Colornumber = (65536 * Blue) + (256 * Green) + Red
  3660.  
  3661. For more information about BIOS interrupts and video graphics, see the
  3662. following books:
  3663.  
  3664. 1. "Advanced MS-DOS Programming, 2nd Edition," by Ray Duncan
  3665.    (Microsoft Press, 1988)
  3666.  
  3667. 2. "Programmer's Guide to PC & PS/2 Video Systems," by Richard Wilton
  3668.    (Microsoft Press, 1987)
  3669.  
  3670. Code Example
  3671. ------------
  3672.  
  3673. The following program can be run in the QuickBASIC 4.00, 4.00b, or
  3674. 4.50 environment and in the QuickBASIC environment included with
  3675. Microsoft BASIC Compiler Versions 6.00 and 6.00b by loading QB.EXE
  3676. with the QB.QLB Quick library. In the BASIC PDS 7.00 environment, load
  3677. QBX.EXE with the QBX.QLB Quick library. If the program is compiled, it
  3678. must be linked with either QB.LIB or QBX.LIB, respectively.
  3679.  
  3680. 'PALINFO.BAS
  3681. '*** You must load QB.QLB or link with QB.LIB for QuickBASIC 4.x ***
  3682. '*** You must load QBX.QLB or link with QBX.LIB for BASIC 7.00 ***
  3683.  
  3684. REM $INCLUDE: 'qb.bi'   'qbx.bi for BASIC 7.00 and QBX
  3685. DIM inregs AS regtype, outregs AS regtype
  3686.  
  3687. SCREEN 12
  3688. PRINT "Palette Information"
  3689. PRINT "Register #", "Green", "Blue", "Red", "Color Number"
  3690. PRINT "----------", "-----", "----", "---", "-------------"
  3691.  
  3692. FOR i = 0 TO 15             '0 to 255 for screen 13
  3693.   inregs.ax = &H1015          'AH = 10H,   AL=15H
  3694.   inregs.bx = i               'BL = register #
  3695.   CALL interrupt(&H10, inregs, outregs)
  3696.  
  3697. 'The following lines mask off the high/low bites of the registers
  3698. 'CH = green, CL = blue, DH = red
  3699.  
  3700.   a% = (outregs.cx AND &HFF00) / &HFF
  3701.   b% = (outregs.cx AND &HFF)
  3702.   c% = (outregs.dx AND &HFF00) / &HFF
  3703.  
  3704.   d& = 65536 * b% + 256 * a% + c%
  3705.   PRINT i, a%, b%, c%, d&
  3706. NEXT i
  3707.  
  3708. END  ' End of example code.
  3709.  
  3710. Additional reference words: &H10 10H &H15 15H
  3711.  
  3712. Keywords:  SR# S900214-79 B_BasicCom
  3713.  
  3714. COPYRIGHT Microsoft Corporation, 1989.
  3715. Updated  90/03/07 05:12
  3716. _____________________________________________________________________________
  3717. Q50736 How to Enter Extended ASCII Characters in QB.EXE Using ALT Key
  3718. Microsoft QuickBASIC Compiler (QUICKBAS)
  3719. 2.00 2.01 3.00 4.00 4.00b 4.50
  3720. MS-DOS
  3721.  
  3722. Summary:
  3723.  
  3724. To enter most ASCII character byte values in the QB.EXE editor,
  3725. including characters without their own keys, you can hold down the ALT
  3726. key while typing in the numeric value for the character on the numeric
  3727. keypad and then releasing the ALT key. The character with that code
  3728. will be inserted at the current cursor position. For example,
  3729. ALT+1+7+2 is the symbol for one-fourth (1/4).
  3730.  
  3731. Extended ASCII characters (values 128 to 255) are useful for typing
  3732. line-drawing characters, foreign alphabet characters, or other special
  3733. symbols into quoted strings or comments (REM or ') in your code. For
  3734. example, QCARDS.BAS for QuickBASIC 4.50 uses extended ASCII characters
  3735. to make attractive screen boxes.
  3736.  
  3737. This information applies to QB.EXE in Microsoft QuickBASIC Versions
  3738. 2.00, 2.01, 3.00, 4.00, 4.00b, and 4.50 for MS-DOS, to QB.EXE in
  3739. Microsoft BASIC Compiler Versions 6.00 and 6.00b for MS-DOS, and to
  3740. QBX.EXE in Microsoft BASIC Professional Development System (PDS)
  3741. Version 7.00 for MS-DOS.
  3742.  
  3743. More Information:
  3744.  
  3745. Most of the ASCII characters (32 through 255) can be entered using the
  3746. ALT key, including the normal alphabetic characters. For example, if
  3747. the ALT key is held down while the number 65 is typed on the numeric
  3748. keypad (with NUM LOCK active) and then ALT is released, "A" is
  3749. inserted at the current cursor position, since the ASCII code for "A"
  3750. is 65 (decimal). This ALT key technique also works at the MS-DOS
  3751. command line and in many other programs in MS-DOS.
  3752.  
  3753. How to Handle ASCII 0-31 Control Codes
  3754. --------------------------------------
  3755.  
  3756. Note that you cannot use the above ALT key method to embed ASCII
  3757. character codes 0 through 31 into your source code. (ASCII characters
  3758. 0 through 31, which are often called control characters, have special
  3759. program-specific meanings.) You also cannot type ASCII 240 using the
  3760. ALT key in QB.EXE or QBX.EXE (ALT+2+4+0). If you want to use a
  3761. character with ASCII value 0-31 or 240 as output from your BASIC
  3762. program, you can use the CHR$() function to generate the character.
  3763. The CHR$() function can be used to generate any ASCII (0-127) or
  3764. extended-ASCII (128-255) character for output from a BASIC program.
  3765.  
  3766. However, in QuickBASIC 4.00, 4.00b, and 4.50, and in Microsoft BASIC
  3767. Compiler Versions 6.00 and 6.00b, the PRINT statement does not display
  3768. any character for control codes 7, 9-13, and 28-31 at run time
  3769. (whether the character is embedded in a string with CTRL+P or created
  3770. with the CHR$() function). For more information, query on the
  3771. following words:
  3772.  
  3773.    ASCII and PRINT and SCRN and CONS
  3774.  
  3775. NOTE: In QB.EXE 4.00 and later and in QBX.EXE 7.00, you can use the
  3776. CTRL+P key to enter some of the control codes from 1 through 31. As an
  3777. example, for 1 press CTRL+P+A, for 2 press CTRL+P+B, for 3 press
  3778. CTRL+P+C, ..., and for 31 press CTRL+P+_ (CTRL+P+underscore).
  3779. Many of these control codes can be typed into string constants or
  3780. comments in your source code. WARNING: BC.EXE may not accept some
  3781. control codes embedded in your source file. Also, the QBX.EXE editor
  3782. does not let you enter the following CTRL+P sequences: CTRL+P+@ (0),
  3783. CTRL+P+J (10), CTRL+P+M (13), CTRL+P+\ (28), or CTRL+P+^ (30).
  3784. Microsoft recommends using the CHR$() function to generate the control
  3785. characters you need instead of typing control characters directly into
  3786. the source file.
  3787.  
  3788. References for ASCII Symbols 0-255
  3789. ----------------------------------
  3790.  
  3791. The numeric character codes 0-255 are documented in the following
  3792. ASCII and extended-ASCII tables:
  3793.  
  3794. 1. In the QuickBASIC 4.50 QB Advisor online Help system under
  3795.    Contents, "ASCII Character Codes"
  3796.  
  3797. 2. In the Microsoft Advisor online Help system for BASIC PDS 7.00
  3798.    under Contents, "ASCII Character Codes"
  3799.  
  3800. 3. Pages 464-465 of "Microsoft QuickBASIC 4.0: BASIC Language
  3801.    Reference" manual for Versions 4.00 and 4.00b
  3802.  
  3803. 4. Pages 464-465 of "Microsoft BASIC Compiler 6.0: BASIC Language
  3804.    Reference" for Versions 6.00 and 6.00b for MS OS/2 and MS-DOS
  3805.  
  3806. 5. Pages 602-603 of "Microsoft BASIC 7.0: Language Reference"
  3807.  
  3808. Keywords:  SR# S890925-102 B_BasicCom
  3809.  
  3810. COPYRIGHT Microsoft Corporation, 1989.
  3811. Updated  90/03/14 03:54
  3812. _____________________________________________________________________________
  3813. Q51076 PE Option in OPEN COM Statement Enables Parity Checking
  3814. Microsoft QuickBASIC Compiler (QUICKBAS)
  3815. 1.00 1.01 1.02 2.00 2.01 3.00 4.00 4.00b 4.50
  3816. MS-DOS
  3817.  
  3818. Summary:
  3819.  
  3820. When opening a communications port (COM1 or COM2) in Microsoft
  3821. QuickBASIC or Microsoft BASIC Compiler, the parity is not checked
  3822. unless the PE option is specified in the OPEN COM statement.
  3823.  
  3824. The PE option must be added under the OPEN COM statement (listed
  3825. alphabetically under OPEN) in the following BASIC language references:
  3826.  
  3827. 1. The QB Advisor on-line Help system for QuickBASIC Version 4.50,
  3828.    under the OPEN COM statement
  3829.  
  3830. 2. Page 297 of "Microsoft QuickBASIC 4.0: BASIC Language Reference"
  3831.    manual for Versions 4.00 and 4.00b
  3832.  
  3833. 3. Page 297 of "Microsoft BASIC Compiler 6.0: BASIC Language
  3834.    Reference" for Versions 6.00 and 6.00b for MS OS/2 and MS-DOS
  3835.  
  3836. 4. Page 241 of "Microsoft BASIC 7.0: BASIC Language Reference" for
  3837.    Microsoft PDS Version 7.00 for MS OS/2 and MS-DOS
  3838.  
  3839. 5. The Microsoft Advisor on-line Help system for QuickBASIC Extended
  3840.    Version 7.00, under the OPEN COM statement.
  3841.  
  3842. 6. Page 375 of "Microsoft QuickBASIC Compiler" Versions 2.0x and 3.00
  3843.    manual
  3844.  
  3845. The PE option is documented in the "Microsoft GW-BASIC Interpreter:
  3846. User's Reference" for Versions 3.20, 3.22, and 3.23, under the OPEN
  3847. COM statement.
  3848.  
  3849. More Information:
  3850.  
  3851. The PE option enables parity checking during communications. A "Device
  3852. I/O error" occurs if the two communicating programs have two different
  3853. parities. (Parity can be even, odd, none, space, or mark). For
  3854. example, a "Device I/O error" occurs when two programs try to talk to
  3855. each other across a serial line using the following two different OPEN
  3856. COM statements:
  3857.  
  3858.    OPEN "COM1:1200,O,7,2,PE" FOR RANDOM AS #1
  3859. and
  3860.    OPEN "COM2:1200,E,7,2,PE" FOR RANDOM AS #2
  3861.  
  3862. If the PE option is removed from the OPEN COM statements above, no
  3863. error occurs.
  3864.  
  3865. This information applies to Microsoft QuickBASIC Versions 1.00, 1.01,
  3866. 2.00, 2.01, 3.00, 4.00, 4.00b, 4.50, to Microsoft BASIC Compiler
  3867. Versions 6.00 and 6.00b for MS-DOS, and to Microsoft BASIC PDS Version
  3868. 7.00 for MS-DOS.
  3869.  
  3870. Keywords:  SR# S891114-52 docerr B_BasicCom
  3871.  
  3872. COPYRIGHT Microsoft Corporation, 1989.
  3873. Updated  90/03/16 05:06
  3874. _____________________________________________________________________________
  3875. Q59725 INTERRUPT for Clock Tick Counter Returns Negative Value
  3876. Microsoft QuickBASIC Compiler (QUICKBAS)
  3877. 4.00 4.00b 4.50
  3878. MS-DOS
  3879.  
  3880. Summary:
  3881.  
  3882. Interrupt 1A Hex, with Function 0, returns the current value of the
  3883. clock tick counter in registers CX and DX. When the low-order portion
  3884. of the clock tick counter (returned in DX) exceeds 32,767, it becomes
  3885. negative when stored as an integer in BASIC, because 32,767 is the
  3886. maximum value for a 2-byte signed integer. Below is an example to
  3887. convert the negative value to the equivalent unsigned long integer
  3888. value.
  3889.  
  3890. This information applies to Microsoft QuickBASIC Versions 4.00, 4.00b,
  3891. and 4.50, to Microsoft BASIC Compiler Versions 6.00 and 6.00b, and to
  3892. Microsoft BASIC Professional Development System (PDS) Version 7.00 for
  3893. MS-DOS.
  3894.  
  3895. More Information:
  3896.  
  3897. For a more complete description of converting negative signed integers
  3898. to unsigned integers, query on the following words:
  3899.  
  3900.    CALL and INTERRUPT and negative and signed and integer
  3901.  
  3902. The following QuickBASIC program outputs only positive values by
  3903. removing the sign bit and adding the remaining number plus 1 to
  3904. 32,767:
  3905.  
  3906. ' $INCLUDE: 'qb.bi'
  3907. REM  In BASIC 7.00, use $INCLUDE: 'qbx.bi' instead of 'qb.bi'.
  3908. REM  To use CALL INTERRUPT in this program, you must do the following:
  3909. REM  If you run this program in QB.EXE, use QB /L QB.QLB.
  3910. REM  If you run this program in QBX.EXE, use QBX /L QBX.QLB.
  3911. REM  LINK with QB.LIB (or QBX.LIB for BASIC 7.00).
  3912.  
  3913. DIM inregs AS regtype, outregs AS regtype
  3914. LOCATE 23, 1: PRINT "Push any key to end program."
  3915. DO
  3916. inregs.ax = 0
  3917. CALL interrupt(&H1A, inregs, outregs)
  3918. high& = outregs.cx
  3919. low& = outregs.dx
  3920. IF low& < 0 THEN              'if the low-order portion is negative:
  3921.   low& = low& AND &H7FFF      'remove sign bit
  3922.   low& = low& + &H7FFF + 1    'add remaining number plus 1 to 32,767
  3923. END IF
  3924. LOCATE 24, 1: PRINT high&; ":"; low&; "   ";
  3925. LOOP UNTIL INKEY$ <> ""
  3926. END
  3927.  
  3928. Keywords:  SR# S900222-218 B_BasicCom
  3929.  
  3930. COPYRIGHT Microsoft Corporation, 1989.
  3931. Updated  90/03/27 04:30
  3932. _____________________________________________________________________________
  3933. Q60966 QB.EXE and QBX.EXE Erase Line If You Type STRIG ON
  3934. Microsoft QuickBASIC Compiler (QUICKBAS)
  3935. 4.00 4.00b 4.50
  3936. MS-DOS
  3937.  
  3938. Summary:
  3939.  
  3940. If the following code example is typed into the Microsoft QuickBASIC
  3941. (QB.EXE) or QuickBASIC extended (QBX.EXE) editors, the line "STRIG ON"
  3942. will disappear when you either move the cursor off that line, press
  3943. RETURN, or try to run the program.
  3944.  
  3945. More Information:
  3946.  
  3947. This is not considered a problem with QB.EXE or QBX.EXE. Page 411 of
  3948. the "Microsoft QuickBASIC 4.0: BASIC Language Reference," Page 411 of
  3949. the "Microsoft BASIC Compiler 6.0: BASIC Language Reference," and Page
  3950. 361 of the "Microsoft BASIC 7.0: Language Reference" state that the
  3951. STRIG ON and STRIG OFF statements are ignored. These statements are
  3952. provided for compatibility with earlier versions of BASIC.
  3953.  
  3954. Code Example
  3955. ------------
  3956.  
  3957.    PRINT "Before Line"
  3958.    STRIG ON                 'This line will disappear if entered
  3959.                             'in CAPS or not
  3960.    PRINT "After Line"
  3961.  
  3962. Output
  3963. ------
  3964.  
  3965.    Before Line
  3966.    After Line
  3967.  
  3968. Keywords:  B_BasicCom SR# S900410-80
  3969.  
  3970. COPYRIGHT Microsoft Corporation, 1990.
  3971. Updated  90/05/31 06:21
  3972. _____________________________________________________________________________
  3973. Q33301 FUNCTION Procedures Cannot Be Invoked in I/O Statements
  3974. Microsoft QuickBASIC Compiler (QUICKBAS)
  3975. 4.00 4.00b 4.50
  3976. MS-DOS
  3977.  
  3978. Summary:
  3979.  
  3980. You should avoid invoking (or nesting) a FUNCTION procedure in a BASIC
  3981. statement that performs output to a file. Instead, the returned value
  3982. of the FUNCTION procedure should be assigned to an intermediate
  3983. variable, and the intermediate variable can then be used in the I/O
  3984. statement. (A FUNCTION procedure is defined in a FUNCTION...END
  3985. FUNCTION block.)
  3986.  
  3987. This and other restrictions are described on Page 201 of the
  3988. "Microsoft QuickBASIC 4.0: BASIC Language Reference" manual for
  3989. versions 4.00 and 4.00b, as follows:
  3990.  
  3991.    Because BASIC may rearrange arithmetic expressions for greater
  3992.    efficiency, avoid using FUNCTION procedures that change program
  3993.    variables in arithmetic expressions. Also avoid using FUNCTION
  3994.    procedures that perform I/O in I/O statements. Using FUNCTION
  3995.    procedures that perform graphics operations in graphics statements
  3996.    may also cause side effects.
  3997.  
  3998. The same restriction is mentioned on Page 201 of the "Microsoft BASIC
  3999. Compiler 6.0: BASIC Language Reference" for versions 6.00 and 6.00b
  4000. for MS OS/2 and MS-DOS. It is also mentioned on Page 146 of the
  4001. "Microsoft BASIC 7.0: Language Reference" manual.
  4002.  
  4003. Please note that user-defined functions defined with the DEF FN
  4004. statement do not have the above restrictions.
  4005.  
  4006. Keywords:  B_BasicCom
  4007.  
  4008. COPYRIGHT Microsoft Corporation, 1990.
  4009. Updated  90/07/10 15:43
  4010. _____________________________________________________________________________
  4011. Q58658 Quick Libraries in BASIC 7.00 Don't Use Expanded Memory
  4012. Microsoft BASIC Compiler (BASICCOM)
  4013. 7.00 7.10
  4014. MS-DOS
  4015.  
  4016. Summary:
  4017.  
  4018. When using a Quick library in QBX.EXE, the programming environment
  4019. included with Microsoft BASIC Professional Development System (PDS)
  4020. version 7.00 or 7.10, the Quick library is always placed in
  4021. conventional memory. If you have expanded memory (as defined in the
  4022. LIM 4.0 EMS), QBX.EXE utilizes this expanded memory for loaded source
  4023. code segments that are smaller than 16K; however, Quick libraries are
  4024. always placed in conventional memory.
  4025.  
  4026. Microsoft BASIC PDS 7.00 or 7.10 is the only Microsoft BASIC product
  4027. that supports expanded memory, so this is not a consideration in
  4028. earlier versions of Microsoft BASIC Compiler or QuickBASIC.
  4029.  
  4030. Note: (LIM 4.0 EMS is an acronym for the Lotus/Intel/Microsoft version
  4031. 4.0 Expanded Memory Specification for MS-DOS.)
  4032.  
  4033. Keywords:  SR# S900207-70
  4034.  
  4035. COPYRIGHT Microsoft Corporation, 1990.
  4036. Updated  90/07/28 07:00
  4037. _____________________________________________________________________________
  4038. Q61349 BASIC PDS 7.00 "Program Memory Overflow" with Too Many CONST
  4039. Microsoft BASIC Compiler (BASICCOM)
  4040. 7.00 7.10 | 7.00 7.10
  4041. MS-DOS    | OS/2
  4042.  
  4043. Summary:
  4044.  
  4045. When used with the /V switch, the BC.EXE compiler that comes with
  4046. Microsoft BASIC Professional Development System (PDS) version 7.00
  4047. produces a "Program memory overflow" error when compiling a program
  4048. that has approximately 680+ CONSTants. The compiler can still have up
  4049. to 13K "bytes free" of compiler workspace when reporting this error.
  4050.  
  4051. "Program memory overflow" also occurs when compiling the TEST1.BAS
  4052. program generated below using 756+ CONSTants with the BC /Fs (far
  4053. strings) option.
  4054.  
  4055. The CONST limits are improved in BASIC PDS version 7.10, which can
  4056. handle significantly more CONSTants than BASIC 7.00.
  4057.  
  4058. The error message "Program memory overflow" is misleading because
  4059. normally the compiler only gives that error when more than 64K of code
  4060. has been generated for the module being compiled. This error
  4061. represents a limitation of the compiler. This error is generated when
  4062. the number of CONSTants that can be included in a BASIC module has
  4063. been exceeded.
  4064.  
  4065. More Information:
  4066.  
  4067. The "Program memory overflow" error above is due to the amount of
  4068. internal overhead that the compiler sets aside to do its work with
  4069. CONSTants. The error message is not generated because of a lack of
  4070. compiler workspace. In this case, 13K "bytes free" is a valid number.
  4071. There is actually 13K of compiler workspace free. A different
  4072. limitation has been encountered -- the number of CONSTants BC.EXE can
  4073. handle.
  4074.  
  4075. The BC.EXE in QuickBASIC version 4.50 and the BC.EXE compiler in BASIC
  4076. versions 6.00b and 7.10 will successfully compile a program with over
  4077. 1000 CONSTants.
  4078.  
  4079. Illustration
  4080. ------------
  4081.  
  4082. To demonstrate the limitation in 7.00, use the FIRST.BAS program below
  4083. to create the BASIC program TEST1.BAS with "n" number of CONSTants.
  4084. For example, a TEST1.BAS program created with approximately 650
  4085. CONSTants will compile with no errors in BASIC PDS 7.00. A program
  4086. with 680+ CONSTants compiled with BC /V gives "Program-memory
  4087. overflow" in BASIC PDS 7.00.
  4088.  
  4089. As a comparison to versions earlier than 7.00, if you create a
  4090. TEST1.BAS program with 1000 CONSTants, it will compile correctly with
  4091. BC.EXE 4.50 and BC.EXE 6.00b (which have a greater capacity for
  4092. CONSTants than 7.00).
  4093.  
  4094. As a comparison to 7.10, in TEST1.BAS created below, 7.10 can handle
  4095. 1100 CONSTants when compiled BC /V (but 1200 CONSTants gives "Program
  4096. memory overflow"). In TEST1.BAS created below, 7.10 can handle 2100
  4097. CONSTants when compiled BC /Fs (but 2200 CONSTants gives "Compiler out
  4098. of memory, 0 bytes free"). BASIC 7.10 can thus handle many more
  4099. CONSTants than 7.00.
  4100.  
  4101. FIRST.BAS
  4102. ---------
  4103.  
  4104. FIRST.BAS prompts you for a number, and then creates another BASIC
  4105. program, TEST1.BAS, with that many CONSTants. Compile the resulting
  4106. TEST1.BAS with BC /V or /Fs to test for compiler limitations.
  4107.  
  4108.    DEFINT A-Z
  4109.    CLS
  4110.    INPUT "How many CONSTants to you want in the file: ", Num%
  4111.    OPEN "test1.bas" FOR OUTPUT AS #1
  4112.    beg$ = "CONST p"
  4113.    equals$ = " ="
  4114.    FOR i = 1 TO Num%
  4115.       constant$ = beg$ + LTRIM$(RTRIM$(STR$(i))) + equals$ + STR$(i)
  4116.       PRINT #1, constant$
  4117.    NEXT
  4118.    CLOSE
  4119.    PRINT "File 'test.bas' successfully created"
  4120.    END
  4121.  
  4122. Keywords:  SR# S900329-74
  4123.  
  4124. COPYRIGHT Microsoft Corporation, 1990.
  4125. Updated  90/07/28 07:00
  4126. _____________________________________________________________________________
  4127. Q58108 BASIC 7.00 Wrong Integer FOR-NEXT Index Results in .EXE
  4128. Microsoft BASIC Compiler (BASICCOM)
  4129. 7.00   | 7.00
  4130. MS-DOS | OS/2
  4131.  
  4132. Summary:
  4133.  
  4134. In a compiled .EXE program, a FOR ... NEXT loop with an ending loop
  4135. counter value that is a variable and with a body that contains an
  4136. integer or long integer array assigned to a single- or
  4137. double-precision value can PRINT an incorrect value for the loop
  4138. counter. This problem occurs in a compiled .EXE program only, not in
  4139. the QuickBASIC Extended environment (QBX.EXE). An example of this
  4140. problem is shown in the program below.
  4141.  
  4142. Microsoft has confirmed this to be a problem in Microsoft BASIC
  4143. Professional Development System (PDS) version 7.00 for MS-DOS and MS
  4144. OS/2. This problem was corrected in Microsoft BASIC PDS version 7.10.
  4145.  
  4146. More Information:
  4147.  
  4148. The program below illustrates two conditions that, when occurring
  4149. together, can produce an undesirable effect. The root of this error is
  4150. embedded in the BASIC compiler (BC.EXE) optimization techniques. The
  4151. two conditions necessary to show this problem are as follows:
  4152.  
  4153. 1. A variable (not a constant) is used as the stop (ending) loop
  4154.    counter value on a FOR ... NEXT statement.
  4155.  
  4156. 2. An integer or long integer array (which is subscripted with the
  4157.    loop counter) is assigned to a single- or double-precision number.
  4158.    (This is known as "typecasting" -- a single- or double-precision
  4159.    number is typecasted to an integer or long integer.)
  4160.  
  4161. The problem occurs only on the first PRINT statement in the source
  4162. file that prints the loop counter (i%). For all loop iterations, that
  4163. PRINT i% statement incorrectly displays the fixed value of t#, the
  4164. ending loop value. PRINT i% statements farther down in the source code
  4165. work correctly.
  4166.  
  4167. To eliminate the problem, use one of the following workarounds:
  4168.  
  4169. 1. Compile with the BC /X option.
  4170.  
  4171.      Note: In the example below, the debug compiler option (/D) does
  4172.      not correct the problem.
  4173.  
  4174. 2. Use the CINT() function to convert the real number to an integer
  4175.    before assigning it to the integer or long integer array.
  4176.  
  4177. 3. Use a numeric constant (instead of a variable) for the ending
  4178.    value of the FOR loop counter.
  4179.  
  4180. 4. Compile with the BC /FPa option (instead of the default /FPi).
  4181.  
  4182. Code Example
  4183. ------------
  4184.  
  4185.    Dim ia%(10)            'An integer or long array shows problem.
  4186.    t# = 5                 't# can be any numeric type (!, @, #, %, or &)
  4187.    FOR i% = 1 to t#       't# is the ending value of the loop counter, i%
  4188.    PRINT i%;              'This value incorrectly prints equal to t# in .EXE
  4189.    ia%(i%) = 46.7         'A real number is typecast to an integer or
  4190.                           'long-integer value and assigned to the array
  4191. REM ia%(i%) = CINT(46.7)  'Workaround: use CINT(46.7) in the above line.
  4192.    PRINT i%;              'This value prints correctly.
  4193.    PRINT ia%(i%)          'This value prints correctly.
  4194.    NEXT i%
  4195.    END
  4196.  
  4197. Below is the (incorrect) output from this .EXE (compiled without
  4198. BC /X):
  4199.  
  4200.    5   1   46.7
  4201.    5   2   46.7
  4202.    5   3   46.7
  4203.    5   4   46.7
  4204.    5   5   46.7
  4205.  
  4206. The output should be as follows:
  4207.  
  4208.    1   1   46.7
  4209.    2   2   46.7
  4210.    3   3   46.7
  4211.    4   4   46.7
  4212.    5   5   46.7
  4213.  
  4214. Keywords:  SR# S900123-121 buglist7.00 fixlist7.10
  4215.  
  4216. COPYRIGHT Microsoft Corporation, 1990.
  4217. Updated  90/08/02 05:32
  4218. _____________________________________________________________________________
  4219. Q59008 Bad Integer Output Using DEF FN, VAL, FOR-NEXT in BASIC 7.00
  4220. Microsoft BASIC Compiler (BASICCOM)
  4221. 7.00   | 7.00
  4222. MS-DOS | OS/2
  4223.  
  4224. Summary:
  4225.  
  4226. When run as an .EXE program (compiled with BC.EXE), the program below
  4227. gives incorrect output in Microsoft BASIC Professional Development
  4228. System (PDS) version 7.00 for MS-DOS and MS OS/2. The same program
  4229. gives correct output when run in the QBX.EXE environment or compiled
  4230. with the BC /D option.
  4231.  
  4232. The program fails when it assigns an integer array (which is
  4233. subscripted by a FOR...NEXT loop counter) to the VAL of a DEF FN
  4234. string function operating on a temporary string that was assigned to
  4235. an array element that is subscripted by the FOR...NEXT loop counter.
  4236.  
  4237. Microsoft has confirmed this to be a problem in Microsoft BASIC
  4238. Professional Development System (PDS) version 7.00. This problem was
  4239. corrected in BASIC PDS version 7.10.
  4240.  
  4241. More Information:
  4242.  
  4243. This problem does not occur with an .EXE compiled in QuickBASIC
  4244. version 4.50 or earlier.
  4245.  
  4246. The program below outputs "2 2" instead of "1 2" from an .EXE program.
  4247. (The problem occurs whether compiled as a stand-alone .EXE or as an
  4248. .EXE requiring the BRT module). This problem is corrected by doing any
  4249. one of the following:
  4250.  
  4251. 1. Compiling with the BC /D option.
  4252.  
  4253. 2. Removing the DEFINT A-Z line.
  4254.  
  4255. 3. Replacing n (the ending value of the FOR...NEXT loop counter) with
  4256.    the constant 2 in the FOR...NEXT statement.
  4257.  
  4258. 4. Eliminating the use of the temporary (placeholder) variable t$ by
  4259.    putting s$(i) in place of it in the VAL function.
  4260.  
  4261. 5. Replacing d(i) with a nonarray (scalar) variable.
  4262.  
  4263. Code Example
  4264. ------------
  4265.  
  4266.    DEFINT A-Z
  4267.    DIM s$(1 TO 2), d(1 TO 2)
  4268.    DEF FNa$ (x$)
  4269.    FNa$ = x$
  4270.    END DEF
  4271.    CLS
  4272.    n = 2
  4273.    s$(1) = "1"
  4274.    s$(2) = "2"
  4275.    PRINT
  4276.    FOR i = 1 TO n
  4277.       t$ = s$(i)
  4278.       d(i) = VAL(FNa$(t$))
  4279.    ' One workaround is to use:   d(i) = VAL(FNa$(s$(i)))
  4280.       PRINT d(i);
  4281.    NEXT
  4282.    END
  4283.  
  4284. Keywords:  SR# S900217-5 buglist7.00 fixlist7.10
  4285.  
  4286. COPYRIGHT Microsoft Corporation, 1990.
  4287. Updated  90/08/02 05:32
  4288. _____________________________________________________________________________
  4289. Q60965 Problem When Using Integer Array and FOR Loop in BASIC 7.00
  4290. Microsoft BASIC Compiler (BASICCOM)
  4291. 7.00   | 7.00
  4292. MS-DOS | OS/2
  4293.  
  4294. Summary:
  4295.  
  4296. The code example below shows a case where using an integer variable
  4297. for a FOR loop-counter can produce incorrect results in a compiled
  4298. BASIC program. The program must have the following elements to
  4299. reproduce the problem:
  4300.  
  4301. 1. The program must contain a simple FOR loop (not nested, etc.).
  4302.  
  4303. 2. The FOR loop must contain a call to the INT function.
  4304.  
  4305. 3. The upper bound of the FOR loop must be specified with a
  4306.    variable, not a literal.
  4307.  
  4308. 4. The loop-counter variable and upper-bound variable must be
  4309.    integers.
  4310.  
  4311. The code example below demonstrates these conditions and prints out
  4312. the value of the loop counter each time it loops. In a compiled BASIC
  4313. program, this example always prints the upper bound of the loop
  4314. counter.
  4315.  
  4316. Microsoft has confirmed this to be a problem in the BC.EXE compiler
  4317. that comes with Microsoft BASIC Professional Development System (PDS)
  4318. version 7.00 for MS-DOS and MS OS/2. This problem was corrected in
  4319. BASIC PDS version 7.10.
  4320.  
  4321. More Information:
  4322.  
  4323. This problem does not occur in QBX.EXE (the QuickBASIC extended
  4324. environment that comes with BASIC PDS 7.00). This problem also does
  4325. not occur in the BC.EXE or QB.EXE environments that come with
  4326. QuickBASIC versions 4.00, 4.00b, or 4.50.
  4327.  
  4328. Any of the following workarounds corrects the problem:
  4329.  
  4330. 1. Compile with the BC /X option.
  4331.  
  4332. 2. Compile with the BC /FPa option.
  4333.  
  4334. 3. Change the DEFINT statement to DEFtype, where "type" is anything
  4335.    but INT (integer).
  4336.  
  4337. 4. Change the upper bound on the FOR-LOOP to a literal.
  4338.  
  4339. Code Example
  4340. ------------
  4341.  
  4342. DEFINT A-Z                    'Change to something other than INT
  4343.                               'or remove the line
  4344. DIM test(4)
  4345. temp = 4
  4346. FOR k = 1 TO temp             'Use 4 instead of temp.
  4347.    PRINT k                    'In a compiled program, this line
  4348.                               'always prints the upper bound
  4349.                               'of the FOR-LOOP.
  4350.    test(k) = INT(1.0)         'Remove the INT function CALL.
  4351. NEXT k
  4352.  
  4353. The following is the output in the QBX.EXE environment (correct):
  4354.  
  4355.    1
  4356.    2
  4357.    3
  4358.    4
  4359.  
  4360. The following is the output from a compiled 7.00 .EXE program
  4361. (incorrect):
  4362.  
  4363.    4
  4364.    4
  4365.    4
  4366.    4
  4367.  
  4368. Keywords:  SR# S900411-147 buglist7.00 fixlist7.10
  4369.  
  4370. COPYRIGHT Microsoft Corporation, 1990.
  4371. Updated  90/08/02 05:32
  4372. _____________________________________________________________________________
  4373. Q64430 Abrupt Branch to ON Event GOSUB Handler from Separate Handler
  4374. Microsoft QuickBASIC Compiler (QUICKBAS)
  4375. 2.00 2.01 3.00 4.00 4.00b 4.50
  4376. MS-DOS
  4377.  
  4378. Summary:
  4379.  
  4380. When program control is within an ON <event> GOSUB handler, it is
  4381. still possible to trap other events (where <event> can be COM, KEY,
  4382. PEN, PLAY, STRIG, TIMER, etc.). This is normal behavior for ON <event>
  4383. GOSUB trapping, but may be undesirable for those who want to disable
  4384. all event trapping within an ON <event> handler. This article gives a
  4385. code example demonstrating normal flow of control when a second
  4386. trappable key is pressed within a given ON KEY GOSUB handler. The
  4387. comments in this program show a method of temporarily disabling KEY
  4388. and other event trapping within an ON KEY GOSUB handler.
  4389.  
  4390. This information applies to Microsoft QuickBASIC versions 2.00, 2.01,
  4391. 3.00, 4.00, 4.00b, and 4.50 for MS-DOS, to Microsoft BASIC Compiler
  4392. versions 6.00 and 6.00b for MS-DOS and MS OS/2, and to Microsoft BASIC
  4393. PDS (Professional Development System) versions 7.00 and 7.10 for
  4394. MS-DOS and MS OS/2.
  4395.  
  4396. More Information:
  4397.  
  4398. Within an ON <event> GOSUB handler, event trapping is suspended within
  4399. the handler for only the trapped event. Any other active event traps
  4400. (set with other ON <event> GOSUB statements) triggered within an event
  4401. handler will cause control to immediately branch to the other ON
  4402. <event> handler during execution of the initial handler. Upon
  4403. terminating the second handler, control resumes where it left off in
  4404. the original handler. This abrupt transfer of control may be
  4405. problematic for those who want all actions surrounding a particular
  4406. event, a key press for example, to be processed in full before
  4407. subsequent key presses or events are handled.
  4408.  
  4409. The code example below demonstrates a case of control branching from
  4410. one ON KEY handler to another when a second key is pressed within the
  4411. first handler. The example contains the code (remarked out) necessary
  4412. to temporarily disable all ON KEY and other event trapping within the
  4413. initial ON KEY handler. If you unremark (uncomment) the code shown,
  4414. the program will complete each handler without interruption.
  4415.  
  4416. Code Example
  4417. ------------
  4418.  
  4419. 'DECLARE SUB EventsStop ()  ' These are the DECLARE statements for the
  4420. 'DECLARE SUB EventsOn ()    ' SUBs that disable and enable key and
  4421.                             ' event trapping. (DECLARE statements are
  4422.                             ' not needed or supported for QuickBASIC
  4423.                             ' 3.00 or earlier versions.)
  4424. CLS
  4425.  
  4426. ON KEY(1) GOSUB F1KeyHandler   ' Trapping for F1 function key.
  4427. ON KEY(2) GOSUB F2KeyHandler   ' Trapping for F2 function key.
  4428.  
  4429. KEY(1) ON
  4430. KEY(2) ON
  4431.  
  4432. PRINT "Please, press the F1 key"
  4433. SLEEP
  4434. PRINT "Exiting program"
  4435. END
  4436.  
  4437. ' To temporarily disable all key and event trapping within an
  4438. ' event handler, the CALL to SUB EventsStop must be the first
  4439. ' statement and the CALL to SUB EventsOn must be the last statement
  4440. ' of the handler before the RETURN.
  4441.  
  4442. F1KeyHandler:
  4443.         'CALL EventsStop       ' Include this statement to temporarily
  4444.                                ' disable all or selected ON KEY and
  4445.                                ' event statements
  4446.  
  4447.         PRINT "In F1 key handler"
  4448.         PRINT "Press F2 to jump to F2 key handler"
  4449.         SLEEP
  4450.         PRINT "Exiting F1 key handler"
  4451.  
  4452.         'CALL EventsOn         ' Include this statement so that any
  4453.                                ' keys pressed or events occurring
  4454.                                ' during the execution of this handler
  4455.                                ' will be processed at this point.
  4456.         RETURN
  4457.  
  4458. F2KeyHandler:
  4459.         'CALL EventsStop       ' Include this statement to temporarily
  4460.                                ' disable all or selected key and event
  4461.                                ' trapping within this handler.
  4462.         PRINT "In F2 key handler"
  4463.         PRINT "Exiting F2 key handler"
  4464.  
  4465.         'CALL EventsOn         ' Include this statement so that
  4466.                                ' any trappable keys or events triggered
  4467.                                ' during the execution of this handler
  4468.                                ' will be processed at this point.
  4469.         RETURN
  4470.  
  4471. SUB EventsOn               'All keys and events to enable go in here
  4472.         KEY(1) ON
  4473.         KEY(2) ON
  4474.  
  4475.         'TIMER ON          'Examples of events that may be enabled
  4476.         'COM(1) ON
  4477. END SUB
  4478.  
  4479. SUB EventsStop             'All keys and events to temporarily disable
  4480.         KEY(1) STOP        'go in here
  4481.         KEY(2) STOP
  4482.  
  4483.         'TIMER STOP        'Examples of events that may be temporarily
  4484.         'COM(1) STOP       'disabled
  4485. END SUB
  4486.  
  4487. Additional References
  4488. ---------------------
  4489.  
  4490. For more description of normal program flow within an ON <event> GOSUB
  4491. handler, please see the following:
  4492.  
  4493. 1. Page 315 of "Microsoft BASIC 7.0: Programmer's Guide" for BASIC PDS
  4494.    versions 7.00 and 7.10
  4495.  
  4496. 2. Page 234 of "Microsoft QuickBASIC 4.5: Programming in BASIC" manual
  4497.    for QuickBASIC version 4.50
  4498.  
  4499. 3. Page 289 of "Microsoft QuickBASIC 4.0: Programming in BASIC:
  4500.    Selected Topics" manual for QuickBASIC versions 4.00 and 4.00b
  4501.  
  4502. 4. Page 357 of "Microsoft QuickBASIC Compiler" manual for versions
  4503.    2.00, 2.01, and 3.00
  4504.  
  4505. Keywords:  SR# S900712-87 B_BasicCom
  4506.  
  4507. COPYRIGHT Microsoft Corporation, 1990.
  4508. Updated  90/08/04 05:35
  4509. _____________________________________________________________________________
  4510. Q59734 BASIC 7.00 Can Write Whole Array (in TYPE) to Disk at Once
  4511. Microsoft BASIC Compiler (BASICCOM)
  4512. 7.00 7.10 | 7.00 7.10
  4513. MS-DOS    | OS/2
  4514.  
  4515. Summary:
  4516.  
  4517. Microsoft BASIC Professional Development System (PDS) versions 7.00
  4518. and 7.10 introduce support for static arrays in user-defined TYPE
  4519. definitions. This means that you can write an entire array (in a user
  4520. TYPE record) to a disk file at once. The code example below writes an
  4521. entire array to a RANDOM or BINARY file using a single PUT# statement.
  4522.  
  4523. More Information:
  4524.  
  4525. Note that you cannot output arrays all at once (in one PRINT# or
  4526. WRITE# statement) to files opened with sequential access (OPEN FOR
  4527. OUTPUT). With sequential access (OPEN FOR OUTPUT or INPUT), you must
  4528. output or input just one array element at a time.
  4529.  
  4530. You must use RANDOM or BINARY access to write a static
  4531. nonvariable-length string array to a file all at once (as shown in the
  4532. examples below).
  4533.  
  4534. Note that in Microsoft QuickBASIC versions 4.00, 4.00b, and 4.50 for
  4535. MS-DOS, in Microsoft BASIC Compiler versions 6.00 and 6.00b for MS-DOS
  4536. and MS OS/2, and in Microsoft BASIC PDS versions 7.00 and 7.10 for
  4537. MS-DOS and MS OS/2, you can directly write whole records (variables)
  4538. of a given user-defined TYPE to disk as the third argument of the PUT#
  4539. statement. Each and every element of the user-defined TYPE record is
  4540. automatically copied to the file. If the data is numeric and you
  4541. output to a file OPENed with RANDOM or BINARY access, the data is
  4542. automatically stored in numeric format (without requiring a lengthy
  4543. FIELD statement or numeric-to-string conversion functions such as
  4544. MKS$, MKD$, MKI$, or MKL$).
  4545.  
  4546. Since an array can be an element of a record of user-defined TYPE in
  4547. BASIC 7.00 and 7.10 (but not in earlier versions), you can write a
  4548. whole array at once into a disk file, as shown below.
  4549.  
  4550. Code Example
  4551. ------------
  4552.  
  4553. The following example, compiled in BASIC PDS 7.00 or 7.10, shows how
  4554. to write a whole array to disk at once, using just one PUT# statement:
  4555.  
  4556. TYPE rec1
  4557.   array1(20) AS INTEGER
  4558. END TYPE
  4559. DIM var1 AS rec1, var2 AS rec1  'DIMension var1 & var2 with TYPE rec1
  4560. FOR i = 1 TO 20      ' Fill each element of the array:
  4561.   var1.array1(i) = i
  4562. NEXT
  4563.  
  4564. ' The following OPEN statements may OPEN FOR either RANDOM or BINARY:
  4565. OPEN "test.dat" FOR RANDOM AS #1
  4566. PUT #1, , var1       ' Write whole array to disk all at once.
  4567. CLOSE
  4568.  
  4569. OPEN "test.dat" FOR RANDOM AS #1
  4570. GET #1, , var2      ' Reads array all at once into var2.
  4571. FOR i = 1 TO 20     ' Print the contents of the array var2.array1:
  4572.   PRINT var2.array1(i);
  4573. NEXT
  4574. CLOSE
  4575.  
  4576. COPYRIGHT Microsoft Corporation, 1990.
  4577. Updated  90/08/04 05:35
  4578. _____________________________________________________________________________
  4579. Q32216 Two Ways to Pass Arrays in Compiled BASIC to Assembler Routine
  4580. Microsoft BASIC Compiler (BASICCOM)
  4581. 6.00 6.00b 7.00 7.10 | 6.00 6.00b 7.00 7.10
  4582. MS-DOS               | OS/2
  4583.  
  4584. Summary:
  4585.  
  4586. An array in a compiled BASIC program can be passed to an assembly
  4587. language program in the two ways shown below. The array can be passed
  4588. either through the CALL statement's parameter list or, for static
  4589. arrays only, through a COMMON block.
  4590.  
  4591. Microsoft does not support passing dynamic arrays through COMMON to
  4592. assembler (since this depends upon a Microsoft proprietary dynamic
  4593. array descriptor format that changes from version to version). Dynamic
  4594. arrays can be passed to assembler only as parameters in the CALL
  4595. statement.
  4596.  
  4597. This information applies to the following products:
  4598.  
  4599. 1. Microsoft QuickBASIC Compiler versions 4.00, 4.00b, and 4.50
  4600.  
  4601. 2. Microsoft BASIC Compiler versions 6.00 and 6.00b for MS-DOS and
  4602.    MS OS/2
  4603.  
  4604. 3. Microsoft BASIC Professional Development System (PDS) versions 7.00
  4605.    and 7.10 for MS-DOS and MS OS/2
  4606.  
  4607. More Information:
  4608.  
  4609. For more information about passing other types of parameters between
  4610. BASIC and MASM, search in the Software/Data Library for the following
  4611. word:
  4612.  
  4613.    BAS2MASM
  4614.  
  4615. The following information pertains to passing an array to an assembly
  4616. routine through the CALL parameter list:
  4617.  
  4618. If the array is passed through the parameter list, all the information
  4619. about the array must be passed. This includes the length of each item,
  4620. the number of items, and the segment and offset of the base element of
  4621. the array. The first two items may be hardcoded into the assembler
  4622. program, but the latter two must be passed because there is no way of
  4623. knowing where the array will be located before the program starts. The
  4624. following is an example:
  4625.  
  4626.    DECLARE SUB PutInfo (BYVAL Segment%, BYVAL Offset%)
  4627.    DIM a%(100)
  4628.    CALL PutInfo(VARSEG(a%(0)),VARPTR(a%(0)))
  4629.  
  4630. The assembly-language program pulls the information off the stack,
  4631. then continues with its purpose. Please note that this method works
  4632. with both static and dynamic arrays.
  4633.  
  4634. The following information pertains to passing an array to an assembly
  4635. language routine through a COMMON block:
  4636.  
  4637. Passing information through a COMMON block to an assembly language
  4638. program is fairly simple. In the assembly language program, a segment
  4639. is set up with the same name as the COMMON block and then grouped with
  4640. DGROUP, as follows:
  4641.  
  4642.    BNAME segment 'BC_VARS'
  4643.      x  dw 1 dup (?)
  4644.      y  dw 1 dup (?)
  4645.      z  dw 1 dup (?)
  4646.    BNAME ends
  4647.  
  4648.   dgroup group BNAME
  4649.  
  4650. The above assembler code matches the following BASIC code named COMMON
  4651. block:
  4652.  
  4653.    DEFINT A-Z
  4654.    COMMON /BNAME/ x,y,z
  4655.  
  4656. Passing arrays through the COMMON block is done in a similar fashion.
  4657. However, only static arrays may be passed to assembler through COMMON.
  4658.  
  4659. Note: This information does not apply to passing far
  4660. variable-length-strings in BASIC PDS version 7.00 or 7.10. For
  4661. information on accessing far variable-length-strings in BASIC PDS
  4662. version 7.00 or 7.10, see Chapter 13, "Mixed-Language Programming with
  4663. Far Strings," in the "Microsoft BASIC 7.0: Programmer's Guide" for
  4664. versions 7.00 and 7.10.
  4665.  
  4666. When static arrays are used, the entire array is stored in the COMMON
  4667. block. Consider the following example:
  4668.  
  4669. BASIC Program
  4670. -------------
  4671.  
  4672.       DECLARE SUB PutInfo ()
  4673.       DIM b%(100)
  4674.       COMMON /BNAME/ a%, b%(), c%
  4675.       CALL PutInfo
  4676.       CLS
  4677.       PRINT a%, c%
  4678.       FOR i = 0 TO 100
  4679.        PRINT b%(i);
  4680.       NEXT i
  4681.       END
  4682.  
  4683. Assembly Program
  4684. -----------------
  4685.  
  4686.       ;Note, this program uses MASM version 5.x directives.
  4687.  
  4688.       .model Medium
  4689.  
  4690.        BNAME segment COMMON 'BC_VARS'
  4691.          a  dw 1 dup (?)
  4692.          b  db 202 dup (?)      ;Note that all the space for the
  4693.                                 ;array is set up
  4694.          c  dw 1 dup (?)
  4695.        BNAME ends
  4696.  
  4697.        dgroup group BNAME
  4698.  
  4699.        .code
  4700.  
  4701.             public PutInfo
  4702.        PutInfo      proc   far
  4703.             push   bp
  4704.             mov    bp,sp
  4705.             push   di
  4706.  
  4707.             inc    word ptr dgroup:a
  4708.             inc    word ptr dgroup:c
  4709.  
  4710.             mov    cx,101
  4711.             mov    di,offset dgroup:b
  4712.  
  4713.        repeat:
  4714.             mov    [di],cx
  4715.             add    di,2
  4716.             loop   repeat
  4717.  
  4718.             pop    di
  4719.             pop    bp
  4720.             ret
  4721.        PutInfo      endp
  4722.             end
  4723.  
  4724. As noted in the assembly source, the space for the array must be set up
  4725. in the COMMON segment.
  4726.  
  4727. When dynamic arrays are used, the array is not placed in the COMMON
  4728. block. Instead, a multibyte array descriptor is placed on the COMMON
  4729. block. The dynamic array descriptor changes from version to version,
  4730. and is not released by Microsoft -- it is considered Microsoft
  4731. proprietary information.
  4732.  
  4733. Keywords:  B_QuickBas
  4734.  
  4735. COPYRIGHT Microsoft Corporation, 1990.
  4736. Updated  90/08/09 05:31
  4737. _____________________________________________________________________________
  4738. Q37770 "Program Memory Overflow": Break into SUBprograms
  4739. Microsoft BASIC Compiler (BASICCOM)
  4740. 6.00 6.00b 7.00 7.10 | 6.00 6.00b 7.00 7.10
  4741. MS-DOS               | OS/2
  4742.  
  4743. Summary:
  4744.  
  4745. The code generated by BC.EXE in Microsoft BASIC Compiler versions 6.00
  4746. and 6.00b, Microsoft BASIC Professional Development System (PDS)
  4747. versions 7.00 and 7.10, and QuickBASIC versions 4.00, 4.00b, and 4.50
  4748. may be larger (on disk or in run-time memory) than that compiled with
  4749. previous versions. With the increase in product features, the program
  4750. size has grown. Therefore, it is possible that your program will no
  4751. longer compile and will give a "Program Memory Overflow" error. This
  4752. error can be avoided by breaking the program into smaller, separately
  4753. compiled subprograms or FUNCTION procedures.
  4754.  
  4755. More Information:
  4756.  
  4757. At compile time, the BC.EXE compiler options can make a big difference
  4758. in object file size. The /D (debug), /E (error handling with RESUME
  4759. label), and /V (event handling between statements) compiler options
  4760. generate the largest amount of code. The /X (error handling with
  4761. RESUME NEXT, RESUME, and RESUME 0) and /W (event handling between
  4762. lines) options generate less code than /E and /V; however, /X and /W
  4763. still generate a fair amount of code.
  4764.  
  4765. If you find that even with a careful choice of compiler options the
  4766. program is still too big to compile, the program should be broken up
  4767. into smaller modules that can be linked together.
  4768.  
  4769. Each module can contain up to 64K in code and share a 64K data segment
  4770. with the other modules. For code to be placed into its own module, it
  4771. must be a subprogram or FUNCTION procedure. A subprogram procedure is
  4772. surrounded by the SUB and END SUB statements. A FUNCTION procedure is
  4773. surrounded by the FUNCTION and END FUNCTION statements. For more
  4774. information about the memory the compiler uses and how to determine
  4775. segment sizes for code and data, query in this Knowledge Base for the
  4776. following words:
  4777.  
  4778.    determining and segment and sizes and LINK and /Map
  4779.  
  4780. Also, if a program works in the QuickBASIC environment, BC.EXE usually
  4781. compiles it to an executable program. However, there are two
  4782. exceptions. If the program contains a large $INCLUDE file with RESUME
  4783. and RESUME NEXT in it, the BC.EXE compiler may fail. The BC.EXE
  4784. compiler builds a table of line numbers for RESUME/RESUME NEXT
  4785. statements at 4 bytes each so it can tell where to resume back to.
  4786. This adds additional code to the program and causes memory depletion.
  4787. The QB.EXE interpreter does not have to keep the table, so less code
  4788. is generated.
  4789.  
  4790. To work around this situation, you can do the following two things:
  4791.  
  4792. 1. Use RESUME <label> instead of RESUME NEXT. Note that RESUME <label>
  4793.    should only be used to return to the same procedure level as where
  4794.    the error occurred, or else stack space will be consumed without
  4795.    being released, which can result in an "Out of stack space" error.
  4796.    For example, if an error occurs in a SUB procedure that is handled
  4797.    by an error handler in the main level code that performs RESUME
  4798.    <label> to a label in the main level code, then return addresses
  4799.    for the SUB remain unused on the stack and unavailable to the
  4800.    program.
  4801.  
  4802. 2. Break the program into smaller separate modules.
  4803.  
  4804. If you have a large number of static numeric arrays, the BC.EXE
  4805. compiler can run out of memory. In the QuickBASIC QB.EXE or QBX.EXE
  4806. environment, static numeric arrays are not stored in the DGROUP data
  4807. segment; they are stored in an additional segment. When the program is
  4808. compiled with BC.EXE, these arrays are placed into the DGROUP data
  4809. segment. This segment is limited to 64K. One way to work around this
  4810. segment limitation is to make the static arrays dynamic to put them in
  4811. the far heap.
  4812.  
  4813. Dynamic non-variable-length-string arrays are stored on the far heap
  4814. and not in the DGROUP data segment. There are three different ways to
  4815. make an array dynamic, as follows:
  4816.  
  4817. 1. Use the REM $DYNAMIC metacommand to make all arrays dynamic.
  4818.  
  4819. 2. Use a variable as the number of elements in the DIM statement, as
  4820.    in the following example:
  4821.  
  4822.       x=20
  4823.       DIM array(x)
  4824.  
  4825. 3. Place the array in COMMON and dimension the array after the COMMON
  4826.    statement:
  4827.  
  4828.       COMMON SHARED array()
  4829.       DIM array(100)
  4830.  
  4831. Once the program compiles, there are a few things that can be done to
  4832. reduce the size of the linked executable file. The following is a list
  4833. of ways to help reduce the size of .EXE files:
  4834.  
  4835. 1. Use the /E (/EXEPACK) linker option. This linker option removes
  4836.    sequences of repeated bytes and optimizes the load-time relocation
  4837.    table. The result is that executable files linked with this option
  4838.    may be smaller and may load faster than files linked without this
  4839.    option. Note: The /EXEPACK option cannot be used with the /Q
  4840.    option.
  4841.  
  4842. 2. For stand-alone .EXE files (that is, those compiled with the BC /O
  4843.    option) that use a string variable for the filename in the OPEN
  4844.    statement, linking in the file NOCOM.OBJ reduces the size of the
  4845.    programs by about 4K. (NOCOM.OBJ should be used only if your
  4846.    program contains no OPEN "COM" statements.) For example, the
  4847.    following is a program that NOCOM.OBJ will help make smaller:
  4848.  
  4849.       X$="test.dat"
  4850.       OPEN X$ FOR OUTPUT AS #1
  4851.  
  4852. In addition to NOCOM.OBJ, BASIC compiler version 6.00 provides other
  4853. NOxxx.OBJ files, including NOCGA.OBJ, NOEGA.OBJ, NOGRAPH.OBJ,
  4854. NOHERC.OBJ, NOLPT.OBJ, NOVGA.OBJ, and SMALLERR.OBJ. These files are
  4855. discussed in both the "Microsoft BASIC Compiler 6.0: User's Guide" and
  4856. the README.DOC found on Disk 1. These NOxxx.OBJ files can also be used
  4857. when a custom run-time module is built with the BUILDRTM.EXE utility.
  4858.  
  4859. For more information about stub files and optimizing code for size and
  4860. speed, see Chapter 15, "Optimizing Program Size and Speed," in the
  4861. "Microsoft BASIC 7.0: Programmer's Guide" for versions 7.00 and 7.10.
  4862.  
  4863. Keywords:  SR# G881028-5376 B_QuickBas
  4864.  
  4865. COPYRIGHT Microsoft Corporation, 1990.
  4866. Updated  90/08/11 05:20
  4867. _____________________________________________________________________________
  4868. Q60968 QBX.EXE 7.10 Expanded Memory Usage Better Than 7.00; 32K Table
  4869. Microsoft BASIC Compiler (BASICCOM)
  4870. 7.00 7.10
  4871. MS-DOS
  4872.  
  4873. Summary:
  4874.  
  4875. The QuickBASIC Extended environment (QBX.EXE) can use up to 16 MB
  4876. (megabytes) of Lotus-Intel-Microsoft (LIM) 4.0 expanded memory
  4877. under MS-DOS. If the expanded memory is available, QBX.EXE
  4878. automatically stores in it SUBs, FUNCTIONs, and module-level code
  4879. units that are no greater than 16K in size. If QBX.EXE is invoked with
  4880. the /Ea switch, arrays that are no greater than 16K in size are also
  4881. stored in expanded memory.
  4882.  
  4883. In QBX.EXE in BASIC PDS version 7.00, the memory is allocated in 16K
  4884. pages; for example, a 2K procedure consumes 16K and wastes 14K (16K
  4885. minus 2K) of expanded memory. Also, when one or more SUBs or FUNCTIONs
  4886. are stored in expanded memory, QBX.EXE makes a one-time allocation of
  4887. 32K (two 16K pages) in expanded memory as overhead for its own
  4888. internal tables.
  4889.  
  4890. QBX.EXE in BASIC PDS version 7.10 is enhanced so that memory is
  4891. allocated in 1K pages; for example, a 1K procedure or array takes up
  4892. 1K, thus using expanded memory much more efficiently than in QBX.EXE
  4893. 7.00.
  4894.  
  4895. This article applies to Microsoft BASIC Professional Development
  4896. System (PDS) versions 7.00 and 7.10 for MS-DOS.
  4897.  
  4898. More Information:
  4899.  
  4900. Examples of Expanded Memory Usage in QBX.EXE 7.00
  4901. -------------------------------------------------
  4902.  
  4903. As an example for BASIC PDS 7.00, suppose QBX.EXE is run on a machine
  4904. for which FRE(-3) reports that 2720K of expanded memory is available.
  4905. When the first module-level statement is entered, FRE(-3) would then
  4906. return 2704K, 16K less. When the first SUB or FUNCTION is created
  4907. after that, FRE(-3) would return 2656K, 48K less -- 16K for the SUB or
  4908. FUNCTION itself and 32K for QBX.EXE's internal tables.
  4909.  
  4910. When SUBs, FUNCTIONs, module-level code units, or arrays (if /Ea is
  4911. used) are deleted, QBX.EXE deallocates the expanded memory they were
  4912. using. The tables, however, will not be deallocated unless New Program
  4913. is chosen from the File menu.
  4914.  
  4915. In 7.00, a single-element integer array takes the same expanded memory
  4916. space (16K) as an array with 8192 elements. Likewise, a SUB with a
  4917. single PRINT statement takes the same space (16K) as a large SUB with
  4918. hundreds of statements. (This is no longer true in 7.10, where
  4919. expanded memory usage is more efficient.)
  4920.  
  4921. To use expanded memory to its best potential in the QBX.EXE 7.00
  4922. environment, you should try to make your SUBs as close to the 16K
  4923. limit as possible without exceeding it. (This is not necessary in
  4924. 7.10.) The size of the SUBs (in kilobytes) is listed in the View Subs
  4925. (F2) dialog box to the right of each SUB.
  4926.  
  4927. Likewise, arrays in QBX.EXE 7.00 will use expanded memory more
  4928. efficiently if they are dimensioned to be just under the 16K page
  4929. size. (This is not necessary in 7.10.)
  4930.  
  4931. References:
  4932.  
  4933. Microsoft BASIC Professional Development System (PDS) versions 7.00
  4934. and 7.10 offer expanded memory support under the Lotus-Intel-Microsoft
  4935. version 4.0 Expanded Memory Specification (LIM 4.0 EMS) for code and
  4936. data in the QBX.EXE environment under MS-DOS. Earlier versions do not
  4937. offer any expanded memory support. LIM 4.0 EMS support is discussed in
  4938. the "Microsoft BASIC 7.0: Getting Started" manual and in the
  4939. "Microsoft BASIC 7.1: Getting Started" manual.
  4940.  
  4941. To be compatible with BASIC PDS 7.00 or 7.10, the expanded-memory
  4942. device driver must observe the LIM 4.0 EMS.
  4943.  
  4944. Keywords:  SR# S900228-5
  4945.  
  4946. COPYRIGHT Microsoft Corporation, 1990.
  4947. Updated  90/08/11 05:20
  4948. _____________________________________________________________________________
  4949. Q48205 Example of BASIC Function Returning a String to C
  4950. Microsoft QuickBASIC Compiler (QUICKBAS)
  4951. 4.00 4.00b 4.50
  4952. MS-DOS
  4953.  
  4954. Summary:
  4955.  
  4956. The two programs below demonstrate how a Microsoft BASIC function can
  4957. return a string to C.
  4958.  
  4959. This information about interlanguage calling applies to QuickBASIC
  4960. versions 4.00, 4.00b, 4.50 for MS-DOS, to Microsoft BASIC Compiler
  4961. versions 6.00 and 6.00b for MS-DOS and MS OS/2, and to Microsoft BASIC
  4962. Professional Development System (PDS) versions 7.00 and 7.10 for
  4963. MS-DOS and MS OS/2.
  4964.  
  4965. For BASIC PDS 7.00 and 7.10, this example applies to near strings
  4966. only. If you are using far strings (/Fs during compile or in the
  4967. QBX.EXE environment), you must use the string-manipulation routines
  4968. supplied with BASIC PDS 7.00 and 7.10 (StringAssign, StringRelease,
  4969. StringAddress, and StringLength). For more information about using far
  4970. strings, see Chapter 13 of the "Microsoft BASIC 7.0: Programmer's
  4971. Guide" for versions 7.00 and 7.10.
  4972.  
  4973. More Information:
  4974.  
  4975. For more information about passing other types of parameters between
  4976. BASIC and C, and a list of which BASIC and C versions are compatible
  4977. with each other, search in the Software/Data Library for the following
  4978. word:
  4979.  
  4980.    BAS2C
  4981.  
  4982. Code Example
  4983. ------------
  4984.  
  4985. The following BASIC program is BSTRF.BAS, which contains a function
  4986. that returns a string to a calling C routine:
  4987.  
  4988.    DECLARE SUB CSUB CDECL ()
  4989.    CALL CSUB
  4990.    END
  4991.  
  4992.    FUNCTION basvarfunc$(dummy%)
  4993.       basvarfunc$ = "This is the string"
  4994.    END FUNCTION
  4995.  
  4996. The following program is CSTRF.C, which calls a BASIC routine that
  4997. returns a string. A string descriptor is created to receive the data
  4998. returned by the BASIC function.
  4999.  
  5000. #include <stdio.h>
  5001. struct stringdesc
  5002.        {
  5003.         int length;       /* string length */
  5004.         char *string;     /* string address */
  5005.        };
  5006. extern struct stringdesc * pascal basvarfunc(int *dummy);
  5007. struct stringdesc *std;
  5008. void csub()
  5009. {
  5010.    int i;
  5011.  
  5012.    std = basvarfunc(0);
  5013.  
  5014.    printf("Length of string: %2d\r\n", std->length);
  5015.  
  5016.    for(i = 0; i < std->length; i++)
  5017.       printf("%c", std->string[i]);
  5018.  
  5019.    printf("\r\n");
  5020.  
  5021. }
  5022.  
  5023. To demonstrate these programs from an .EXE program, compile and link
  5024. as follows:
  5025.  
  5026.    BC BSTRF.BAS;
  5027.    CL /c /AM CSTRF.C;
  5028.    LINK /NOE BSTRF CSTRF;
  5029.  
  5030. BSTRF.EXE produces the following output:
  5031.  
  5032.    Length of String: 18
  5033.    This is the string
  5034.  
  5035. Keywords:  B_BasicCom S_C S_QuickC
  5036.  
  5037. COPYRIGHT Microsoft Corporation, 1990.
  5038. Updated  90/08/11 05:20
  5039. _____________________________________________________________________________
  5040. Q48207 Example of Passing Strings from C to BASIC
  5041. Microsoft QuickBASIC Compiler (QUICKBAS)
  5042. 4.00 4.00b 4.50
  5043. MS-DOS
  5044.  
  5045. Summary:
  5046.  
  5047. The two programs below demonstrate how Microsoft C can create and pass
  5048. both fixed-length and variable-length strings to Microsoft BASIC.
  5049.  
  5050. This information about interlanguage calling applies to QuickBASIC
  5051. versions 4.00, 4.00b, 4.50 for MS-DOS, to Microsoft BASIC Compiler
  5052. versions 6.00 and 6.00b for MS-DOS and MS OS/2, and to Microsoft BASIC
  5053. Professional Development System (PDS) versions 7.00 and 7.10 for
  5054. MS-DOS and MS OS/2.
  5055.  
  5056. For BASIC PDS 7.00 and 7.10, this example works only with near
  5057. strings. If you are using far strings (BC /Fs compile switch or in
  5058. QBX.EXE), you must use the string-manipulation routines provided with
  5059. BASIC PDS 7.00 and 7.10 to change variable-length strings
  5060. (StringAssign, StringRelease, StringAddress, and StringLength). For
  5061. more information about using far strings, see Chapter 13 of the
  5062. "Microsoft BASIC 7.0: Programmer's Guide" for versions 7.00 and 7.10.
  5063.  
  5064. More Information:
  5065.  
  5066. For more information about passing other types of parameters between
  5067. BASIC and C and a list of which BASIC and C versions are compatible
  5068. with each other, search in the Software/Data Library for the following
  5069. word:
  5070.  
  5071.    BAS2C
  5072.  
  5073. Code Example
  5074. ------------
  5075.  
  5076. The following BASIC program is BSUB.BAS, which invokes a C routine
  5077. that creates two strings and passes them to a BASIC subroutine. The
  5078. BASIC subroutine prints out the string (and the string's length)
  5079. received from the C routine.
  5080.  
  5081.    DECLARE SUB CSUB CDECL()
  5082.    TYPE fixstringtype        ' Must use type to pass fixed-length string
  5083.       B AS STRING * 26       '  in parameter list.
  5084.    END TYPE
  5085.    CALL CSUB
  5086.    END
  5087.  
  5088.    SUB BASSUB(A$, B AS fixstringtype)  ' Subroutine called from C
  5089.       PRINT A$
  5090.       PRINT LEN(A$)
  5091.       PRINT B.B
  5092.       PRINT LEN(B.B)
  5093.    END SUB
  5094.  
  5095. The following program is CSUB.C, which builds a string descriptor that
  5096. is passed to a called BASIC subroutine:
  5097.  
  5098. #include <string.h>
  5099. struct stringdesc
  5100.        {
  5101.         int length;       /* string length */
  5102.         char *string;     /* near address of the string */
  5103.        };
  5104. extern void pascal bassub(struct stringdesc *basstring,
  5105.                           char *basfixstring);
  5106. struct stringdesc *std;
  5107. char thesecondstring[26];
  5108.  
  5109. void csub()
  5110. {                                         /* create the strings */
  5111.    std->length = 18;
  5112.    strcpy(std->string, "This is the string");
  5113.    strcpy(thesecondstring, "This is the second string");
  5114.    bassub(std, thesecondstring);          /* call BASIC subroutine */
  5115. }
  5116.  
  5117. To demonstrate these programs from an .EXE program, compile and link
  5118. as follows:
  5119.  
  5120.    BC BSUB.BAS;
  5121.    CL /c /AM CSUB.C;
  5122.    LINK /NOE BSUB CSUB;
  5123.  
  5124. BSUB.EXE produces the following output:
  5125.  
  5126.    This is the string
  5127.    18
  5128.    This is the second string
  5129.    26
  5130.  
  5131. Keywords:  B_BasicCom S_C S_QuickC
  5132.  
  5133. COPYRIGHT Microsoft Corporation, 1990.
  5134. Updated  90/08/11 05:20
  5135. _____________________________________________________________________________
  5136. Q59727 Legal Data Delimiters When Using INPUT #n Statement
  5137. Microsoft QuickBASIC Compiler (QUICKBAS)
  5138. 2.00 2.01 3.00 4.00 4.00b 4.50
  5139. MS-DOS
  5140.  
  5141. Summary:
  5142.  
  5143. This article corrects several documentation errors concerning how to
  5144. delimit data in a sequential file that is to be read by the INPUT#
  5145. statement.
  5146.  
  5147. The INPUT# statement reads data items from a sequential device or file
  5148. and assigns them to variables. If the data items in the file are
  5149. numeric values, they should be separated with a space, carriage return
  5150. (CR), or comma. Strings should be separated with a carriage return or
  5151. a comma, or enclosed in double quotation marks. A linefeed (LF) by
  5152. itself should not be used as a file delimiter in either case.
  5153.  
  5154. More Information:
  5155.  
  5156. The following references incorrectly state that a linefeed may be used
  5157. as a delimiter between data items in a file. These references also
  5158. omit the fact that string data may be delimited by a comma.
  5159.  
  5160. 1. Page 304 of the "Microsoft QuickBASIC Compiler" manual for versions
  5161.    2.00, 2.01, and 3.00
  5162.  
  5163. 2. Page 225 of the "Microsoft QuickBASIC 4.0: BASIC Language
  5164.    Reference" manual for QuickBASIC versions 4.00 and 4.00b
  5165.  
  5166. 3. Page 225 of the "Microsoft BASIC Compiler 6.0: BASIC Language
  5167.    Reference" manual for versions 6.00 and 6.00b
  5168.  
  5169. 4. Page 167 of the "Microsoft BASIC 7.0: Language Reference" manual
  5170.    for Microsoft BASIC Professional Development System (PDS)
  5171.    versions 7.00 and 7.10
  5172.  
  5173. 5. Under the INPUT# statement in the QB Advisor online Help system
  5174.    for QuickBASIC version 4.50
  5175.  
  5176. In addition, all the above references (except #4) incorrectly state
  5177. that string data items may be delimited with spaces. Only numeric data
  5178. items may be delimited with spaces. String data items must be
  5179. delimited by a comma or a carriage return, or enclosed in double
  5180. quotation marks.
  5181.  
  5182. If you need some other character, such as a linefeed by itself, to act
  5183. as a delimiter, then a file may be read in BINARY mode. When a file is
  5184. opened in BINARY mode, the data is not interpreted and the program
  5185. must be written to interpret or "filter" each character as needed.
  5186.  
  5187. The following is a description of how the INPUT# statement handles a
  5188. linefeed, carriage return, space, and comma if one of these characters
  5189. is used as a delimiter between data items. Also, the program below
  5190. exhibits the behavior of these characters when used as delimiters.
  5191.  
  5192. Numeric Input Syntax: INPUT #n, <numeric variable>
  5193. --------------------------------------------------
  5194.  
  5195. This reads a linefeed in as a numeric value instead of a delimiter.
  5196. Each time a linefeed is encountered, the linefeed character is treated
  5197. as a data item and a value of 0 is returned for the input.
  5198.  
  5199. A carriage return, space, or comma functions correctly as a delimiter
  5200. for numeric input.
  5201.  
  5202. String Input Syntax:  INPUT #n, <string variable>
  5203. -------------------------------------------------
  5204.  
  5205. This ignores the linefeed character completely. If two data items are
  5206. separated by a linefeed and read in as strings, the two data items are
  5207. read in as one string that is a concatenation of the two data items.
  5208.  
  5209. A space between two data items causes the two data items to be read in
  5210. as one string, and the space is an actual character in that string.
  5211.  
  5212. A carriage return or comma functions correctly as a delimiter. If a
  5213. comma appears between a pair of double quotation marks, the comma is
  5214. treated as part of the string. A carriage return always acts as a
  5215. delimiter, terminating any string delimited by a beginning double
  5216. quotation mark.
  5217.  
  5218. Sample Code
  5219. -----------
  5220.  
  5221. CLS
  5222. INPUT "Enter 'q' to quit.  Enter 'c' to continue==> ", start$
  5223.  
  5224. WHILE start$ <> "q"
  5225.  CLS
  5226.  
  5227.  OPEN "numeric.dat" FOR OUTPUT AS #1
  5228.  OPEN "string.dat" FOR OUTPUT AS #2
  5229.  
  5230.  PRINT "Input the ASCII code for the delimiter you wish to attempt:"
  5231.  PRINT "   10 = line feed"
  5232.  PRINT "   13 = carriage return"
  5233.  PRINT "   32 = space"
  5234.  INPUT "   44 = comma =============>", delimit%
  5235.  
  5236.  num1% = 5: num2% = 10        'define data to be put in numeric file
  5237.  str1$ = "hi": str2$ = "mom"  'define data to be put in string file
  5238.  
  5239.  PRINT #1, num1%; CHR$(delimit%); num2%  'write data separated by
  5240.  PRINT #2, str1$; CHR$(delimit%); str2$  'chosen delimiter to file
  5241.  
  5242.  CLOSE
  5243.  
  5244.  OPEN "numeric.dat" FOR INPUT AS #1
  5245.  OPEN "string.dat" FOR INPUT AS #2
  5246.  
  5247.  PRINT
  5248.  count% = 0
  5249.  PRINT "This file contains the numeric values 5 and 10."
  5250.  PRINT "==============================================="
  5251.  DO UNTIL EOF(1)
  5252.      count% = count% + 1
  5253.      INPUT #1, inp1%
  5254.      PRINT "Value read in after"; count%; "input(s):"; inp1%
  5255.  LOOP
  5256.  
  5257.  PRINT
  5258.  count% = 0
  5259.  PRINT "This file contains the string values 'hi' and 'mom'."
  5260.  PRINT "===================================================="
  5261.  DO UNTIL EOF(2)
  5262.      count% = count% + 1
  5263.      INPUT #2, inp2$
  5264.      PRINT "Value read in after"; count%; "input(s): "; inp2$
  5265.  LOOP
  5266.  
  5267.  CLOSE
  5268.  
  5269.  PRINT : PRINT
  5270.  INPUT "Press 'q' to quit.  Press 'c' to continue==> ", start$
  5271. WEND
  5272. END
  5273.  
  5274. Keywords:  SR# S900312-105 B_BasicCom docerr
  5275.  
  5276. COPYRIGHT Microsoft Corporation, 1990.
  5277. Updated  90/08/11 05:20
  5278. _____________________________________________________________________________
  5279. Q64428 Assembly Function Returning Variable-Length String to BASIC
  5280. Microsoft QuickBASIC Compiler (QUICKBAS)
  5281. 4.00 4.00b 4.50
  5282. MS-DOS
  5283.  
  5284. Summary:
  5285.  
  5286. The two programs below demonstrate how an assembly language function
  5287. can return a variable-length string to a Microsoft BASIC program.
  5288.  
  5289. Note: This routine will not work inside the QuickBASIC Extended
  5290. environment (QBX.EXE) or when compiled using the Far Strings option
  5291. (BC /Fs) in Microsoft BASIC Professional Development System (PDS)
  5292. version 7.00 or 7.10. For information on interlanguage programming
  5293. with far strings in Microsoft BASIC PDS, see Chapter 13, "Mixed
  5294. Language Programming with Far Strings," in the "Microsoft BASIC 7.0:
  5295. Programmer's Guide" for versions 7.00 and 7.10.
  5296.  
  5297. This information about interlanguage calling applies to QuickBASIC
  5298. versions 4.00, 4.00b, and 4.50 for MS-DOS, to Microsoft BASIC Compiler
  5299. versions 6.00 and 6.00b for MS-DOS and MS OS/2, and to Microsoft BASIC
  5300. PDS versions 7.00 and 7.10 for MS-DOS and MS OS/2.
  5301.  
  5302. More Information:
  5303.  
  5304. For more information about passing other types of parameters between
  5305. BASIC and MASM, query in the Software/Data Library or this Knowledge
  5306. Base for the following word:
  5307.  
  5308.    BAS2MASM
  5309.  
  5310. Code Example
  5311. ------------
  5312.  
  5313. The following BASIC program is SFUNC.BAS, which displays a
  5314. variable-length string returned from an assembly language function
  5315. (QPrint).
  5316.  
  5317.    DECLARE FUNCTION QPrint$(slen%)
  5318.    CLS
  5319.    FOR i% = 1 to 3
  5320.       TString$ = QPrint$(i%)  ' i% is the length of the string
  5321.       PRINT TSTring$, LEN(TString$)
  5322.    NEXT
  5323.  
  5324. The following assembly language program is ASTR.ASM, which contains
  5325. the function QPrint. The QPrint function returns a string, and the
  5326. passed integer parameter (argument) returns the length of the string.
  5327.  
  5328. ; The following handy .MODEL MEDIUM,BASIC directive is found in MASM
  5329. ; 5.10 but not in earlier versions:
  5330. .MODEL MEDIUM, BASIC
  5331. .DATA
  5332.         str      db 10 dup (?)    ; my own string
  5333.         mystring dw ?             ; my own descriptor (length)
  5334.                  dw ?             ;  (offset)
  5335.  
  5336. .CODE
  5337.         PUBLIC QPrint
  5338. QPrint  PROC
  5339.         push bp
  5340.         mov bp, sp
  5341.         push ds
  5342.         push es
  5343.  
  5344.         mov bx, [bp+6]      ; get the ptr to the string descriptor.
  5345.         mov cx, [bx]
  5346.  
  5347.         push ds
  5348.         pop es                    ; set es = ds
  5349.  
  5350.         mov di, offset dgroup:str ; load the offset into di
  5351.         mov al, 'a'               ; load character to fill
  5352.         rep stosb                 ; store "a" into the string
  5353.         mov cx, [bx]              ; put the length in cx again
  5354.         mov bx, offset dgroup:mystring ; put offset of string
  5355.                                        ;  descriptor in bx
  5356.         mov [bx], cx                   ; length in first two bytes
  5357.         mov [bx+2], offset dgroup:str  ; offset into second two bytes
  5358.         mov ax, bx                     ; load address of descriptor
  5359.                                        ;   into ax
  5360.         pop es
  5361.         pop ds
  5362.         pop bp
  5363.  
  5364.         ret 2
  5365. QPrint  ENDP
  5366.         END
  5367.  
  5368. To demonstrate these programs from an .EXE program, compile and link
  5369. as follows:
  5370.  
  5371.    BC SFUNC.BAS;
  5372.    MASM ASTR.ASM;
  5373.    LINK SFUNC ASTR;
  5374.  
  5375. SFUNC.EXE produces the following output:
  5376.  
  5377.    a
  5378.    aa
  5379.    aaa
  5380.  
  5381. Keywords:  B_BasicCom H_MASM S_QUICKASM SR# S900718-47
  5382.  
  5383. COPYRIGHT Microsoft Corporation, 1990.
  5384. Updated  90/08/14 05:27
  5385. _____________________________________________________________________________
  5386. Q65177 "Out of Stack Space" Using RETURN <linenumber> for SUB Event
  5387. Microsoft BASIC Compiler (BASICCOM)
  5388. 6.00 6.00b 7.00 7.10 | 6.00 6.00b 7.00 7.10
  5389. MS-DOS               | OS/2
  5390.  
  5391. Summary:
  5392.  
  5393. If an event occurs in a procedure (SUB or FUNCTION), then returning
  5394. from event-handling with the RETURN <linenumber> statement always
  5395. leaves unrecoverable information on the stack, which can lead to the
  5396. error message "Out of Stack Space" after many trapped events.
  5397.  
  5398. This behavior is a result of violating the following design rule: to
  5399. correctly restore (pop) the stack after handling an event, you must
  5400. always return to the procedure level where the event occurred. This
  5401. applies to all events trapped with the ON <event> GOSUB statement
  5402. (where <event> includes COM, KEY, PEN, PLAY, TIMER, STRIG, and
  5403. others).
  5404.  
  5405. RETURN <linenumber> or <linelabel> is only designed to return from
  5406. events that occur at the module-level (main-level) code. This
  5407. correctly pops the stack.
  5408.  
  5409. You must use RETURN without the <linenumber> or <linelabel> option if
  5410. you want to RETURN to a SUB or FUNCTION procedure where an event was
  5411. trapped. This correctly pops the stack.
  5412.  
  5413. This information applies to Microsoft BASIC Professional Development
  5414. System (PDS) versions 7.00 and 7.10 for MS-DOS and MS OS/2; to
  5415. Microsoft BASIC Compiler versions 6.00 and 6.00b for MS-DOS and MS
  5416. OS/2; and to Microsoft QuickBASIC versions 1.00, 1.01, 1.02, 2.00,
  5417. 2.01, 3.00, 4.00, 4.00b, and 4.50 for MS-DOS.
  5418.  
  5419. More Information:
  5420.  
  5421. To demonstrate the "Out of stack space" message, run the following
  5422. program and hold down the ESC key, which will be trapped in a loop
  5423. until the error occurs. The "Out of stack space" error occurs because
  5424. this program incorrectly allows events in the SUB to be handled by the
  5425. RETURN <linelabel> instead of an ordinary RETURN.
  5426.  
  5427. Code Example
  5428. ------------
  5429.  
  5430. DECLARE SUB test ()
  5431. ' This is an example where the RETURN <linenumber>
  5432. ' statement gives you "Out of Stack Space" (after about 53 ESC key
  5433. ' trap iterations in QBX.EXE, or 118 if compiled in BC.EXE) when the
  5434. ' event (pressing the ESC key) is trapped in a SUB procedure.
  5435. KEY 15, CHR$(0) + CHR$(1)    ' Trap ESC key
  5436. ON KEY(15) GOSUB escape
  5437. KEY(15) ON
  5438. PRINT "now in main"
  5439. again:
  5440.   CALL test
  5441.   PRINT "Done"
  5442. END
  5443. escape:
  5444.   j = j + 1
  5445. ' The FRE(-2) function returns a value decreased at each iteration by
  5446. ' the number of bytes of stack (associated with the SUBprogram) that
  5447. ' were lost:
  5448.   PRINT j; "ESC key was pressed. Continue in main. FRE(-2)="; FRE(-2)
  5449.   KEY(15) ON   ' <-- Must say KEY(15) ON here or else the
  5450.                '   RETURN <linelabel> statement will leave the
  5451.                '   ON KEY(15) GOSUB trap still active, which does an
  5452.                '   implied KEY(15) STOP. If the key had been trapped
  5453.                '   in the main program, then RETURN <linelabel> would
  5454.                '   work normally, and you wouldn't have to use
  5455.                '   KEY(15) ON here.
  5456.   RETURN again
  5457.  
  5458. SUB test STATIC
  5459. PRINT "Now in SUB"
  5460. WHILE INKEY$ = "": WEND
  5461. PRINT "You pressed some key other than ESC."
  5462. END SUB
  5463.  
  5464. References:
  5465.  
  5466. The following is taken from Page 296 (under the "RETURN Statement") of
  5467. "Microsoft BASIC 7.0: Language Reference" for versions 7.00 and 7.10:
  5468.  
  5469.    RETURN with a line label or line number can return control to a
  5470.    statement in the module-level code only, not in procedure-level
  5471.    code.
  5472.  
  5473. The following is taken from Page 227 (under the heading "ON event
  5474. Statement") of "Microsoft BASIC 7.0: Language Reference" for versions
  5475. 7.00 and 7.10:
  5476.  
  5477.    The RETURN linenumber or RETURN linelabel forms of RETURN can be
  5478.    used to return to a specific line from the trapping routine. Use
  5479.    this type of return with care, however, because any GOSUB, WHILE,
  5480.    or FOR statements active at the time of the trap remain active.
  5481.    BASIC may generate error messages such as NEXT without FOR. In
  5482.    addition, if an event occurs in a procedure, a RETURN linenumber or
  5483.    RETURN linelabel statement cannot get back into the procedure
  5484.    because the line number or label must be in the module-level code.
  5485.  
  5486. The above information is accurate, but it should be added that if an
  5487. event occurs in a procedure (SUB or FUNCTION), then returning from
  5488. event-handling with the RETURN <linenumber> statement leaves
  5489. unrecoverable information on the stack, which eventually leads to the
  5490. error message "Out of Stack Space" after many trapped events.
  5491.  
  5492. Keywords:  B_QuickBas
  5493.  
  5494. COPYRIGHT Microsoft Corporation, 1990.
  5495. Updated  90/09/05 05:25
  5496. _____________________________________________________________________________
  5497. Q65287 Must Use BYVAL at Both Ends When CALLing 7.10 SUB or FUNCTION
  5498. Microsoft BASIC Compiler (BASICCOM)
  5499. 7.10   | 7.10
  5500. MS-DOS | OS/2
  5501.  
  5502. Summary:
  5503.  
  5504. When passing parameters by value to a BASIC SUBprogram or FUNCTION
  5505. procedure, you must use the BYVAL attribute from both the calling end
  5506. and the receiving end.
  5507.  
  5508. By itself, using BYVAL in the SUB or FUNCTION statement (at the
  5509. receiving end) isn't enough to tell the SUB or FUNCTION to pass by
  5510. value. If you don't also use the BYVAL attribute in the CALL statement
  5511. or the DECLARE statement, then by default BASIC will pass by reference
  5512. and push only the address of the variable on the stack. If you
  5513. mistakenly use BYVAL only at the calling end or only at the receiving
  5514. end, then an incorrect value will be passed.
  5515.  
  5516. This information only applies to Microsoft BASIC Professional
  5517. Development System (PDS) version 7.10, since passing parameters to
  5518. BASIC SUBprograms and FUNCTIONS with the BYVAL attribute was first
  5519. introduced version 7.10.
  5520.  
  5521. More Information:
  5522.  
  5523. Note for Versions Earlier Than 7.10: In Microsoft BASIC PDS version
  5524. 7.00, in Microsoft BASIC Compiler versions 6.00 and 6.00b, and in
  5525. QuickBASIC versions 4.00, 4.00b, and 4.50, you could not DECLARE or
  5526. CALL a BASIC routine with parameters having the BYVAL attribute, since
  5527. BYVAL could be used only for parameters of non-BASIC routines (such as
  5528. C or Macro Assembler).
  5529.  
  5530. NOTE: If you create a program in an editor outside the QBX.EXE
  5531. environment without DECLARE statements at the top of the program,
  5532. DECLARE statements will not automatically be added to your code. As a
  5533. result, a SUB statement that contains a formal parameter with the
  5534. BYVAL attribute (at the receiving end) will have no BYVAL declaration
  5535. at the calling end. Instead of specifying BYVAL in a DECLARE
  5536. statement, you can specify BYVAL in the CALL statement.
  5537.  
  5538. Code Example: Incorrect Way to Pass by Value
  5539. --------------------------------------------
  5540.  
  5541. The program below, written in an editor outside of the QBX.EXE
  5542. environment, will pass the offset of the variable A& to the
  5543. SUBprogram, although the SUBprogram is expecting the actual value
  5544. contained in A&. This happens because each end of the call to the
  5545. SUBprogram acts blindly on the information that it has. The call to
  5546. TestPass blindly assumes that it is passing a value by reference,
  5547. which is the default. It therefore passes the offset (in this case
  5548. 3030) of the variable A& to the SUBprogram TestPass. The SUBprogram
  5549. TestPass is expecting to receive the value of the variable A&, as is
  5550. dictated by the BYVAL attribute in the SUB statement. The program
  5551. therefore prints 3030 (the offset) on the screen, instead of the
  5552. constant 2 (the value).
  5553.  
  5554. CALL TestPass (2&)  'Notice no declaration of BYVAL in CALL or
  5555.                     'DECLARE, so default is pass (send) by reference.
  5556. SUB TestPass(BYVAL A&)  'BYVAL in SUB says to pass (receive) by value.
  5557.     B& = A&
  5558.     PRINT A&        ' Prints 3030, the offset of A&.
  5559. END SUB
  5560.  
  5561. Correct Way to Pass by Value, Using BYVAL in DECLARE and SUB
  5562. ------------------------------------------------------------
  5563.  
  5564. DECLARE SUB TestPass(BYVAL A&)
  5565. ' BYVAL in the above DECLARE means to pass (send) by value.
  5566. CALL TestPass (2&)
  5567. SUB TestPass(BYVAL A&)  'BYVAL in SUB means pass (receive) by value.
  5568.     B& = A&
  5569.     PRINT A&      ' prints 2, the value (contents) of A&
  5570. END SUB
  5571.  
  5572. Another Correct Way to Pass by Value, Using BYVAL in CALL and SUB
  5573. -----------------------------------------------------------------
  5574.  
  5575. CALL TestPass (BYVAL 2&)  'BYVAL in CALL means pass (send) by value.
  5576. SUB TestPass(BYVAL A&)    'BYVAL in SUB means pass (receive) by value.
  5577.     B& = A&
  5578.     PRINT A&      ' prints 2, the value (contents) of A&
  5579. END SUB
  5580.  
  5581. References
  5582. ----------
  5583.  
  5584. The following is taken from the README.DOC file for BASIC 7.10:
  5585.  
  5586.    In version 7.10, BASIC supports the use of the BYVAL keyword
  5587.    in CALL, DECLARE, SUB, and FUNCTION statements for BASIC
  5588.    procedures. You can use BYVAL to pass parameters by value
  5589.    rather than by reference (the default). It is no longer
  5590.    necessary to enclose parameters in parentheses to emulate
  5591.    passing by value. For more information and an example of using
  5592.    BYVAL in BASIC procedures, see the online Help for the DECLARE
  5593.    statement (BASIC procedures). For specifics on using BYVAL with
  5594.    CALL, see the online Help for the CALL statement (BASIC
  5595.    procedures).
  5596.  
  5597. Keywords:  SR# S900820-85
  5598.  
  5599. COPYRIGHT Microsoft Corporation, 1990.
  5600. Updated  90/09/05 05:25
  5601. _____________________________________________________________________________
  5602. Q41533 BASIC 7.00 Can Return Exit Code (Error Level) to Batch File
  5603. Microsoft QuickBASIC Compiler (QUICKBAS)
  5604. 1.00 1.01 1.02 2.00 2.01 3.00 4.00 4.00b 4.50
  5605. MS-DOS
  5606.  
  5607. Summary:
  5608.  
  5609. MS-DOS batch processing (.BAT) files can use an "IF ERRORLEVEL n"
  5610. statement to detect exit code levels returned by some programs.
  5611.  
  5612. However, the only versions of Microsoft BASIC that allow a program to
  5613. return an error level code to MS-DOS are Microsoft BASIC Professional
  5614. Development System (PDS) versions 7.00 and 7.10. The END n or STOP n
  5615. statement returns error level n to the batch file that invoked the
  5616. BASIC 7.00 or 7.10 .EXE program. The IF ERRORLEVEL n statement in the
  5617. batch file can detect if the returned exit code is equal to or greater
  5618. than n.
  5619.  
  5620. In all other versions of Microsoft BASIC, the error level (exit) code
  5621. returned by a BASIC program is controlled by the BASIC run-time
  5622. module, not by your program. As an alternative, you can create a file
  5623. in the BASIC program to serve as a flag when a certain condition
  5624. occurs. The batch file that called your program can then check for the
  5625. existence of the flag file in place of checking for an error level. In
  5626. batch files, the "IF EXIST filename" command can be used.
  5627.  
  5628. The following products do not allow your program to return an error
  5629. level to MS-DOS batch files:
  5630.  
  5631. 1. QuickBASIC versions 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00,
  5632.    4.00b, and 4.50 for MS-DOS
  5633.  
  5634. 2. Microsoft GW-BASIC versions 3.20, 3.22, and 3.23 for MS-DOS
  5635.  
  5636. 3. Microsoft BASIC Compiler versions 5.35 and 5.36 for MS-DOS and
  5637.    versions 6.00 and 6.00b for MS-DOS and MS OS/2
  5638.  
  5639. More Information:
  5640.  
  5641. Your BASIC program must not attempt to invoke any MS-DOS interrupts
  5642. (CALL INTERRUPT) to terminate the program with an error level;
  5643. otherwise, strange results may occur and the machine may hang. BASIC
  5644. must handle program termination by itself.
  5645.  
  5646. BASIC 7.00 or 7.10 Can Return Exit Code (ERRORLEVEL) to Batch File
  5647. ------------------------------------------------------------------
  5648.  
  5649. An .EXE program compiled in BASIC 7.00 or 7.10 can use the STOP n% or
  5650. END n% statement to return an exit code (n%) to MS-DOS, as follows:
  5651.  
  5652.    ' TEST.BAS
  5653.    PRINT "This is a BASIC program that returns an exit code of 5."
  5654.    n% = 5
  5655.    END n%
  5656.  
  5657. The exit code can be trapped in a MS-DOS batch file with the IF
  5658. ERRORLEVEL n GOTO statement, as follows:
  5659.  
  5660.    TEST
  5661.    ECHO OFF
  5662.    IF NOT ERRORLEVEL 1 GOTO DONE
  5663.       ECHO  An error occurred with exit code 1 or higher.
  5664.    :DONE
  5665.    ECHO End of batch file.
  5666.  
  5667. Using a File as a Flag for a Batch File
  5668. ---------------------------------------
  5669.  
  5670. The following technique lets any BASIC version give a simple yes or no
  5671. message to a batch file.
  5672.  
  5673. The following batch file, ERRT.BAT, calls the BASIC program ERRTST,
  5674. which drops back to the batch file. It then checks for the existence
  5675. of the file ERRFIL (which is an arbitrary name) to see if an error
  5676. occurred while running the BASIC program:
  5677.  
  5678.    echo off
  5679.    del errfil
  5680.    errtst
  5681.    if not exist errfil goto end
  5682.    echo An error occurred during program running
  5683.    :end
  5684.    echo End of batch file
  5685.  
  5686. The following file is ERRTST.BAS; it creates the error file if it
  5687. cannot open the file GARBAGE.DAT:
  5688.  
  5689. ' set up to error out if "GARBAGE.DAT" does not exist
  5690. ON ERROR GOTO errorlevel
  5691. OPEN "garbage.dat" FOR INPUT AS #1
  5692. CLOSE #1
  5693. END
  5694. errorlevel:
  5695.    CLOSE #1
  5696.    OPEN "errfil" FOR OUTPUT AS #1   'Create file that acts as a flag
  5697.    CLOSE #1
  5698.    SYSTEM   ' Returns to DOS.
  5699.  
  5700. To demonstrate this procedure, compile and link ERRTST.BAS as follows:
  5701.  
  5702.    BC ERRTST.BAS;
  5703.    LINK ERRTST.OBJ;
  5704.  
  5705. Now run the batch file ERRT.BAT. If the BASIC program cannot find
  5706. GARBAGE.DAT, ERRT.BAT shows "An error occurred during program
  5707. running."
  5708.  
  5709. Keywords:  B_BasicCom B_GWBasicI SR# S890216-141
  5710.  
  5711. COPYRIGHT Microsoft Corporation, 1990.
  5712. Updated  90/09/05 05:25
  5713. _____________________________________________________________________________
  5714. Q37340 MS-DOS QuickBASIC 4.00 Differs from XENIX BASIC Compiler 5.70
  5715. Microsoft QuickBASIC Compiler (QUICKBAS)
  5716. 4.00 4.00b 4.50
  5717. MS-DOS
  5718.  
  5719. Summary:
  5720.  
  5721. This article compares Microsoft BASIC Compiler versions 5.70 and 5.70a
  5722. for XENIX 286 to the following compilers:
  5723.  
  5724. 1. Microsoft QuickBASIC versions 4.00, 4.00b, 4.50 for MS-DOS
  5725.  
  5726. 2. Microsoft BASIC Compiler versions 6.00 and 6.00b for MS-DOS
  5727.  
  5728. Microsoft BASIC Compiler for XENIX 286 provides a library for ISAM
  5729. file handling that is not available with the above Microsoft BASIC
  5730. compilers for MS-DOS.
  5731.  
  5732. Microsoft BASIC Professional Development System (PDS) versions 7.00
  5733. and 7.10 provide ISAM file support under MS-DOS (and under MS OS/2 in
  5734. BASIC 7.10). BASIC PDS 7.00 and 7.10 offer additional features beyond
  5735. those found in 6.00 and 6.00b.
  5736.  
  5737. The BASIC compilers for MS-DOS have a graphic capability not found in
  5738. the XENIX BASIC compiler.
  5739.  
  5740. Compilers under both XENIX and MS-DOS have SUB...END SUB structures
  5741. for defining subprograms, which can be called with the CALL statement.
  5742.  
  5743. More Information:
  5744.  
  5745. Note: All support and upgrades for Microsoft BASIC Compilers and
  5746. Interpreters for XENIX have been assumed by SCO (the Santa Cruz
  5747. Operation). For more information on XENIX BASIC and SCO, query on the
  5748. following words:
  5749.  
  5750.    SCO and XENIX and BASIC and support
  5751.  
  5752. The list below outlines commands that differ between the BASIC
  5753. compiler for XENIX versus the BASIC products for MS-DOS.
  5754.  
  5755. An asterisk (*) marks words that are reserved, but not functionally
  5756. implemented in the compiler.
  5757.  
  5758. Reserved words in Microsoft BASIC Compiler version 6.00b for MS-DOS or
  5759. QuickBASIC version 4.50 that are not found in Microsoft BASIC Compiler
  5760. version 5.70a for XENIX are as follows:
  5761.  
  5762.    ACCESS      ALIAS       ANY         BEEP      BINARY
  5763.    BLOAD       BSAVE       BYVAL       CASE      CDECL
  5764.    CIRCLE      CLNG        COLOR       COM       COMMAND$
  5765.    CONST       CSRLIN      CVDMBF      CVSMBF    DECLARE
  5766.    DEFLNG      DO          DOUBLE      DRAW      ELSEIF
  5767.    ENVIRON     ENVIRON$    ERDEV       ERDEV$    EXIT
  5768.    FILEATTR    FREEFILE    FUNCTION    INP       INTEGER
  5769.    IOCTL       IOTCL$      IS          KEY       LCASE$
  5770.    * LIST      LOCAL       LONG        LOOP      LTRIM$
  5771.    MKDMBF$     MKL$        MKSMBF$     OFF       OUT
  5772.    PAINT       PALETTE     PCOPY       PEN       PLAY
  5773.    PMAP        PRESET      PSET        RANDOM    REDIM
  5774.    RTRIM$      SCREEN      SEEK        SEG       SELECT
  5775.    SETMEM      SHARED      SIGNAL      SINGLE    SLEEP
  5776.    SOUND       STATIC      STICK       STRING    TYPE
  5777.    UCASE$      UNTIL       VARPTR$     VARSEG    VIEW
  5778.    WINDOW
  5779.  
  5780. Reserved words in Microsoft BASIC Compiler version 5.70a for XENIX
  5781. that are not reserved in Microsoft BASIC Compiler version 6.00b for
  5782. MS-DOS or QuickBASIC version 4.50 are as follows:
  5783.  
  5784.    * DELETE
  5785.    * EDIT
  5786.    * USR
  5787.  
  5788. Keywords:  B_BasicCom
  5789.  
  5790. COPYRIGHT Microsoft Corporation, 1990.
  5791. Updated  90/09/06 06:19
  5792. _____________________________________________________________________________
  5793. Q47122 Example of Passing a Variable-Length String to Assembly
  5794. Microsoft QuickBASIC Compiler (QUICKBAS)
  5795. 4.00 4.00b 4.50
  5796. MS-DOS
  5797.  
  5798. Summary:
  5799.  
  5800. The program shown below demonstrates how to pass a variable-length
  5801. string by far reference to an assembly language routine.
  5802.  
  5803. This information applies to QuickBASIC versions 4.00, 4.00b, and 4.50,
  5804. to Microsoft BASIC Compiler versions 6.00 and 6.00b for MS-DOS and MS
  5805. OS/2, and to near variable-length strings in Microsoft BASIC
  5806. Professional Development System (PDS) versions 7.00 and 7.10 for
  5807. MS-DOS and MS OS/2.
  5808.  
  5809. More Information:
  5810.  
  5811. The following program is PSTRING.BAS, which passes a string to an
  5812. assembly language routine using the VARSEG and SADD functions. SADD
  5813. gives the actual address of the string, whereas VARPTR gives the
  5814. address of the string descriptor.
  5815.  
  5816. This example cannot be used in BASIC PDS 7.00 or 7.10 with far strings
  5817. (BC /Fs) or with QBX.EXE (which always uses far strings). For more
  5818. information about far strings, see Chapter 13 of "Microsoft BASIC 7.0:
  5819. Programmer's Guide" for versions 7.00 and 7.10.
  5820.  
  5821. DECLARE SUB PSTRING(BYVAL STRSEG AS INTEGER, BYVAL STROFF AS INTEGER)
  5822. A$ = "Hello World"
  5823. PRINT "Before call: ";
  5824. PRINT A$
  5825. CALL PSTRING(VARSEG(A$), SADD(A$))
  5826. PRINT "After call : ";
  5827. PRINT A$
  5828.  
  5829. The following separately compiled routine is PSTR.ASM:
  5830.  
  5831. ; The following handy .MODEL MEDIUM,BASIC directive is found in MASM
  5832. ; 5.10 but not in earlier versions:
  5833. .MODEL MEDIUM, BASIC
  5834. .CODE
  5835.  
  5836. pstring     PROC sseg:WORD, soff:WORD
  5837.             push bx                  ; save bx register, dx, and es
  5838.             push dx
  5839.             push es
  5840.  
  5841.             mov ax, sseg             ; get segment of string
  5842.             mov es, ax               ; put into segment register
  5843.             mov bx, soff
  5844.                                      ; 65 is ASCII value for letter 'A'.
  5845.             mov BYTE PTR es:[bx], 65 ; Move the 'A' to the first character
  5846.                                      ;  in the string.
  5847.             pop es
  5848.             pop dx
  5849.             pop bx                   ; restore (pop) es, dx, and bx
  5850.             ret
  5851. pstring     ENDP
  5852.             end
  5853.  
  5854. Compile and link the program as follows:
  5855.  
  5856.    BC PSTRING;
  5857.    MASM PSTR;
  5858.  
  5859.    LINK PSTRING PSTR;
  5860.  
  5861. When run, PSTRING should print the following:
  5862.  
  5863.    Before call: Hello World
  5864.    After call : Aello World
  5865.  
  5866. Keywords:  B_BasicCom
  5867.  
  5868. COPYRIGHT Microsoft Corporation, 1990.
  5869. Updated  90/09/06 06:19
  5870. _____________________________________________________________________________
  5871. Q47756 Example of C Function Returning a String to BASIC
  5872. Microsoft QuickBASIC Compiler (QUICKBAS)
  5873. 4.00 4.00b 4.50
  5874. MS-DOS
  5875.  
  5876. Summary:
  5877.  
  5878. The two programs shown below demonstrate how a C function can return a
  5879. string to a compiled BASIC program.
  5880.  
  5881. This information about interlanguage calling applies to QuickBASIC
  5882. versions 4.00, 4.00b, and 4.50 for MS-DOS, to Microsoft BASIC Compiler
  5883. versions 6.00 and 6.00b for MS-DOS and MS OS/2, and to Microsoft BASIC
  5884. Professional Development System (PDS) versions 7.00 and 7.10 for
  5885. MS-DOS and MS OS/2.
  5886.  
  5887. For Microsoft BASIC PDS 7.00 and 7.10, this example applies only to
  5888. near strings. If you are using far strings (BC /Fs on compile or when
  5889. using QBX.EXE), you must use the string-manipulation routines supplied
  5890. with BASIC PDS 7.00 and 7.10 (StringAssign, StringRelease,
  5891. StringAddress, and StringLength). For more information about far
  5892. strings, see Chapter 13 of "Microsoft BASIC 7.0: Programmer's Guide"
  5893. for versions 7.00 and 7.10.
  5894.  
  5895. More Information:
  5896.  
  5897. For more information about passing other types of parameters between
  5898. BASIC and C and a list of which BASIC and C versions are compatible
  5899. with each other, query in the Software/Data Library on the following
  5900. word:
  5901.  
  5902.    BAS2C
  5903.  
  5904. Code Example
  5905. ------------
  5906.  
  5907. The following BASIC program is BSTRF.BAS, which calls the C function
  5908. and prints out the returned string and its length:
  5909.  
  5910.    DECLARE FUNCTION CFUNC$ CDECL ()
  5911.    a$ = CFUNC$
  5912.    PRINT a$
  5913.    PRINT len(a$)
  5914.  
  5915. The following program is CSTRF.C, which builds a string descriptor
  5916. that is passed back to the calling BASIC program:
  5917.  
  5918. #include <string.h>
  5919. struct stringdesc
  5920.        {
  5921.         int length;        /* length of the string */
  5922.         char *string;      /* near pointer to the string */
  5923.        };
  5924. struct stringdesc *std;
  5925. char thestring[18];      /* In the medium memory model this  */
  5926.                          /* string will be in DGROUP - which */
  5927.                          /* is required for BASIC    */
  5928. struct stringdesc *cfunc()
  5929. {
  5930.   std->length = 18;      /* length of the string */
  5931.   strcpy(thestring, "This is the string");
  5932.   std->string = thestring;
  5933.   return(std);           /* return pointer to string descriptor */
  5934. }
  5935.  
  5936. To demonstrate these programs from an .EXE program, compile and link
  5937. as follows:
  5938.  
  5939.    BC BSTRF.BAS;
  5940.    CL /c /AM CSTRF.C;
  5941.    LINK /NOE BSTRF CSTRF;
  5942.  
  5943. BSTRF.EXE produces the following output:
  5944.  
  5945.    This is the string
  5946.    18
  5947.  
  5948. Keywords:  B_BasicCom S_C S_QuickC
  5949.  
  5950. COPYRIGHT Microsoft Corporation, 1990.
  5951. Updated  90/09/06 06:19
  5952. _____________________________________________________________________________
  5953. Q57501 QBX May Incorrectly Parse Array Element in User-Defined TYPE
  5954. Microsoft BASIC Compiler (BASICCOM)
  5955. 7.00
  5956. MS-DOS
  5957.  
  5958. Summary:
  5959.  
  5960. The QuickBASIC Extended editor (QBX.EXE), which is shipped with
  5961. Microsoft BASIC Professional Development System (PDS) version 7.00 for
  5962. MS-DOS, incorrectly parses a line of code that uses incorrect syntax
  5963. for an array element in a user-defined TYPE. The following is an
  5964. example:
  5965.  
  5966.    TYPE abc
  5967.       a(1 to 10) AS STRING * 8
  5968.    END TYPE
  5969.    DIM y AS abc
  5970.    PRINT y.a$(3)
  5971.  
  5972. When you enter the last line into QBX.EXE and press the ENTER key,
  5973. the line is interpreted (parsed) incorrectly and is displayed
  5974. incorrectly as follows:
  5975.  
  5976.    3yGOTO
  5977.  
  5978. If the correct line of code "PRINT y.a(3)" is entered, the code is
  5979. interpreted correctly.
  5980.  
  5981. Microsoft has confirmed this to be problem in the QBX.EXE editor in
  5982. Microsoft BASIC PDS version 7.00. This problem was corrected in
  5983. QBX.EXE in BASIC PDS 7.10.
  5984.  
  5985. This problem relates only to QBX.EXE and does not relate to the BC.EXE
  5986. compiler in BASIC 7.00.
  5987.  
  5988. Keywords:  buglist7.00 fixlist7.10
  5989.  
  5990. COPYRIGHT Microsoft Corporation, 1990.
  5991. Updated  90/09/25 06:42
  5992. _____________________________________________________________________________
  5993. Q35825 Undocumented BC.EXE Metacommands That Affect .LST Listing
  5994. Microsoft QuickBASIC Compiler (QUICKBAS)
  5995. 4.00 4.00b 4.50
  5996. MS-DOS
  5997.  
  5998. Summary:
  5999.  
  6000. Placing the following metacommands into your source file affects the
  6001. list (.LST) file generated by the compiler:
  6002.  
  6003.    REM $List
  6004.    REM $linesize
  6005.    REM $title
  6006.    REM $subtitle
  6007.    REM $page
  6008.    REM $pagesize
  6009.  
  6010. These metacommands are correctly documented in the "Microsoft
  6011. QuickBASIC Compiler" version 1.0x manual, and are used by the
  6012. BASCOM.EXE compiler in QuickBASIC versions 1.00, 1.01, and 1.02. Note
  6013. that these metacommands do not apply to QuickBASIC versions 2.00,
  6014. 2.01, and 3.00, which do not output a source-listing .LST file.
  6015.  
  6016. The above metacommands work with the BC.EXE compiler that is provided
  6017. with Microsoft QuickBASIC versions 4.00, 4.00b, and 4.50; with
  6018. Microsoft BASIC Compiler versions 6.00 and 6.00b; and with Microsoft
  6019. BASIC Professional Development System (PDS) versions 7.00 and 7.10 for
  6020. MS-DOS and MS OS/2. However, these metacommands need to be added to
  6021. the following manuals:
  6022.  
  6023. 1. "Microsoft QuickBASIC 4.0: BASIC Language Reference," Appendix C,
  6024.    "Metacommands," for versions 4.00 and 4.00b
  6025.  
  6026. 2. "Microsoft QuickBASIC 4.5: BASIC Language Reference," Appendix C,
  6027.    "Metacommands," for version 4.50
  6028.  
  6029. 3. "Microsoft BASIC Compiler 6.0: BASIC Language Reference," Appendix C,
  6030.    "Metacommands," for versions 6.00 and 6.00b
  6031.  
  6032. 4. "Microsoft BASIC 7.0: BASIC Language Reference" (metacommands are
  6033.    listed alphabetically) for BASIC PDS versions 7.00 and 7.10.
  6034.  
  6035. More Information:
  6036.  
  6037.    REM $LIST{+ -}
  6038.  
  6039. The $LIST metacommand turns on and off portions of the source listing
  6040. generated by the compiler. The $LIST metacommand has no effect on
  6041. whether or not a source code listing is produced; it only affects what
  6042. parts of the source code are placed in the listing. A source code
  6043. listing is produced only if you request it when you start the
  6044. compiler. To turn source code listing off at any point in the program,
  6045. add the following line:
  6046.  
  6047.    REM $LIST-
  6048.  
  6049. To turn source code listing on at any point in the program, add the
  6050. following line:
  6051.  
  6052.    REM $LIST+
  6053.  
  6054. The following metacommand sets the width of the listing output. Its
  6055. default is 80 characters:
  6056.  
  6057.    REM $LINESIZE:n
  6058.  
  6059. The following is an example of how to set the list file to 132
  6060. columns:
  6061.  
  6062.    REM $LINESIZE:132
  6063.  
  6064. The following metacommand places a title on each page of the list
  6065. (.LST) file:
  6066.  
  6067.    REM $TITLE:'text'
  6068.  
  6069. The following metacommand places a subtitle on all pages except the
  6070. first:
  6071.  
  6072.    REM $SUBTITLE:'text'
  6073.  
  6074. The following metacommand forces a new page in the compiler listing
  6075. file:
  6076.  
  6077.    REM $Page
  6078.  
  6079. The following metacommand forces a new page in the compiler listing
  6080. after n minus 6 lines have been printed.
  6081.  
  6082.    REM $Pagesize:n
  6083.  
  6084. Keywords:  B_BasicCom docerr
  6085.  
  6086. COPYRIGHT Microsoft Corporation, 1990.
  6087. Updated  90/10/18 05:15
  6088. _____________________________________________________________________________
  6089. Q44236 Only One Video Page with Hercules SCREEN 0; HELP Correction
  6090. Microsoft QuickBASIC Compiler (QUICKBAS)
  6091. 4.50
  6092. MS-DOS
  6093.  
  6094. Summary:
  6095.  
  6096. Only one page (page 0) is supported in SCREEN mode 0 on a Hercules
  6097. adapter. To obtain two pages, Hercules graphics mode (SCREEN 3) should
  6098. be used.
  6099.  
  6100. The indicated documentation sources below incorrectly show two pages
  6101. (pages 0 and 1) available in SCREEN mode 0 (TEXT mode) on a Hercules
  6102. adapter. This is incorrect.
  6103.  
  6104. More Information:
  6105.  
  6106. The information covering "Hercules Adapter Screen Modes" in the
  6107. following sources incorrectly states you can have 2 pages under SCREEN
  6108. mode 0 when using a Hercules video adapter:
  6109.  
  6110. 1. The documentation error occurs in QB.EXE 4.50 QB Advisor online
  6111.    Help system under the HELP menu, SCREEN statement, Details section,
  6112.    Adapters and Displays ("HELP: SCREEN Statement Details - Adapters")
  6113.  
  6114.    This documentation error has been corrected in the Microsoft
  6115.    Advisor on-line Help system of the QBX.EXE environment supplied
  6116.    with Microsoft BASIC PDS versions 7.00 and 7.10 for MS-DOS.
  6117.  
  6118. 2. This documentation error occurs on Page 327 of the "Microsoft
  6119.    QuickBASIC 4.5: BASIC Language Reference" manual.
  6120.  
  6121.    This documentation error has been corrected in the "Microsoft BASIC
  6122.    7.0: Language Reference" manual for BASIC PDS version 7.00 and 7.10.
  6123.  
  6124. 3. This documentation error occurs in the QBX.EXE 7.00 and 7.10
  6125.    Microsoft Advisor online Help system under the HELP menu, PCOPY
  6126.    statement, Details section ("HELP: PCOPY Statement Details").
  6127.  
  6128.    This documentation error does not occur for PCOPY HELP in QB.EXE
  6129.    4.50.
  6130.  
  6131. Keywords:  SR# S890502-115 docerr B_BasicCom
  6132.  
  6133. COPYRIGHT Microsoft Corporation, 1990.
  6134. Updated  90/10/18 05:15
  6135. _____________________________________________________________________________
  6136. Q35965 Which BASIC Versions Can CALL C, FORTRAN, Pascal, MASM
  6137. Microsoft QuickBASIC Compiler (QUICKBAS)
  6138. 4.00 4.00b 4.50
  6139. MS-DOS
  6140.  
  6141. Summary:
  6142.  
  6143. Certain versions of Microsoft QuickBASIC and Microsoft BASIC Compiler
  6144. can CALL routines from certain other Microsoft languages (and pass
  6145. parameters), depending upon the product version number, as explained
  6146. below.
  6147.  
  6148. More Information:
  6149.  
  6150. Microsoft BASIC Professional Development System (PDS) version 7.10 can
  6151. be linked with Microsoft C PDS version 6.00 or QuickC version 2.50 or
  6152. 2.51.
  6153.  
  6154. The following application note, which can be requested from Microsoft
  6155. Product Support Services, is required if you wish to perform BASIC
  6156. 7.10 mixed-language programming with C 5.10, FORTRAN 5.00, or Pascal
  6157. 4.00:
  6158.  
  6159.    "How to Link BASIC PDS 7.10 with C 5.10, FORTRAN 5.00, or
  6160.     Pascal 4.00" (application note number BB0345)
  6161.  
  6162. QuickBASIC 4.50 and BASIC PDS 7.00 (but not earlier versions) can
  6163. create .OBJ modules that can be linked with .OBJ modules from
  6164. Microsoft FORTRAN version 5.00 and Microsoft QuickC version 2.01.
  6165.  
  6166. QuickBASIC versions 4.00b and 4.50, Microsoft BASIC Compiler versions
  6167. 6.00 and 6.00b for MS-DOS and MS OS/2, and Microsoft BASIC PDS version
  6168. 7.00 for MS-DOS and MS OS/2 create .OBJ modules that can be linked
  6169. with .OBJ modules from the following languages:
  6170.  
  6171. 1. Microsoft Pascal version 4.00.
  6172. 2. Microsoft FORTRAN version 4.10.
  6173. 3. Microsoft C version 5.10 and QuickC versions 1.01 and 2.00.
  6174. 4. Microsoft Macro Assembler (MASM) version 5.00 or later recommended,
  6175.    but earlier versions should also work.
  6176.  
  6177. For more information on interlanguage CALLing between Microsoft C and
  6178. BASIC, query in this Knowledge Base on the word "BAS2C".
  6179.  
  6180. For more information on interlanguage CALLing between Microsoft MASM
  6181. and BASIC, query in this Knowledge Base on the word "BAS2MASM".
  6182.  
  6183. For more information about using the CALL statement to pass parameters
  6184. from BASIC to other languages, query in this Knowledge Base on the
  6185. following words:
  6186.  
  6187.    CALL and (PASSING or PASS) and [language name]
  6188.  
  6189. QuickBASIC 4.00
  6190. ---------------
  6191.  
  6192. QuickBASIC version 4.00 creates .OBJ modules that can be linked with
  6193. .OBJ modules from the following languages (Microsoft has performed
  6194. successful interlanguage test suites for QuickBASIC version 4.00 with
  6195. these language versions):
  6196.  
  6197. 1. Microsoft C version 5.00, QuickC version 1.00.
  6198. 2. Microsoft FORTRAN version 4.00.
  6199. 3. Microsoft Pascal version 4.00.
  6200. 4. Microsoft Macro Assembler (MASM) versions 4.00 and later
  6201.    recommended, but earlier versions should also work.
  6202.  
  6203. Note that QuickBASIC version 4.00b might link with these earlier
  6204. language versions, but Microsoft cannot guarantee success because the
  6205. 4.00b test suites were performed only on the later language versions
  6206. mentioned further above in this article.
  6207.  
  6208. QuickBASIC 1.x, 2.x, 3.00
  6209. -------------------------
  6210.  
  6211. In QuickBASIC versions 1.00, 1.01, 1.02, 2.00, 2.01, and 3.00, you can
  6212. link only to .OBJ modules from Microsoft Macro Assembler (versions
  6213. 1.2x, 2.x, or later) or the given version of QuickBASIC. In other
  6214. words, QuickBASIC versions 3.00 and earlier can CALL only QuickBASIC
  6215. subprograms or assembly routines.
  6216.  
  6217. Important Information About Interlanguage CALLing
  6218. -------------------------------------------------
  6219.  
  6220. To be compatible with compiled BASIC, programs should be assembled or
  6221. compiled using the medium, large, or huge memory model, and BASIC must
  6222. be linked first (as the main module).
  6223.  
  6224. When you link compiled BASIC to other compiled BASIC modules, compiler
  6225. versions should not be mixed. For example, an .OBJ module compiled in
  6226. QuickBASIC version 4.00 should not be linked with an .OBJ module
  6227. compiled in QuickBASIC version 4.00b or 4.50 or Microsoft BASIC
  6228. Compiler version 6.00 or 6.00b or Microsoft BASIC PDS version 7.00 or
  6229. 7.10.
  6230.  
  6231. As an alternative to the CALL statement for interlanguage invocation,
  6232. you may use the SHELL statement to invoke most (non-TSR) .EXE, .COM,
  6233. or .BAT programs that you can also invoke from DOS. SHELL works
  6234. differently than CALL. SHELL invokes another copy of the DOS
  6235. COMMAND.COM command processor before running a requested executable
  6236. program.
  6237.  
  6238. Keywords:  B_BasicCom S_C H_Fortran S_PasCal H_MASM S_QuickASM S_QuickC
  6239.  
  6240. COPYRIGHT Microsoft Corporation, 1990.
  6241. Updated  90/10/23 06:15
  6242. _____________________________________________________________________________
  6243. Q65568 How to Add Other Language Compilers to PWB's Build Options
  6244. Microsoft Programmer's WorkBench (PWB)
  6245. 1.00 1.10 | 1.00 1.10
  6246. MS-DOS    | OS/2
  6247.  
  6248. Summary:
  6249.  
  6250. The Programmer's WorkBench (PWB) is an environment capable of
  6251. utilizing different compilers for mixed-language programming. When
  6252. installed during BASIC version 7.10 setup, PWB version 1.10 shows
  6253. build options for the BASIC language only. However, it is possible to
  6254. include other language compilers to utilize the full features of the
  6255. PWB utility.
  6256.  
  6257. The following information applies to the Programmer's WorkBench
  6258. version 1.10 utility supplied with Microsoft BASIC Professional
  6259. Development System (PDS) version 7.10 for MS-DOS and MS OS/2.
  6260.  
  6261. More Information:
  6262.  
  6263. Note that the 1.00 version of PWB is shipped with Microsoft C
  6264. Professional Development System (PDS) version 6.00. The steps below
  6265. should also apply to PWB version 1.00.
  6266.  
  6267. The Programmer's WorkBench (PWB.EXE) is an advanced development
  6268. environment capable of integrating several language compilers,
  6269. NMAKE.EXE, LINK.EXE, and the CodeView debugger. It offers the ability
  6270. to accomplish tasks, such as program development under protected mode
  6271. and mixed-language programming. This ability is not available in the
  6272. QuickBASIC extended development environment (QBX.EXE).
  6273.  
  6274. Two special files, PWBC.PX$ (for protected mode OS/2) and PWBC.MX$
  6275. (for DOS mode), reside on the BASIC PDS 7.10 disks and support the
  6276. option of using the C compiler in PWB. Since SETUP.EXE (in BASIC PDS
  6277. 7.10) does not copy PWBC.PX$ and PWBC.MX$ during installation, these
  6278. files must be unpacked and transferred to your machine, for example to
  6279. the \BINP subdirectory located in the \BC7 directory. (Note: The
  6280. UNPACK.EXE utility is found on disk 1 of the BASIC PDS package.) After
  6281. unpacking, the files will have the names PWBC.PXT and PWBC.MXT.
  6282.  
  6283. Next, the following command lines must be added to the TOOLS.INI file
  6284. to make the C compiler available to PWB:
  6285.  
  6286.    [pwb - .BAS .BI]
  6287.       LOAD: LogicalDrive:\[Path]\PWBC.PXT
  6288.  
  6289. For further information about installing PWBC.PXT and PWBC.MXT, see
  6290. Page 54 of the "Microsoft BASIC 7.1: Getting Started" manual.
  6291.  
  6292. If you want to program in languages other than BASIC or C [such as
  6293. Microsoft Macro Assembler (MASM), Microsoft Pascal, Microsoft FORTRAN,
  6294. or Microsoft COBOL 3.00/3.00a], the following steps will insert the
  6295. initial build options to include other languages to PWB's build
  6296. options menu. In the example below, options to include the MASM.EXE
  6297. assembler are specified. If some other language's compiler is desired,
  6298. substitute appropriate changes for that compiler, where noted in the
  6299. specified areas:
  6300.  
  6301.  1. In PWB, go to the Options menu and select Build Options.
  6302.  
  6303.  2. Choose Save Current Build Options.
  6304.  
  6305.  3. Enter a meaningful message, such as "Options to Include MASM" in
  6306.     the window's edit field (if some other language is desired, change
  6307.     MASM to the appropriate name). Select the OK button from the "Save
  6308.     Current Build Options" and "Build Options" windows.
  6309.  
  6310.  4. Open the "TOOLS.INI" file in the PWB utility and go down to the
  6311.     bottom of the file. Somewhere near the bottom should be the tag
  6312.     "[PWB-Build Options: Options to Include MASM]" (or the language
  6313.     that was specified).
  6314.  
  6315.  5. In this section, add the following NMAKE instructions:
  6316.  
  6317.        build: inference .asm.obj masm_asm_obj
  6318.        build: command masm_asm_obj "masm $<;"
  6319.  
  6320.     Note: For languages other than MASM, distinguish a variable name
  6321.     in the inference rule to be used in the commands line (such as
  6322.     masm_asm_obj has been used above) and then specify the appropriate
  6323.     compiler in the commands line within the quotation marks. The
  6324.     special filename macro specified in the quotation marks, "$<",
  6325.     applies the command to any object that has an out-of-date
  6326.     executable file.
  6327.  
  6328.  6. Press SHIFT+F8 to reinitialize the file and then close it.
  6329.  
  6330.  7. Go to the File menu and select New (it is a good idea to close any
  6331.     files that are currently open before this step).
  6332.  
  6333.  8. Go to the Options menu and select Build Options.
  6334.  
  6335.  9. Choose Initial Build Options.
  6336.  
  6337. 10. Select the "Options to Include MASM" option (it should be near the
  6338.     bottom of the list).
  6339.  
  6340. After completing these instructions, the PWB utility will now be ready
  6341. to compile assembler along with BASIC source code, provided that paths
  6342. to the necessary compilers are furnished.
  6343.  
  6344. Keywords:  s_pascal b_basiccom s_c h_masm h_fortran b_cobol
  6345.  
  6346. COPYRIGHT Microsoft Corporation, 1990.
  6347. Updated  90/10/31 18:22
  6348. _____________________________________________________________________________
  6349. Q66744 How to POKE Keystrokes Such as F3 (Last Command) into Keyboard
  6350. Microsoft QuickBASIC Compiler (QUICKBAS)
  6351. 3.00 4.00 4.00b 4.50
  6352. MS-DOS
  6353.  
  6354. Summary:
  6355.  
  6356. Instead of using CALL INTERRUPT to push keystrokes into the keyboard
  6357. buffer, the code example below POKEs a key directly into the keyboard
  6358. buffer area in memory under MS-DOS.
  6359.  
  6360. This information applies to QuickBASIC versions 3.00, 4.00, 4.00b, and
  6361. 4.50 for MS-DOS; to Microsoft BASIC Compiler versions 6.00 and 6.00b
  6362. for MS-DOS; and to Microsoft BASIC Professional Development System
  6363. (PDS) versions 7.00 and 7.10 for MS-DOS.
  6364.  
  6365. More Information:
  6366.  
  6367. In many applications, it is often useful to echo the command line to
  6368. the screen during repetitive execution of a program. This makes the
  6369. program easier to use by allowing you to avoid typing in the command
  6370. line at the completion of each instance of the program. The code
  6371. example below shows a quick way to push the F3 keystroke into the
  6372. keyboard buffer, which echoes the previously entered command line to
  6373. the screen.
  6374.  
  6375. Code Example
  6376. ------------
  6377.  
  6378. DEF SEG = 0      ' Set default segment to 0
  6379. POKE 1054,0      ' Push 0 for extended key into keyboard buffer
  6380. POKE 1055, 61    ' Push F3 key scan code into keyboard buffer
  6381. POKE 1050, 30    ' Set beginning (head) buffer position
  6382. POKE 0152, 32    ' Set ending (tail) buffer position
  6383. DEF SEG          ' Return current segment pointer to default segment
  6384.  
  6385. References
  6386. ----------
  6387.  
  6388. For more articles about reading from and writing to the keyboard
  6389. buffer, search in this Knowledge Base for the following words:
  6390.  
  6391.    interrupt and keyboard and buffer
  6392.  
  6393. The addresses for the keyboard buffer area, head, and tail (used in
  6394. the above code example) are documented in "The New Peter Norton
  6395. Programmer's Guide to the IBM PC & PS/2" by Peter Norton and Richard
  6396. Wilton, published by Microsoft Press (1988).
  6397.  
  6398. Keyboard scan codes are documented in Appendix D of "Microsoft
  6399. QuickBASIC 4.5: Programming in BASIC"; in Appendix A of "Microsoft
  6400. QuickBASIC 4.0: Language Reference" for 4.00 and 4.00b; in Appendix A
  6401. of "Microsoft BASIC Compiler 6.0: Language Reference" for 6.00 and
  6402. 6.00b; and in Appendix A of "Microsoft BASIC 7.0: Language Reference"
  6403. manual for BASIC PDS versions 7.00 and 7.10.
  6404.  
  6405. Keywords:  B_BasicCom
  6406.  
  6407. COPYRIGHT Microsoft Corporation, 1990.
  6408. Updated  90/11/09 06:23
  6409. _____________________________________________________________________________
  6410. Q48398 Using RUN with No Argument Inside SUB Should Cause Error
  6411. Microsoft QuickBASIC Compiler (QUICKBAS)
  6412. 4.00 4.00b 4.50
  6413. MS-DOS
  6414.  
  6415. Summary:
  6416.  
  6417. In the QB.EXE or QBX.EXE environment, a RUN statement with no
  6418. <filename> argument fails to give a "Subprogram Error" and may hang
  6419. under certain conditions (see Program #3 below) when invoked inside a
  6420. SUBprogram (SUB .. END SUB). This improper use of RUN correctly
  6421. produces a "Subprogram Error" when compiled with BC.EXE in QuickBASIC
  6422. versions 4.00, 4.00b, and 4.50 and in Microsoft BASIC Professional
  6423. Development System (PDS) versions 7.00 and 7.10.
  6424.  
  6425. Microsoft has confirmed this to be a problem in the QB.EXE environment
  6426. of QuickBASIC versions 4.00, 4.00b, and 4.50 for MS-DOS; in the QB.EXE
  6427. environment of Microsoft BASIC Compiler versions 6.00 and 6.00b
  6428. (buglist6.00, buglist6.00b) for MS-DOS; and in the QBX.EXE environment
  6429. of Microsoft BASIC PDS versions 7.00 and 7.10 (buglist7.00,
  6430. buglist7.10) for MS-DOS. We are researching this problem and will post
  6431. new information here as it becomes available.
  6432.  
  6433. More Information:
  6434.  
  6435. Normally, the RUN statement with no argument restarts the current
  6436. program. However, using RUN with no argument to restart a program is
  6437. allowed only in the module-level code of a program, not in a
  6438. SUBprogram or FUNCTION procedure. In a SUBprogram or FUNCTION
  6439. procedure, you must use RUN <filename>, since RUN <linenumber> and RUN
  6440. with no argument are not allowed in SUBprograms. However, you can use
  6441. RUN <filename> to have a program run itself from within a SUBprogram
  6442. or FUNCTION.
  6443.  
  6444. The appropriate use of RUN is correctly documented on Page 367 of the
  6445. "Microsoft QuickBASIC 4.0: BASIC Language Reference" manual:
  6446.  
  6447.    Because a line number in a RUN statement must refer to a line in
  6448.    the module-level code, only the RUN "filespec" form of the
  6449.    statement is allowed in a SUB or FUNCTION.
  6450.  
  6451. The above correct statement should replace the incorrect statements
  6452. described further below.
  6453.  
  6454. Documentation Error
  6455. -------------------
  6456.  
  6457. The RUN <linenumber> option is incorrectly documented on Page 317 of
  6458. the "Microsoft QuickBASIC 4.5: BASIC Language Reference" manual for
  6459. version 4.50 and on Page 303 of the "Microsoft BASIC 7.0: Language
  6460. Reference" manual for BASIC PDS versions 7.00 and 7.10. These pages
  6461. give the following incorrect statements:
  6462.  
  6463.    Therefore, a RUN statement in a SUB or FUNCTION procedure must
  6464.    point to labels at module level. If no line label is given,
  6465.    execution always starts with the first executable line of the
  6466.    main module.
  6467.  
  6468. This same documentation error occurs in the QB Advisor online Help
  6469. system for QuickBASIC 4.50 and in the Microsoft Advisor online Help
  6470. system for BASIC PDS 7.00 and 7.10 and can be found as follows from
  6471. within the QB.EXE environment or QBX.EXE environment:
  6472.  
  6473. 1. Press SHIFT+F1.
  6474.  
  6475. 2. Select Index.
  6476.  
  6477. 3. Type "R".
  6478.  
  6479. 4. Double-click the left mouse button on "RUN statement" or position
  6480.    the cursor on "RUN" and press ENTER.
  6481.  
  6482. 5. Select Details.
  6483.  
  6484. Program #1
  6485. ----------
  6486.  
  6487. Program #1 below correctly causes a "Subprogram Error" during
  6488. compilation with BC.EXE 4.00, 4.00b, and 4.50, but the QB.EXE or
  6489. QBX.EXE editor fails to give you an error message, and the RUN
  6490. executes:
  6491.  
  6492.    ' **** PROGRAM #1: Test.Bas
  6493.    ' Main level (module level):
  6494.    PRINT "Inside Main Level"
  6495.    CALL Test
  6496.    ' Subprogram level:
  6497.    SUB Test
  6498.    PRINT "Inside Test"
  6499.    RUN
  6500.    END SUB
  6501.  
  6502. Program #2
  6503. ----------
  6504.  
  6505. Program #2 below is the correct method for using RUN (with a
  6506. <filename> argument) in a SUBprogram, and it works when the program is
  6507. either compiled with BC.EXE or run in the QB.EXE or QBX.EXE editor:
  6508.  
  6509.    ' **** Program #2: Test.Bas
  6510.    ' Main level (module level):
  6511.    PRINT "Inside Main Level"
  6512.    CALL Test
  6513.    ' Subprogram level:
  6514.    SUB Test
  6515.    PRINT "Inside Test"
  6516.    RUN "Test"   ' This is legal for both QB.EXE/QBX.EXE and BC.EXE
  6517.    END SUB
  6518.  
  6519. Program #3
  6520. ----------
  6521.  
  6522. In QB.EXE or QBX.EXE, your program may hang if the RUN statement is
  6523. invoked with no parameters (or with a line number) in a non-STATIC SUB
  6524. or FUNCTION procedure, and the SUB or FUNCTION procedure uses DIM or
  6525. REDIM to dimension a dynamic array local to that procedure:
  6526.  
  6527.    'Warning!!!!! This program is going to hang your machine.
  6528.    DECLARE SUB sub1 ()
  6529.    sub1
  6530.    END
  6531.    SUB sub1
  6532.       DIM y(1)
  6533.       y(1) = 1
  6534.       PRINT y(1);
  6535.       ' Note: Invoking ERASE Y before the RUN will prevent the hang.
  6536.       ' Must then press CTRL+BREAK to stop the program, since it keeps
  6537.       ' running itself.
  6538.       RUN
  6539.    END SUB
  6540.  
  6541. You can change Program #3 to run successfully without hanging in
  6542. QB.EXE/QBX.EXE if you do one of the following:
  6543.  
  6544. 1. ERASE the local dynamic array(s) before the RUN.
  6545.  
  6546. 2. Make the SUB STATIC.
  6547.  
  6548. 3. Make the array global by dimensioning it with DIM SHARED or COMMON
  6549.    SHARED at the module level of the program.
  6550.  
  6551. 4. Pass the array as a parameter to the SUBprogram.
  6552.  
  6553. Additional reference words: B_BasicCom SR# S900919-42 SR# S890801-4
  6554.  
  6555. Keywords:  buglist4.00 buglist4.00b buglist4.50 docerr
  6556.  
  6557. COPYRIGHT Microsoft Corporation, 1990.
  6558. Updated  90/11/10 05:19
  6559. _____________________________________________________________________________
  6560. Q58733 BASIC 7.00 Can Assign an Array to an Array If in a TYPE
  6561. Microsoft BASIC Compiler (BASICCOM)
  6562. 7.00 7.10 | 7.00 7.10
  6563. MS-DOS    | OS/2
  6564.  
  6565. Summary:
  6566.  
  6567. Some languages, such as Pascal, allow you to assign one array directly
  6568. to another, which copies all the elements from one array to another.
  6569. Microsoft BASIC cannot do this, except in Microsoft BASIC Professional
  6570. Development System (PDS) versions 7.00 and 7.10 where you can now
  6571. directly assign one static array to another by defining the array in a
  6572. user-defined-TYPE variable and then assigning one variable of this
  6573. TYPE to another.
  6574.  
  6575. Using a variable of a TYPE that contains an array, you can also write
  6576. an entire array to a file using a single PUT# statement.
  6577.  
  6578. More Information:
  6579.  
  6580. Note that in Microsoft QuickBASIC versions 4.00, 4.00b, and 4.50 for
  6581. MS-DOS, in Microsoft BASIC Compiler versions 6.00 and 6.00b for MS-DOS
  6582. and MS OS/2, and in Microsoft BASIC PDS versions 7.00 and 7.10 for
  6583. MS-DOS and MS OS/2, you can directly assign variables of a
  6584. user-defined TYPE directly to one another if they are of the same
  6585. TYPE. (LSET can be used for assignment if the record variables differ
  6586. in TYPE.) The TYPEd variables are assigned in one simple statement,
  6587. and each and every element of the user-defined TYPE is automatically
  6588. copied.
  6589.  
  6590. Microsoft BASIC PDS version 7.00 for MS-DOS and MS OS/2 introduces
  6591. support for static arrays in user-defined TYPEs. In BASIC PDS 7.00 and
  6592. 7.10, you can directly assign one static array to another by defining
  6593. the array in a user-defined-TYPE variable and then assigning one
  6594. variable of this TYPE to another, as shown in Example 1.
  6595.  
  6596. You can also write a whole array at once into a disk file, as shown in
  6597. Example 2.
  6598.  
  6599. Code Example 1
  6600. --------------
  6601.  
  6602. The following program can be used in BASIC PDS 7.00 and 7.10 to
  6603. demonstrate the assignment of the contents of one static array to
  6604. another. (Note that dynamic arrays cannot be placed in user-defined
  6605. TYPEs.)
  6606.  
  6607.    TYPE rec1
  6608.      array1(20) AS INTEGER
  6609.    END TYPE
  6610.    DIM var1 AS rec1, var2 AS rec1
  6611.    CLS
  6612.    FOR i = 1 TO 20      ' Fill the array in var1:
  6613.      var1.array1(i) = i
  6614.    NEXT
  6615.      var2 = var1          ' Make the assignment.
  6616.    FOR i = 1 TO 20      ' Confirm that the array was copied to var2:
  6617.      PRINT var2.array1(i)
  6618.    NEXT
  6619.    END
  6620.  
  6621. Code Example 2
  6622. --------------
  6623.  
  6624. The following example, compiled in BASIC PDS 7.00 or 7.10, shows how
  6625. to write a whole array to disk at once, using just one PUT# statement:
  6626.  
  6627.    TYPE rec1
  6628.      array1(20) AS INTEGER
  6629.    END TYPE
  6630.    DIM var1 AS rec1, var2 AS rec1
  6631.    CLS
  6632.    FOR i = 1 TO 20      ' Fill the array in var1:
  6633.      var1.array1(i) = i
  6634.    NEXT
  6635.  
  6636.    OPEN "test.dat" FOR RANDOM AS #1
  6637.    PUT #1, , var1         ' write whole array to disk all at once.
  6638.    CLOSE
  6639.  
  6640.    OPEN "test.dat" FOR RANDOM AS #1
  6641.    GET #1, , var2      ' Reads array all at once into var2.
  6642.    FOR i = 1 TO 20     ' Print the contents of array var2:
  6643.      PRINT var2.array1(i);
  6644.    NEXT
  6645.    CLOSE
  6646.  
  6647. Keywords:  SR# S900131-59 B_QuickBas
  6648.  
  6649. COPYRIGHT Microsoft Corporation, 1990.
  6650. Updated  90/11/20 14:26
  6651. _____________________________________________________________________________
  6652. Q66455 Problems May Occur When Passing the Same Array Element Twice
  6653. Microsoft BASIC Compiler (BASICCOM)
  6654. 6.00 6.00b 7.00 7.10 | 6.00 6.00b 7.00 7.10
  6655. MS-DOS               | OS/2
  6656.  
  6657. Summary:
  6658.  
  6659. The following program may give unexpected results when the same array
  6660. element is passed twice to the subprogram. The problem results from a
  6661. form of variable aliasing, where the same memory location is
  6662. referenced by two different variables.
  6663.  
  6664. To avoid aliasing problems, never pass the same variable twice in a
  6665. given parameter list.
  6666.  
  6667. More Information:
  6668.  
  6669. Passing the same array element twice in the same parameter list can
  6670. give incorrect or unexpected results regardless of array type or
  6671. dynamic or static array allocation. The results may also vary between
  6672. compiler versions. A customer reported that the program below gave the
  6673. results that he wanted in QuickBASIC 4.00, but not in Microsoft BASIC
  6674. Professional Development System (PDS) version 7.10; Microsoft has not
  6675. confirmed this report.
  6676.  
  6677. This behavior results from the fact the BASIC often requires a far
  6678. pointer to access arrays, but parameters need to be passed as near
  6679. pointers. On a CALL, BASIC sets aside a temporary location holding the
  6680. array element and then passes a pointer to the temporary area.
  6681.  
  6682. There are two options in this sort of situation: Recode the subprogram
  6683. so that it is not necessary to pass the array element twice, or assign
  6684. one of the parameters to a temporary variable and then pass the
  6685. temporary variable.
  6686.  
  6687. References:
  6688.  
  6689. For a similar article on variable aliasing when a parameter is both
  6690. SHARED and passed as a parameter to a subprogram, query in this
  6691. Knowledge Base on the following words:
  6692.  
  6693.    DYNAMIC and ARRAY and ALIASES
  6694.  
  6695. A variable should not be passed twice in the list of arguments passed
  6696. to a procedure; otherwise, variable-aliasing problems will occur. This
  6697. restriction is documented under "The Problem of Variable Aliasing" on
  6698. Page 64 in the "Microsoft BASIC 7.0: Programmer's Guide" for BASIC PDS
  6699. versions 7.00 and 7.10, on Page 68 of the "Microsoft QuickBASIC 4.5:
  6700. Programming in BASIC" manual, and on Page 78 of the "Microsoft
  6701. QuickBASIC 4.0: Programming in BASIC: Selected Topics" manual for
  6702. QuickBASIC versions 4.00 and 4.00b.
  6703.  
  6704. Code Example
  6705. ------------
  6706.  
  6707.    DECLARE SUB MakeUpper(instring AS STRING, outstring AS STRING)
  6708.    DIM a$(15)
  6709.    a$(4)="abcdefg"
  6710.    CALL MakeUpper(a$(4), a$(4))
  6711.    PRINT a$(4)
  6712.    END
  6713.  
  6714.    SUB MakeUpper(instring AS STRING, outstring AS STRING)
  6715.      outstring = UCASE$(instring)
  6716.    END SUB
  6717.  
  6718. Keywords:  SR# S901018-67 B_QuickBAS
  6719.  
  6720. COPYRIGHT Microsoft Corporation, 1990.
  6721. Updated  90/11/20 14:26
  6722. _____________________________________________________________________________
  6723. Q47566 SHARED Dynamic Array Element Passed as Parameter Aliases to 0
  6724. Microsoft QuickBASIC Compiler (QUICKBAS)
  6725. 4.00 4.00b 4.50
  6726. MS-DOS
  6727.  
  6728. Summary:
  6729.  
  6730. If you attempt to alter an element of a SHARED or COMMON SHARED
  6731. $DYNAMIC array while inside a SUBprogram and that element has also
  6732. been passed as a parameter to the SUBprogram, the value returned in
  6733. the parameter will be the value assigned to the array element upon
  6734. exit from the SUBprogram, and will replace whatever value may have
  6735. been assigned directly to the array in the SUBprogram.
  6736.  
  6737. This behavior occurs in Microsoft QuickBASIC versions 4.00, 4.00b, and
  6738. 4.50, Microsoft BASIC Compiler 6.00 and 6.00b for MS-DOS and MS OS/2,
  6739. and Microsoft BASIC PDS 7.00 for MS-DOS and MS OS/2.
  6740.  
  6741. This is a form of variable aliasing, which is a programming practice
  6742. not recommended by Microsoft. A variable passed in an argument list to
  6743. a procedure should not also be shared by means of the SHARED statement
  6744. or the SHARED attribute (of the DIM or COMMON statement) in that
  6745. procedure's module.
  6746.  
  6747. Similarly, a variable should not be passed twice in the list of
  6748. arguments passed to a procedure, or else variable aliasing problems
  6749. occur. This information can be found under "The Problem of Variable
  6750. Aliasing" section, on Page 64 in the "Microsoft BASIC 7.0:
  6751. Programmer's Guide" for BASIC PDS versions 7.00 and 7.10, on Page 68
  6752. of the "Microsoft QuickBASIC 4.5: Programming in BASIC" manual, and on
  6753. Page 78 of "Microsoft QuickBASIC 4.0: Programming in BASIC: Selected
  6754. Topics" manual for versions 4.00 and 4.00b.
  6755.  
  6756. More Information:
  6757.  
  6758. The behavior in the first example above results from the way
  6759. QuickBASIC accesses $DYNAMIC arrays. Since access to these arrays
  6760. requires a far pointer, and all parameters use near pointers, a
  6761. temporary location is set aside for the parameter before and during
  6762. the CALL, and the value in this location is assigned to the actual
  6763. array element following the return from the CALL. Thus, whatever value
  6764. you assign to the array element inside the SUBprogram using the SHARED
  6765. array name will be replaced with the value of the parameter when the
  6766. SUBprogram ends.
  6767.  
  6768. Note that when inside the QuickBASIC environment, virtually all arrays
  6769. are treated as $DYNAMIC. It is only at compile time that $STATIC
  6770. arrays are actually made $STATIC by allocation in the data segment.
  6771. Since the QuickBASIC editor treats most arrays as $DYNAMIC, this
  6772. behavior can be observed in the editor even for arrays declared
  6773. $STATIC. Please see Pages 32-33 in the "Microsoft QuickBASIC 4.0:
  6774. BASIC Language Reference" manual for versions 4.00 and 4.00b, and
  6775. Pages 719-721 in the "Microsoft BASIC 7.0: Programmer's Guide" for
  6776. BASIC PDS Version 7.00, for a complete description of where arrays are
  6777. stored.
  6778.  
  6779. The following example demonstrates this behavior:
  6780.  
  6781. DECLARE SUB test (a!)
  6782. CLS
  6783. ' *** The DYNAMIC metacommand is not required to reproduce
  6784. '     this behavior inside the QuickBASIC environment.
  6785. '$DYNAMIC
  6786. DIM SHARED b(20)        'Step 1. b(20) initially is 0.
  6787. CALL test(b(20))
  6788. PRINT b(20)             'Step 3. PRINTs 0 -- global has been
  6789. END                     '        replaced by returned value.
  6790.  
  6791. SUB test (a!)
  6792.   b(20) = 10
  6793.   PRINT b(20)           'Step 2. PRINTs 10 -- Global value is
  6794. END SUB                 '        changed. Parameter a! is still 0.
  6795.  
  6796. Keywords:  B_BasicCom
  6797.  
  6798. COPYRIGHT Microsoft Corporation, 1990.
  6799. Updated  90/11/20 14:26
  6800. _____________________________________________________________________________
  6801. Q60140 Location of Keyboard Buffer Area in MS-DOS; BASIC PEEK, POKE
  6802. Microsoft QuickBASIC Compiler (QUICKBAS)
  6803. 4.00 4.00b 4.50
  6804. MS-DOS
  6805.  
  6806. Summary:
  6807.  
  6808. The actual location of the keyboard buffer on the IBM PC or PS/2 is
  6809. variable, but by default, the buffer is a 32-byte area located at
  6810. segment 0, offset 1054 (41E hex). Because many applications assume
  6811. that this is the default location, please be careful if you change its
  6812. address or size.
  6813.  
  6814. More Information:
  6815.  
  6816. The buffer is composed of 16 2-byte entries. It holds up to 16
  6817. keystrokes until they are read via the BIOS services through interrupt
  6818. 22 (16 hex). Because this is a circular queue buffer, two pointers
  6819. indicate the head and tail of the queue. It is usually best to
  6820. manipulate the pointers rather than the actual data.
  6821.  
  6822. This information is taken from "The New Peter Norton Programmer's
  6823. Guide To The IBM PC and PS/2" on pages 56-60, published by Microsoft
  6824. Press (1988).
  6825.  
  6826. There are other adjacent memory locations that are used in conjunction
  6827. with the keyboard buffer. The most important of these are listed
  6828. below. All of these addresses are in segment 0.
  6829.  
  6830. Offset 1050 (41A hex)
  6831. ---------------------
  6832.  
  6833. A 2-byte address that points to the current head of the BIOS keyboard
  6834. buffer at offset 1054.
  6835.  
  6836. Offset 1052 (41C hex)
  6837. ---------------------
  6838.  
  6839. A 2-byte address that points to the current tail of the BIOS keyboard
  6840. buffer at offset 1054.
  6841.  
  6842. Note: One interesting way to clear the keyboard buffer is to set the
  6843. head of the queue equal to the tail. To do this in BASIC, simply PEEK
  6844. the two bytes at 1052 and POKE them into location 1050.
  6845.  
  6846. Offset 1152 (480 hex)
  6847. ---------------------
  6848.  
  6849. A 2-byte word pointing to the start of the keyboard buffer area.
  6850.  
  6851. Offset 1154 (482 hex)
  6852. ---------------------
  6853.  
  6854. A 2-byte word pointing to the end of the keyboard buffer area.
  6855.  
  6856. Note: Be careful if you choose to change the addresses at 1152 or 1154
  6857. because many applications may not check these memory locations to
  6858. determine the keyboard buffer area. These applications will assume the
  6859. default configuration.
  6860.  
  6861. References:
  6862.  
  6863. For more articles about reading from and writing to the keyboard
  6864. buffer, search in this Knowledge Base for the following words:
  6865.  
  6866.    interrupt AND keyboard AND buffer
  6867.  
  6868. Keyboard scan codes are documented in Appendix D of "Microsoft
  6869. QuickBASIC 4.5: Programming in BASIC"; in Appendix A of "Microsoft
  6870. QuickBASIC 4.0: Language Reference" for 4.00 and 4.00b; in Appendix A
  6871. of "Microsoft BASIC Compiler 6.0: Language Reference" for 6.00 and
  6872. 6.00b; and in Appendix A of "Microsoft BASIC 7.0: Language Reference"
  6873. manual for BASIC PDS versions 7.00 and 7.10.
  6874.  
  6875. Keywords:  SR# S900326-109 b_basiccom pss
  6876.  
  6877. COPYRIGHT Microsoft Corporation, 1990.
  6878. Updated  90/11/20 14:26
  6879.