home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft_Programmers_Library.7z / MPL / basic / b71strt.txt < prev    next >
Encoding:
Text File  |  2013-11-08  |  159.5 KB  |  4,474 lines

  1.  BASIC Version 7.1 Getting Started
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  ────────────────────────────────────────────────────────────────────────────
  11.  
  12.                     BASIC Version 7.1 Getting Started
  13.  
  14.  ────────────────────────────────────────────────────────────────────────────
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  Microsoft Corporation   For IBM Personal Computers and Compatibles
  25.  
  26.  Information in this document is subject to change without notice and
  27.  does not represent a commitment on the part of Microsoft Corporation.
  28.  The software described in this document is furnished under a license
  29.  agreement or nondisclosure agreement. The software may be used or copied
  30.  only in accordance with the terms of the agreement. It is against the
  31.  law to copy the software on any medium except as specifically allowed in
  32.  the license or nondisclosure agreement. No part of this manual may be
  33.  reproduced or transmitted in any form or by any means, electronic or
  34.  mechanical, including photocopying and recording, for any purpose
  35.  without the express written permission of Microsoft.
  36.  
  37.  Copyright 1989, 1990 Microsoft Corporation. All rights reserved.
  38.  
  39.  Simultaneously published in the U.S. and Canada.
  40.  
  41.  Printed and bound in the United States of America.
  42.  
  43.  
  44.  Microsoft, MS, MS-DOS, and CodeView are registered trademarks and
  45.  Windows is a trademark of Microsoft Corporation.
  46.  
  47.  386-Max is a trademark of Qualitas, Inc.
  48.  
  49.  AT is a registered trademark of American Telephone and Telegraph
  50.  Company.
  51.  
  52.  Btrieve is a registered trademark of SoftCraft, Inc., a Novell
  53.  Company.
  54.  
  55.  COMPAQ is a registered trademark of Compaq Computer Corporation.
  56.  
  57.  dBASE is a registered trademark of Ashton-Tate Corporation.
  58.  
  59.  IBM is a registered trademark of International Business Machines
  60.  Corporation.
  61.  
  62.  Intel is a registered trademark of Intel Corporation.
  63.  
  64.  Lotus is a registered trademark of Lotus Development Corporation.
  65.  
  66.  
  67.  
  68.  Document No. DB06823-0590
  69.  
  70.  No. D704-72
  71.  
  72.  
  73.  Guide to Keystrokes
  74.  
  75.  The following table lists the most commonly used keystrokes in the
  76.  QuickBASIC Extended (QBX), Programmer's WorkBench (PWB), and CodeView
  77.  environments. Unless stated otherwise, each keystroke has the same
  78.  function in all three environments.
  79.  
  80.  
  81.  Introduction
  82.  ────────────────────────────────────────────────────────────────────────────
  83.  
  84.  Welcome to Microsoft BASIC version 7.1 Professional Development
  85.  System. Microsoft BASIC includes the tools and files you'll need to
  86.  create and debug large, sophisticated BASIC programs that run under the
  87.  DOS and OS/2 operating systems. The Microsoft BASIC package includes the
  88.  following:
  89.  
  90.  Microsoft QuickBASIC Extended (QBX) development environment
  91.  
  92.  Microsoft Programmer's WorkBench (PWB) development environment
  93.  
  94.  BASIC compiler (BC)
  95.  
  96.  Integrated Indexed Sequential Access Method (ISAM) package
  97.  
  98.  Major utilities:
  99.  
  100.    -  Microsoft Segmented-Executable Linker (LINK)
  101.    -  Microsoft Library Manager (LIB)
  102.    -  Microsoft Program-Maintenance Utility (NMAKE)
  103.    -  Run-Time Module Build Utility (BUILDRTM)
  104.    -  Microsoft Help File Creation Utility (HELPMAKE)
  105.    -  Microsoft QuickHelp
  106.  
  107.  
  108.    ■  Add-on libraries:
  109.           Date/Time, Financial, and Format
  110.    ■  Toolboxes: Matrix Math, Presentation Graphics, and User Interface
  111.  
  112.  
  113.  Microsoft CodeView debugger and other mixed-language development
  114.    tools
  115.  
  116.  Printed and online documentation
  117.  
  118.  
  119.  Distribution of Run-Time Modules
  120.  
  121.  As described in Paragraph 5 of the Microsoft License Agreement
  122.  included with this product, the following run-time modules may be
  123.  distributed under the terms and conditions listed in the agreement:
  124.  
  125.  BRT71xxx.EXE, BRT71xxx.DLL, HELVB.FON, TMSRB.FON, MSHERC.COM,
  126.  MOUSE.COM, PATCH87.EXE, FIXSHIFT.COM, PROISAM.EXE, PROISAMD.EXE,
  127.  ISAMIO.EXE, ISAMCVT.EXE, ISAMPACK.EXE, and ISAMREPR.EXE.
  128.  
  129.  These modules can only be distributed in conjunction with and as a
  130.  necessary and integrated component of your software product, in such a
  131.  manner that they enhance or supplement the core value otherwise existing
  132.  in your software product.
  133.  
  134.  The following copyright notice applies to this product for purposes
  135.  of run-time module distribution:
  136.  
  137.  Portions(C) 1982-1990 Microsoft Corporation. All rights
  138.  reserved.
  139.  
  140.  
  141.  Documentation
  142.  
  143.  Microsoft BASIC 7.1 includes a full set of printed and online
  144.  documentation.
  145.  
  146.  
  147.  Printed Documentation
  148.  
  149.   Getting Started
  150.  gets you up and running with Microsoft BASIC.
  151.  
  152.  The  Programmer's Guide
  153.  provides information about programming concepts and techniques. The
  154.  first part of the manual focuses on the features of the BASIC language,
  155.  including such topics as control-flow structures, string processing, and
  156.  error/event handling. The second part of the manual describes program
  157.  development utilities supplied with Microsoft BASIC. These chapters give
  158.  the syntax and command-line options for each utility, as well as
  159.  illustrative examples. The appendixes contain the BASIC language
  160.  definitions.
  161.  
  162.  The  BASIC Language Reference
  163.  is divided into three parts. Each part begins with summary tables
  164.  listing the functions and statements described in that part, followed by
  165.  individual reference descriptions in alphabetical order.
  166.  
  167.    ■  Part 1, "Language Reference," describes Microsoft BASIC functions,
  168.  statements, and metacommands.
  169.  
  170.    ■  Part 2, "Add-On-Library Reference," describes the functions in the
  171.  add-on libraries.
  172.  
  173.    ■  Part 3, "BASIC Toolbox Reference," describes the procedures in the
  174.  BASIC toolboxes.
  175.  
  176.  
  177.  The appendixes describe keyboard/scan codes, reserved words,
  178.  command-line tools, and error messages.
  179.  
  180.  
  181.  Online Documentation
  182.  
  183.  Microsoft BASIC puts a complete online reference database at your
  184.  fingertips with the new Microsoft Advisor online Help system. Online
  185.  Help gives you context-sensitive Help for the BASIC language, QBX,
  186.  command-line compiler options, error messages, and symbols in your
  187.  programs. See Chapter 6, "Using Online Help," for more information.
  188.  
  189.  
  190.  Document Conventions
  191.  
  192.  Microsoft documentation uses the term "OS/2" to refer to the OS/2
  193.  systems--Microsoft Operating System/2 (MS OS/2) and IBM OS/2.
  194.  Similarly, the term "DOS" refers to the
  195.  
  196.   and IBM Personal Computer DOS operating systems. The name of a
  197.  specific operating system is used when it is necessary to note features
  198.  that are unique to that system.
  199.  
  200.  This manual uses the following typographic conventions:
  201.  
  202. ╓┌───────────────────────────────────────┌───────────────────────────────────╖
  203.  Example of convention                   Description
  204.  ────────────────────────────────────────────────────────────────────────────
  205.  setup                                   Words you type appear in this
  206.                                          boldface font.
  207.  
  208.  BASIC.LIB, ADD.EXE, COPY, LINK          Uppercase (capital) letters
  209.                                          indicate filenames and
  210.  
  211.  
  212.  Example of convention                   Description
  213.  ────────────────────────────────────────────────────────────────────────────
  214. 
  215.   SUB,  IF,  LOOP,  PRINT,  TIME$        Bold uppercase letters indicate
  216.                                          language-specific keywords with
  217.  
  218.  
  219.  Bad File Mode                           This font is used for error
  220.                                          messages.
  221.  
  222.  
  223.  
  224.  
  225.  
  226. ╓┌───────────────────────────────────────┌───────────────────────────────────╖
  227.  ────────────────────────────────────────────────────────────────────────────
  228.   handles                                Italic letters indicate
  229.                                          placeholders for information you
  230.                                          supply.
  231.  
  232.  
  233.  ────────────────────────────────────────────────────────────────────────────
  234. 
  235.   disksize                               Items inside double square
  236.                                          brackets are optional.
  237.  
  238.  { WHILE
  239.  
  240.  
  241.  Ctrl key                                Initial capital letters are used
  242.                                          for the names of keys and key
  243.  .
  244.  
  245.  Alt+F1                                  A plus (+) indicates a combination
  246.                                          of keys. For example, Alt+F1
  247.  
  248.  
  249.  Down Arrow key                          The cursor movement ("arrow") keys
  250.                                          are called direction keys.
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257. ╓┌───────────────────────────────────────┌───────────────────────────────────╖
  258.  ────────────────────────────────────────────────────────────────────────────
  259.  "defined term"                          Quotation marks usually indicate a
  260.                                          new term defined in the
  261.  
  262.  
  263.  Video Graphics Array (VGA)              Acronyms are usually spelled out
  264.                                          the first time they are used.
  265.  
  266.  
  267.  
  268.  
  269.  
  270.   ────────────────────────────────────────────────────────────────────────────
  271.  
  272.  
  273.  
  274.  Chapter 1  New Features
  275.  ────────────────────────────────────────────────────────────────────────────
  276.  
  277.  Microsoft BASIC combines powerful new language features with
  278.  capacity, performance, and usability enhancements to provide a
  279.  high-productivity development system for professional BASIC programmers.
  280.  This chapter describes the new features for versions 7.0 and 7.1.
  281.  Changes for version 7.1 are indicated by the words "Version 7.1" in the
  282.  left margin.
  283.  
  284.  
  285.  New Features in Version 7.1
  286.  
  287.  Microsoft BASIC version 7.1 extends BASIC's power under OS/2,
  288.  improves its compatibility with other languages, and provides new
  289.  language features:
  290.  
  291.    ■  BASIC's Indexed Sequential Access Method (ISAM) is now fully
  292.  supported for OS/2.
  293.  
  294.    ■  The Programmer's WorkBench (PWB) provides a sophisticated development
  295.  environment for mixed-language programming under DOS or OS/2.
  296.  
  297.    ■  The CodeView debugger version 3.0 contains many improvements to
  298.  simplify the task of debugging large BASIC and mixed-language programs
  299.  under DOS or OS/2.
  300.  
  301.    ■  QuickHelp provides access to the Microsoft Advisor Help system from
  302.  the command line.
  303.  
  304.    ■  The new  REDIM PRESERVE
  305.   statement lets you change the size of an array without erasing the data
  306.  it contains.
  307.  
  308.    ■  BASIC now supports passing parameters by value within BASIC
  309.  procedures and passing arrays containing fixed length strings as
  310.  parameters.
  311.  
  312.    ■  BASIC is fully compatible with Microsoft C version 6.0.
  313.  
  314.  
  315.  The rest of this chapter discusses the features new to Microsoft
  316.  BASIC versions 7.0 and 7.1 in greater detail.
  317.  
  318.  
  319.  Language Enhancements
  320.  
  321.  Microsoft BASIC contains major language enhancements designed for
  322.  business, scientific, and general-purpose BASIC programming.
  323.  
  324.  
  325.  Integrated ISAM
  326.  
  327.  The Indexed Sequential Access Method package provides a fast and
  328.  simple method for accessing specific records in large and complex data
  329.  files. Microsoft BASIC integrates all ISAM statements and functions with
  330.  the BASIC language. BASIC ISAM includes statements for transaction
  331.  processing and for data retrieval and manipulation.
  332.  
  333.  
  334.  Version 7.1
  335.  
  336.  In version 7.1, ISAM statements and functions are supported for OS/2
  337.  as well as DOS.
  338.  
  339.  Microsoft BASIC also includes several utilities for use with ISAM
  340.  files created with BASIC:
  341.  
  342.    ■  ISAMCVT.EXE (DOS only) converts Btrieve and dBASE files for use with
  343.  ISAM.
  344.  
  345.    ■  ISAMREPR.EXE repairs corrupted ISAM databases.
  346.  
  347.    ■  ISAMPACK.EXE compacts ISAM files to save disk space.
  348.  
  349.    ■  ISAMIO.EXE converts ASCII files to ISAM format and vice versa.
  350.  
  351.  
  352.  
  353.  
  354.  For more information about ISAM, see Chapter 10, "Database
  355.  Programming with ISAM," in the  Programmer's Guide.
  356.  
  357.  
  358.  DOS File Management
  359.  
  360.  The  DIR$ and  CURDIR$ functions and the  CHDRIVE
  361.  statement make it easier to manage DOS files from BASIC programs.
  362.  
  363.   DIR$ is similar to the DOS DIR command, except that the
  364.  filenames are returned one at a time.  CURDIR$ returns the
  365.  current directory specification, and  CHDRIVE changes the current
  366.  drive.
  367.  
  368.  
  369.  Currency Data Type
  370.  
  371.  The currency data type maintains to-the-penny precision while
  372.  providing the speed of integer math for programming accounting tasks.
  373.  Its internal representation as an integer gives this type a significant
  374.  advantage in speed over the floating-point data type for operations such
  375.  as addition and subtraction. For more information about the currency
  376.  data type, see Chapter 15, "Optimizing Program Size and Speed," in the
  377.   Programmer's Guide.
  378.  
  379.  
  380.  Procedure-Level Error Handling
  381.  
  382.  Microsoft BASIC contains local error trapping and handling for
  383.  procedures, making error handling much more efficient. In previous
  384.  versions of BASIC, error-handling routines existed at the module level.
  385.  When a handler was turned on, it was active for all procedures within
  386.  the module.
  387.  
  388.  With Microsoft BASIC, you can create both module-level and
  389.  procedure-level error handlers. The same error can invoke different
  390.  error-handling routines, depending on which procedure is running. For
  391.  example, you may want to invoke different error-handling routines for
  392.   ERR code 54,  Bad File Mode, because the error has different
  393.  meanings for different file operations. For more information on error
  394.  handling, see Chapter 8, "Error Handling," in the  Programmer's Guide.
  395.  
  396.  
  397.  Static Arrays in Records
  398.  
  399.  In previous versions of BASIC, you could create user-defined data
  400.  structures that contained numeric and fixed-string data types by using
  401.  the  TYPE%  ...  END TYPE statements. Now you can use static arrays
  402.  in addition to numeric and string data types, which gives you more
  403.  flexibility in building data structures.
  404.  
  405.  
  406.  Preserve Data when Redimensioning an Array
  407.  
  408.  
  409.  Version 7.1
  410.  
  411.  By adding the  PRESERVE  option to the  REDIM statement,
  412.  you can preserve the data that exists in an array when changing its outer
  413.  boundary.  This simplifies the dynamic control of the amount of memory
  414.  consumed by an array. For details and an example, see the online Help on
  415.  the  REDIM statement .
  416.  
  417.  
  418.  Improved Parameter Passing
  419.  
  420.  
  421.  Version 7.1
  422.  
  423.  With previous versions of BASIC, you could emulate passing parameters
  424.  by value by surrounding the parameter with parentheses. Now you can use
  425.  the  BYVAL keyword in  DECLARE,  SUB, and  FUNCTION
  426.  statements for BASIC procedures. For details on passing parameters by
  427.  value, see the online Help for the  DECLARE,  SUB, and
  428.   FUNCTION statements.
  429.  
  430.  BASIC now also supports passing arrays containing fixed-length
  431.  strings as parameters. For more information, see the online Help for the
  432.   SUB and  FUNCTION statements.
  433.  
  434.  
  435.  Improved COM Support with ERDEV$ and ERDEV
  436.  
  437.  With previous versions of BASIC, if you had a device timeout error,
  438.  there was no way to find out which device timed out, or which control
  439.  line caused the timeout. With Microsoft BASIC, information about the
  440.  timeout is available through the  ERDEV$  and  ERDEV functions.
  441.   ERDEV$ indicates whether a timeout is occurring on the communications port.
  442.   ERDEV indicates the type of timeout error that occurred
  443.  (that is, CTS, DSR, or DCD control-line errors). See the  OPEN COM
  444.  statement in the  BASIC Language Reference for more information.
  445.  
  446.  
  447.  Date/Time, Financial, and Format Add-On Libraries
  448.  
  449.  With these new libraries, you can use BASIC to perform
  450.  spreadsheet-style calculations and formatting. For example, you can
  451.  compute the number of days between two dates by converting the dates
  452.  from month-day-year format to number format, and then subtracting. You
  453.  can use financial functions to calculate double-declining balance
  454.  depreciation, future value, net present value, internal rate of return,
  455.  and other common financial calculations. For more information about
  456.  Date/Time, Financial, and Format add-on libraries, see Part 2 of the
  457.   BASIC Language Reference.
  458.  
  459.  
  460.  Matrix Math Toolbox
  461.  
  462.  The new Matrix Math toolbox contains sample BASIC code for several
  463.  common matrix math operations, including addition, subtraction,
  464.  multiplication and division, matrix inversion, determinant calculation,
  465.  and solution of simultaneous equations using Gaussian elimination. For
  466.  more information about the Matrix Math toolbox, see Part 3 of the BASIC
  467.  Language Reference.
  468.  
  469.  
  470.  Presentation Graphics Toolbox
  471.  
  472.  You can use the Presentation Graphics toolbox to display charts and
  473.  graphs from your programs. The Presentation Graphics toolbox includes
  474.  procedures for pie charts, bar and column charts, line graphs, and
  475.  scatter diagrams. Figure 1.1 shows an example of a column chart created
  476.  with this toolbox.
  477.  
  478.  The toolbox also includes a set of special graphics fonts. For more
  479.  information about Presentation Graphics, see Chapter 6, "Presentation
  480.  Graphics," in the  Programmer's Guide.
  481.  
  482.  
  483.  User Interface Toolbox
  484.  
  485.  With the new user interface code samples, you can design your own
  486.  user interface using BASIC procedures. The code samples in this toolbox
  487.  give you complete control of character-based window interfaces. For
  488.  example, you could write a BASIC program with multiple windows, menu
  489.  bars, dialog boxes, and mouse interaction. For more information about
  490.  the User Interface toolbox, see Part 3 of the  BASIC Language
  491.  Reference.
  492.  
  493.  
  494.  C Version 6.0 Compatibility
  495.  
  496.  
  497.  Version 7.1
  498.  
  499.  BASIC incorporates the C version 6.0 startup code. This makes BASIC
  500.  fully compatible with the latest version of C. However, this can cause
  501.  problems for mixed-language programmers who have earlier versions of C,
  502.  FORTRAN, or Pascal. Compatible run-times for these languages are
  503.  available free from Microsoft. Contact Product Support Services for more
  504.  information.
  505.  
  506.  
  507.  Capacity and Performance Enhancements
  508.  
  509.  Microsoft BASIC eliminates many of the capacity and performance
  510.  barriers that formerly limited the size and sophistication of BASIC
  511.  applications.
  512.  
  513.  
  514.  Far String Support
  515.  
  516.  In previous versions of BASIC, all variable-length string data was
  517.  stored in near memory. This relatively small portion of memory (64K
  518.  maximum) also stores the rest of the simple variables--integers,
  519.  floating-point numbers and fixed strings, all constants, the stack, and
  520.  some run-time overhead. Even when the only variables you use are
  521.  variable-length strings, your maximum data storage is limited.
  522.  
  523.  Microsoft BASIC supports "far strings," which enable you to store
  524.  variable-length string data outside of near memory in multiple segments
  525.  of far memory. This gives you a full 64K of string storage in the module
  526.  level of the main module, plus several additional 64K blocks of storage,
  527.  depending on how you write your program. Removing variable-length
  528.  strings from near memory creates significantly more room for other
  529.  simple variables. For more information on using far strings, see Chapter
  530.  11, "Advanced String Storage," and Chapter 13, "Mixed-Language
  531.  Programming with Far Strings," in the  Programmer's Guide.
  532.  
  533.  
  534.  Overlay Support
  535.  
  536.  With overlays, you can write and run programs up to almost 16
  537.  megabytes in size when compiling and linking from the command line. In
  538.  an overlaid version of a program, specified parts of the program are
  539.  only loaded if and when they are needed. Specifying overlays can be
  540.  useful if you have compiled a program that is too large to load in
  541.  memory. For more information about overlays, see Chapter 18, "Using LINK
  542.  and LIB," in the  Programmer's Guide.
  543.  
  544.  
  545.  Improved Granularity
  546.  
  547.  The extent to which BASIC run-time routines are divided into
  548.  individually accessible pieces is called "granularity." With Microsoft
  549.  BASIC's improved granularity, you can link with the minimum amount of
  550.  library code needed to produce stand-alone programs. This gives you
  551.  smaller compiled programs, saving disk space and memory. For more
  552.  information, see
  553.  
  554.  15, "Optimizing Program Size and Speed," in the  Programmer's
  555.  Guide.
  556.  
  557.  
  558.  Optimized Code Generation
  559.  
  560.  Optimized code generation automatically makes compiled BASIC programs
  561.  smaller and faster. Also, using a new compiler switch, you can tell the
  562.  compiler to generate code for the 80286 (and later) microprocessor
  563.  family, taking advantage of that family's machine instructions. For more
  564.  information on optimized code generation, see Chapter 15, "Optimizing
  565.  Program Size and Speed," in the  Programmer's Guide.
  566.  
  567.  
  568.  Improved Alternate Math Package
  569.  
  570.  For target systems without an 80x87 math coprocessor, the alternate
  571.  math package gives programs greatly improved speed. For example, if your
  572.  application involves spreadsheet-style math without recursive
  573.  calculations, using the alternate math package may give you a noticeable
  574.  performance increase. For more information about the alternate math
  575.  package, see Chapter 15, "Optimizing Program Size and Speed," in the
  576.   Programmer's Guide.
  577.  
  578.  
  579.  Improved IEEE Math Coprocessor Emulation
  580.  
  581.  For target systems with or without a math coprocessor, an improved
  582.  coprocessor emulator gives you faster high-precision calculations.
  583.  
  584.  
  585.  Improved Code Generation
  586.  
  587.  
  588.  Version 7.1
  589.  
  590.  Relative jumps and short jumps to near targets are optimized,
  591.  resulting in smaller, faster programs. This improvement affects all
  592.  control statements.
  593.  
  594.  
  595.  Environment and Usability Enhancements
  596.  
  597.  Microsoft BASIC offers two sophisticated development environments:
  598.  Microsoft QuickBASIC Extended (QBX) and Microsoft Programmer's WorkBench
  599.  (PWB). Both provide the following advanced features:
  600.  
  601.    ■  Integrated debugging capabilities within the environment and
  602.  compatibility with CodeView version 3.0 for debugging and optimizing
  603.  executable programs at a variety of levels
  604.  
  605.    ■  Support for expanded memory specification (EMS 4.0) to create large
  606.  executable programs
  607.  
  608.    ■  Undo/Redo capabilities
  609.  
  610.    ■  Customizable menus and key assignments
  611.  
  612.    ■  Control of build options and target environment from the development
  613.  environment
  614.  
  615.    ■  A comprehensive online Help system designed for professional
  616.  programmers
  617.  
  618.  
  619.  In addition to QBX and PWB, BASIC now includes the QuickHelp
  620.  environment for viewing Microsoft Advisor online Help files.
  621.  
  622.  
  623.  The QuickBASIC Extended Environment
  624.  
  625.  Microsoft QuickBASIC Extended (QBX) is an advanced development
  626.  environment for programmers who write most or all of their code in
  627.  BASIC. It provides line-by-line syntax checking and on-demand program
  628.  execution without recompiling. QBX also provides the following key
  629.  features:
  630.  
  631.    ■  QBX automatically uses expanded memory, if present, for any parts of
  632.  your program source code that are less than 16K in size. The View SUBs
  633.  command now enables you to determine whether a program unit
  634.  (module-level code or procedure) will fit into expanded memory.
  635.  
  636.    ■  Historical Undo/Redo commands. You can use Undo to step back through
  637.  your last 20 edits.
  638.  
  639.    ■  A customizable Utility menu. You can use the Utility menu to run DOS
  640.  command-line programs or a custom editor, or for command-line compiling
  641.  and overlay linking. You can even assign each menu item a shortcut
  642.  key.
  643.  
  644.    ■  Customizable key assignments. If you prefer to use a set of editing
  645.  commands other than the QBX defaults, you can change your key file to
  646.  one of those provided, or you can create your own custom
  647.  assignments.
  648.  
  649.    ■   nPrint to multiple printers or to a file.
  650.  
  651.    ■  Debug watch window capacity doubled (from 8 to 16 expressions).
  652.  
  653.    ■  Complete control of compiler switches for compiling from the
  654.  environment.
  655.  
  656.  
  657.  For information on using QBX, see Chapter 3,"Using QuickBASIC
  658.  Extended."
  659.  
  660.  
  661.  The Programmer's WorkBench Environment
  662.  
  663.  
  664.  Version 7.1
  665.  
  666.  Microsoft Programmer's WorkBench (PWB) is an advanced development
  667.  environment for programmers who often work in languages other than BASIC
  668.  or who want to create, build, and debug their programs under OS/2. PWB
  669.  also offers the following key features:
  670.  
  671.    ■  PWB runs in real or protected modes, so you can write BASIC programs
  672.  under DOS or OS/2.
  673.  
  674.    ■  You can write programs in any Microsoft professional-level language
  675.  and mix languages, such as BASIC and C, within the environment.
  676.  
  677.    ■  The Source Browser allows you to search selected files, list
  678.  references and definitions, build a call tree and outline, and view a
  679.  list of relationships among program symbols.
  680.  
  681.    ■  You can step through compiler errors and PWB will indicate where each
  682.  error occurred in the source code.
  683.  
  684.    ■  PWB and CodeView are integrated, so you can switch from one to the
  685.  other without exiting PWB.
  686.  
  687.    ■  Comprehensive Help is available on all command-line utilities and
  688.  Microsoft languages installed on your system.
  689.  
  690.  
  691.  For information on using PWB, see Chapter 4, "Using the Programmer's
  692.  WorkBench." See the PWB online Help for detailed information on
  693.  performing tasks and customizing the environment.
  694.  
  695.  
  696.  The CodeView Debugger
  697.  
  698.  
  699.  Version 7.1
  700.  
  701.  The CodeView debugger allows you to debug programs under DOS or OS/2.
  702.  This is especially useful when you are using assembly language routines
  703.  in a BASIC program. CodeView version 3.0 offers the following new
  704.  features:
  705.  
  706.    ■  Comprehensive online Help on how to use CodeView. Help is also
  707.  available on any installed Microsoft language or utility from within
  708.  CodeView.
  709.  
  710.    ■  Automatic use of extended and expanded memory, if available.
  711.  
  712.    ■  Full integration with PWB and compatibility with programs created in
  713.  QBX.
  714.  
  715.  
  716.  For introductory information on how to debug programs using this
  717.  environment, see Chapter 5, "Using The CodeView Debugger." For detailed
  718.  information on how to perform tasks in CodeView and for information on
  719.  how CodeView evaluates BASIC expressions, see the CodeView online
  720.  Help.
  721.  
  722.  
  723.  QuickHelp
  724.  
  725.  
  726.  Version 7.1
  727.  
  728.  Microsoft QuickHelp reads Microsoft Advisor online Help files under
  729.  DOS or OS/2. This provides you with an easy way to get Help on the
  730.  command-line utilities and development environments without loading QBX,
  731.  PWB, or CodeView.
  732.  
  733.  If you are using OS/2 or Microsoft Windows, you can run QuickHelp in
  734.  one window and do your programming in another. This can be more
  735.  convenient than using Help in the programming environment, which
  736.  obscures part of the program you are working on.
  737.  
  738.  For more information on using QuickHelp, see Chapter 6, "Using
  739.  Help."
  740.  
  741.   ────────────────────────────────────────────────────────────────────────────
  742.  
  743.  
  744.  
  745.  Chapter 2  Setup
  746.  ────────────────────────────────────────────────────────────────────────────
  747.  
  748.  
  749.  System Requirements
  750.  
  751.  Microsoft BASIC requires the following minimum configuration:
  752.  
  753.    ■  An IBM Personal Computer XT or compatible running DOS version 3.0 or
  754.  later, or OS/2 version 1.1 or later.
  755.  
  756.    ■  A hard disk drive.
  757.  
  758.    ■  A 1.2M 5.25-inch floppy disk drive. (360K and 720K disk versions of
  759.  this product are available from Microsoft. Contact Product Support
  760.  Services for more information.)
  761.  
  762.    ■  640K of available memory.
  763.  
  764.  
  765.  Microsoft BASIC supports the Microsoft Mouse and any other pointing
  766.  devices fully compatible with the Microsoft Mouse.
  767.  
  768.  
  769.  Setup Overview
  770.  
  771.  Your Microsoft BASIC package includes the SETUP.EXE file on Disk 1
  772.  (Setup). You can use Setup in one of two ways:
  773.  
  774.    ■  Install all the files you need to run BASIC, including the QBX
  775.  environment, mixed-language development tools, utilities, and
  776.  libraries.
  777.  
  778.    ■  Selectively install files. Typically, these might include libraries
  779.  or tools you did not choose to install the first time you used
  780.  Setup.
  781.  
  782.  
  783.  Setup offers you a series of choices, letting you specify where to
  784.  install the files and what features and utilities you want to install.
  785.  To conserve disk space, you may choose not to use all of BASIC's
  786.  features at first. You can later run Setup to selectively install
  787.  features you decide to add.
  788.  
  789.  
  790.  Important
  791.  
  792.  You must run Setup to use Microsoft BASIC successfully. Setup
  793.  decompresses files on the distribution disks (using UNPACK.EXE), builds
  794.  libraries, and performs other operations to give you a usable BASIC
  795.  environment. You cannot run BASIC by merely copying files from the
  796.  distribution disks.
  797.  
  798.  
  799.  Running Setup
  800.  
  801.  Setup contains information and Help screens to guide you through the
  802.  setup process. The Setup Main menu points you to the various Setup
  803.  screens where you can:
  804.  
  805.    ■  Specify paths and directories for installed files.
  806.  
  807.    ■  Specify libraries and run-time modules.
  808.  
  809.    ■  Specify ISAM support.
  810.  
  811.    ■  Specify files to install (for selective installation of specific
  812.  files or parts of Microsoft BASIC).
  813.  
  814.  
  815.  To run Setup, place Disk 1 (Setup) in disk drive A:, type
  816.  a:setup
  817.  
  818.  at the system prompt, and then follow the instructions on your screen.
  819.  Before running Setup, however, you should keep the following points in
  820.  mind.
  821.  
  822.  
  823.  Time Required to Install
  824.  
  825.  Set aside an uninterrupted block of time. You can exit Setup if you
  826.  need to, but it will not retain any of the options you selected.
  827.  Installing Microsoft BASIC requires anywhere from 30 minutes to three
  828.  hours, depending on the speed of your processor, available disk space,
  829.  and the options you chose. For best performance, you should remove any
  830.  terminate-and-stay-resident (TSR) programs from memory before running
  831.  Setup.
  832.  
  833.  Setup requires less time if you start it with the /BATCH option, as
  834.  follows:
  835.  
  836.  A:SETUP /BATCH
  837.  
  838.  If you use /BATCH, Setup will operate the same way that it does
  839.  without the option, with one exception. Instead of building BASIC
  840.  run-times and libraries automatically, SETUP /BATCH creates a batch file
  841.  named BUILD.BAT. You must run this batch file from the command line to
  842.  complete the installation process.
  843.  
  844.  
  845.  Amount of Disk Space Required
  846.  
  847.  The amount of disk space required varies depending on which features
  848.  you choose to install. However, Setup determines the exact amount of
  849.  space you need before proceeding with installation. It then checks
  850.  available disk space. If you lack sufficient space, Setup prompts you to
  851.  change the number of files to install. If you do not have sufficient
  852.  disk space and you choose to continue, the installation may not be
  853.  successful.
  854.  
  855.  
  856.  Custom or Default Configuration
  857.  
  858.  The first time you install BASIC, you may not be sure which features
  859.  you want to use. If this is the case, you may want to install with the
  860.  default settings. You can always change these settings by running Setup
  861.  again. To install the default configuration, choose Install with Current
  862.  Options from the Setup Main menu, as shown in Figure 2.1, and then
  863.  follow the instructions on your screen.
  864.  
  865.  I to install default configuration.
  866.  
  867.  
  868.  Setup Will Not Install Until You Tell It To
  869.  
  870.  If you want to install only a few files or you want to change the
  871.  configuration, you can browse through the various Setup screens and
  872.  alter settings. You can spend as much time as you want; Setup takes no
  873.  action until you choose Install with Current Options from the Setup Main
  874.  menu.
  875.  
  876.  
  877.  Files Installed
  878.  
  879.  During installation, Setup places a number of .EXE, .LIB and .OBJ
  880.  files in the directories you specify, as well as documentation and
  881.  sample-code files. Note that Setup may replace existing files.
  882.  Therefore, it is a good idea to have Setup install files only to new
  883.  directories, empty directories, or directories containing software you
  884.  want to update.
  885.  
  886.  Some of the .OBJ files are stub files. Depending on how you want to
  887.  use BASIC, you might want to delete these files after installation.
  888.  Before doing so, however, you should read the section "How Setup Uses
  889.  Stub Files" later in this chapter.
  890.  
  891.  
  892.  After Running Setup
  893.  
  894.  After you install Microsoft BASIC, you may want to do the following
  895.  tasks:
  896.  
  897.    ■  Create or modify the TOOLS.INI file
  898.  
  899.    ■  Modify your environment variables
  900.  
  901.    ■  Unpack individual files from the distribution disks
  902.  
  903.  
  904.  
  905.  Creating or Modifying TOOLS.INI
  906.  
  907.  Programmer's WorkBench, CodeView, QuickHelp, and NMAKE, all included
  908.  with Microsoft BASIC, use the TOOLS.INI file for initialization
  909.  information. Setup installs a file named TOOLS.PRE that contains
  910.  preliminary settings for these applications. Setup places TOOLS.PRE in
  911.  the \BC7\BINB directory by default.
  912.  
  913.  If you don't have an existing TOOLS.INI file, you can rename
  914.  TOOLS.PRE and place it in a directory that is indicated by your INIT
  915.  environment variable.
  916.  
  917.  If you already have a TOOLS.INI file and you have not previously
  918.  installed any of these applications, you can append TOOLS.PRE to your
  919.  existing TOOLS.INI file. For example:
  920.  
  921.  C:\INIT> COPY TOOLS.INI + \BC7\BINB\TOOLS.PRE
  922.  
  923.  If you have previously installed one or more of the applications
  924.  mentioned above, you may want to selectively combine your existing
  925.  TOOLS.INI settings with the additional settings in TOOLS.PRE.
  926.  
  927.  The TOOLS.PRE file contains information about modifying the initial
  928.  settings for each of the applications. Online Help is also available
  929.  from within PWB, CodeView, and QuickHelp on the TOOLS.INI topic.
  930.  
  931.  
  932.  Modifying Your Environment Variables
  933.  
  934.  Setup creates two files that you can use to change your environment
  935.  variables:
  936.  
  937.  for DOS, and NEW-VARS.CMD for OS/2. You can run these files from the
  938.  command line, or you can append them to your AUTOEXEC.BAT file (DOS) or
  939.  your CONFIG.SYS file (OS/2).
  940.  
  941.  If you are installing for OS/2, you should also modify the LIBPATH
  942.  line in your CONFIG.SYS file to include the directory where Setup
  943.  installed BASIC's dynamic-link libraries (DLLs). By default, Setup
  944.  places these files in the \BC7\BINP directory. Since LIBPATH is not part
  945.  of the environment, NEW-VARS.CMD cannot modify it. If you change
  946.  LIBPATH, you will have to restart your system in order for it to take
  947.  effect.
  948.  
  949.  
  950.  Unpacking Individual Files
  951.  
  952.  The files provided on the Microsoft BASIC distribution disks are
  953.  compressed to conserve space. A dollar sign ($) is added to the file
  954.  extension to show that these files must be unpacked before they can be
  955.  used. The file PACKING.LST contains a table showing how the modified
  956.  file extensions correspond to the unpacked files.
  957.  
  958.  Setup automatically unpacks and installs all of the files you need to
  959.  use the configuration you specified from the Setup menus. You can unpack
  960.  individual files after Setup in order to modify your installation
  961.  without rerunning Setup, to restore a file that was deleted, or to
  962.  provide special support for mixed-language programming with Microsoft C
  963.  version 6.0.
  964.  
  965.  To unpack a file from a distribution disk, use the following
  966.  syntax:
  967.  
  968.   UNPACK  packed-filename  unpacked-filename
  969.  
  970.  For example, to unpack the PWB.HLP file, insert the disk containing
  971.  the file in drive A: and type:
  972.  
  973.   UNPACK A:PWB.HL$ PWB.HLP
  974.  
  975.  To find a particular file on the distribution disks, look at the file
  976.  PACKING.LST on Disk 1.
  977.  
  978.  
  979.  Special Instructions for Microsoft C Users
  980.  
  981.  If you have installed Microsoft C version 6.0, you should replace the
  982.  PWB executable files and language extensions provided with C with the
  983.  ones provided with this version of BASIC. BASIC includes a later version
  984.  of these files that supports the use of BASIC and C together in
  985.  mixed-language programs.
  986.  
  987.  The PWB extensions for the C language, PWBC.MXT and PWBC.PXT, are
  988.  provided with BASIC, but are not installed by Setup. You should unpack
  989.  these files individually from the BASIC distribution disks and use them
  990.  to replace the C-language extensions provided with C version 6.0.
  991.  
  992.  
  993.  How Setup Uses Stub Files
  994.  
  995.  This section explains how you can produce smaller stand-alone
  996.  programs using stub files. If you are eager to use BASIC, you can skip
  997.  this section for now and read it later.
  998.  
  999.  A "stub file" replaces a BASIC library module with a module that
  1000.  performs little or no action. Stub files typically contain a small
  1001.  amount of code.
  1002.  
  1003.  The advantage of stub files is that if you know that you will never
  1004.  use a certain feature in your program (such as support for VGA screen
  1005.  modes), you can use the stub file to eliminate code for that feature.
  1006.  The result is that your programs require less memory and disk space.
  1007.  
  1008.  Stub files can be used for BASIC programs that use the BASIC run-time
  1009.  (BRT) module and for BASIC stand-alone executable files.
  1010.  
  1011.  
  1012.  Stub Files and the BRT Module
  1013.  
  1014.  BASIC programs can use the BRT module to support common routines. The
  1015.  use of the BRT module saves disk space by eliminating the need to add
  1016.  library routines to every executable file.
  1017.  
  1018.  Setup uses stub files to build the BRT module. It uses a different
  1019.  stub file (see the following sections) for each feature you decide not
  1020.  to support.
  1021.  
  1022.  Once installation is complete, most stub files have no further effect
  1023.  on the BRT module. You can delete them unless you plan to create
  1024.  stand-alone executable files, as described in the next section.
  1025.  
  1026.  
  1027.  Stub Files and Stand-Alone Programs
  1028.  
  1029.  You can produce stand-alone programs with the BASIC compiler by using
  1030.  the /O option. The advantage of stand-alone programs is that the BRT
  1031.  module need not be present for the program to run.
  1032.  
  1033.  Do not delete stub files if you want to produce stand-alone programs
  1034.  that use the smallest amount of memory. When you create a stand-alone
  1035.  program, you can specify stub files on the LINK command line. The effect
  1036.  is to cancel or reduce support for a feature and thus reduce executable
  1037.  size.
  1038.  
  1039.  For more information on stub files, see Chapter 15, "Optimizing
  1040.  Program Size and Speed," and Chapter 18, "Using LINK and LIB," in the
  1041.   Programmer's Guide.
  1042.  
  1043.  
  1044.  Graphics Support Stub Files
  1045.  
  1046.  The following list summarizes stub files that correspond to items in
  1047.  the second Specify Libraries and Run-Time Modules screen, Screen I/O and
  1048.  Graphics Support. Setup uses a designated stub file to build the BRT
  1049.  module if the corresponding menu item is turned  off
  1050.  .
  1051.  
  1052. ╓┌──────────────┌─────────────┌──────────────┌──────────────┌────────────────╖
  1053.  To turn this        Link with        Having this
  1054.  option  off    this file           effect
  1055.  ────────────────────────────────────────────────────────────────────────────
  1056.  Full           TSCNIO sm
  1057.  
  1058.  Ctrl-Characte
  1059.  r I/O
  1060.  
  1061.  Graphic        NOGRAPH.OBJ   Removes
  1062.  Screen Mode                  support for
  1063.  Support                      all graphics
  1064.                               statements
  1065.                               and SCREEN
  1066.  
  1067.  
  1068.  CGA Graphics   NOCGA.OBJ     Removes
  1069.  Modes                         support for
  1070.  1-2                    SCREEN
  1071.  
  1072.  
  1073.  To turn this        Link with        Having this
  1074.  option  off    this file           effect
  1075.  ────────────────────────────────────────────────────────────────────────────
  1076. 
  1077.  Hercules       NOHERC.OBJ    Removes
  1078.  Graphics                     support for
  1079.  SCREEN Mode 3                SCREEN
  1080.  
  1081.  
  1082.  Olivetti       NOOGA.OBJ     Removes
  1083.  Graphics Mode                support for
  1084.  4                            SCREEN
  1085.  
  1086.  
  1087.  EGA Graphics   NOEGA.OBJ     Removes
  1088.  Modes                         support for
  1089.  7-10                   SCREEN
  1090.  
  1091.  
  1092.  VGA Graphics   NOVGA.OBJ     Removes
  1093.  Modes                        support for
  1094.  To turn this        Link with        Having this
  1095.  option  off    this file           effect
  1096.  ────────────────────────────────────────────────────────────────────────────
  1097. Modes                        support for
  1098.  11-12                  SCREEN
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  Miscellaneous Support Stub Files
  1107.  
  1108.  The following list summarizes stub files that correspond to items in
  1109.  the third Specify Libraries and Run-Time Modules screen:
  1110.  
  1111. ╓┌──────────────┌─────────────┌──────────────┌──────────────┌────────────────╖
  1112.                 To link with  Turn this      this stub      Having this
  1113.                               option  off    file           effect
  1114.  ────────────────────────────────────────────────────────────────────────────
  1115.                 To link with  Turn this      this stub      Having this
  1116.                               option  off    file           effect
  1117.  ────────────────────────────────────────────────────────────────────────────
  1118.  COM n
  1119.  
  1120.  
  1121.  LPT n
  1122.  
  1123.  
  1124.  INPUT          NOFLTIN.OBJ   Allows
  1125.  Floating-Poin                programs to
  1126.  t Values                     contain
  1127.                               INPUT
  1128.  
  1129.  
  1130.  Transcendenta  NOTRNEM m.
  1131.  
  1132.  l Math
  1133.  
  1134.  EMS Support    NOEMS.OBJ     Prevents a
  1135.  for Overlays                 program
  1136.                 To link with  Turn this      this stub      Having this
  1137.                               option  off    file           effect
  1138.  ────────────────────────────────────────────────────────────────────────────
  1139. for Overlays                 program
  1140.                               linked for
  1141.                               overlays from
  1142.                               using EMS
  1143.                               memory. The
  1144.  
  1145.  
  1146.  EVENT          NOEVENT.OBJ   Removes
  1147.  Trapping                     support for
  1148.                               EVENT
  1149.  
  1150.  
  1151.  Full-Power     NOEDIT.OBJ    Limits
  1152.  INPUT Editor                 editing when
  1153.                               a user enters
  1154.                               data in
  1155.                               response to
  1156.                               an INPUT
  1157.                 To link with  Turn this      this stub      Having this
  1158.                               option  off    file           effect
  1159.  ────────────────────────────────────────────────────────────────────────────
  1160.                              an INPUT
  1161.  
  1162.  
  1163.  Detailed       SMALLERR.OBJ  Reduces
  1164.  Error                        length of
  1165.  Messages                     run-time
  1166.                               error
  1167.                               messages.
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  Other Special Files Installed by Setup
  1175.  
  1176.  In addition to stub files, Setup may install two other special files,
  1177.  depending on the configuration chosen. Both these files correspond to
  1178.  options in the third Specify Libraries and Run-Time Modules screen. As
  1179.  with stub files, Setup builds these files directly into the BRT module,
  1180.  but unlike stub files, you must turn the corresponding menu items on
  1181.   in order to link with the files. If you want to use them in a
  1182.  stand-alone program, include them on the command line when you link the
  1183.  program.
  1184.  
  1185. ╓┌──────────────┌─────────────┌──────────────┌──────────────┌────────────────╖
  1186.                 To link       Turn this      with this      Having this
  1187.                               option  on     file           effect
  1188.  ────────────────────────────────────────────────────────────────────────────
  1189.  Math           87.LIB        Provides most
  1190.  Coprocessor                  direct
  1191.  Required                     support for
  1192.                               machines that
  1193.                               have an
  1194.                               8087-family
  1195.  
  1196.  
  1197.  Overlays in    OVLDOS21.OBJ  Required for
  1198.  DOS 2.1                      a program
  1199.                 To link       Turn this      with this      Having this
  1200.                               option  on     file           effect
  1201.  ────────────────────────────────────────────────────────────────────────────
  1202. DOS 2.1                      a program
  1203.                               with overlays
  1204.                               to work under
  1205.                               DOS 2.1.-
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  Where to Go If You Need Additional Help
  1213.  
  1214.  If you need additional help with any of the options in the Setup
  1215.  program, you can use the following table to locate information in the
  1216.  printed documentation. If you just need a quick overview of the new
  1217.  features in Microsoft BASIC, be sure to read Chapter 1, "New Features,"
  1218.  if you haven't already done so.
  1219.  
  1220. ╓┌─────────────────────────────────┌─────────────────────────────────────────╖
  1221.  For information on                See
  1222.  ────────────────────────────────────────────────────────────────────────────
  1223.  ISAM                               Programmer's Guide,
  1224.  
  1225.  Near and far strings               Programmer's Guide,
  1226.  
  1227.  Alternate and emulator math        Programmer's Guide,
  1228.  
  1229.  Overlays                           Programmer's Guide,
  1230.  
  1231.  Compiler options                   Programmer's Guide,
  1232.  
  1233.  Stub files                         Programmer's Guide,
  1234.  
  1235.  Add-on libraries                   BASIC Language Reference,
  1236.  
  1237.  Toolboxes                          BASIC Language Reference,
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.   ────────────────────────────────────────────────────────────────────────────
  1244.  
  1245.  
  1246.  Chapter 3  Using QuickBASIC Extended
  1247.  ────────────────────────────────────────────────────────────────────────────
  1248.  
  1249.  The QuickBASIC Extended (QBX) environment is a powerful tool for
  1250.  developing BASIC applications under DOS. This chapter introduces the QBX
  1251.  environment and covers the following information to get you started:
  1252.  
  1253.    ■  Starting QBX and using the default editing and command keys.
  1254.  
  1255.    ■  Creating and moving around in a program.
  1256.  
  1257.    ■  Compiling programs from within QBX.
  1258.  
  1259.    ■  Using symbol Help, watches, watchpoints, breakpoints, and CodeView
  1260.  support to locate and resolve errors in your program.
  1261.  
  1262.    ■  Adding items to the menu bar and changing the default editing and
  1263.  command key assignments.
  1264.  
  1265.    ■  Using the QBX command-line syntax.
  1266.  
  1267.  
  1268.  Running QBX
  1269.  
  1270.  To start QBX, type the following at the system prompt:
  1271.  
  1272.   QBX
  1273.  
  1274.  Figure 3.1 shows the QBX environment.
  1275.  
  1276.  
  1277.  
  1278.  All environment tasks within QBX can be accomplished by using either
  1279.  the mouse or the keyboard. The following table lists commonly used key
  1280.  combinations by category and task.
  1281.  
  1282. ╓┌─────────────┌────────────┌───────────────────────────┌────────────────────╖
  1283.  Category                   To do this                  Press
  1284.  ────────────────────────────────────────────────────────────────────────────
  1285.  Edit                       Open a program              Alt+F, O
  1286.                             Save a program              Alt+F, S
  1287.                             Select text                 Shift+direction key
  1288.                             Copy selected text          Ctrl+Ins
  1289.                             Cut selected text           Shift+Del
  1290.                             Cut a single line           Ctrl+Y
  1291.                             Paste copied or cut text    Shift+Ins
  1292.                             Search for selected text    Ctrl+/
  1293.                             Repeat last search          F3
  1294.  Debug                      Execute program             Shift+F5
  1295.                             Execute to cursor position  F7
  1296.                             Execute next statement      F8
  1297.                             Execute next procedure      F10
  1298.                             Continue execution          F5
  1299.                             Add instant watch           Shift+F9
  1300.                             Set/clear a breakpoint      F9
  1301.  View/Windows  Next window  F6
  1302.                             Previous window             Shift+F6
  1303.                             View a SUB                  F2
  1304.  Category                   To do this                  Press
  1305.  ────────────────────────────────────────────────────────────────────────────
  1306.                            View a SUB                  F2
  1307.                             View the next SUB           Shift+F2
  1308.                             Display/hide output screen  F4
  1309.  Help                       Help on a topic             F1
  1310.                             Help on using Help          Shift+F1
  1311.                             Exit Help                   Esc
  1312.                             Redisplay last Help         Alt+F1
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  Writing a Program
  1318.  
  1319.  After you start QBX, you can immediately begin writing a program. As
  1320.  you enter BASIC functions and statements, QBX interprets them and checks
  1321.  the syntax of each line. If you make a syntax error, QBX displays an
  1322.  error message dialog box and you must choose OK or press Esc to
  1323.  continue. QBX only checks for errors in syntax; to detect errors in
  1324.  logic, you must run your program. For example, type the following:
  1325.  
  1326.   Now = TIME$
  1327.  
  1328.  Press F5 to execute the program. QBX highlights  TIME$
  1329.   and displays a "Type mismatch" error. Choose OK and correct the line to
  1330.  read:
  1331.  
  1332.   Now$ = TIME$
  1333.  
  1334.  Now the program will execute without an error.
  1335.  
  1336.  QBX organizes your program by separating different procedures (SUB
  1337.  s and  FUNCTION
  1338.  s). When you save your program, QBX automatically adds DECLARE
  1339.   statements as needed. For example, type the following:
  1340.  
  1341.   SUB PrintTime
  1342.  
  1343.  When you press Enter, QBX creates a new procedure with SUB
  1344.  and  END SUB statements in the current window as follows:
  1345.  
  1346.  SUB PrintTime
  1347.  
  1348.  END SUB
  1349.  
  1350.  To see the organization of the program, press F2. QBX displays the
  1351.  View SUBs dialog box. This dialog box lets you move between procedures
  1352.  and the main module of your program. Press Esc to return to the
  1353.  PrintTime procedure.
  1354.  
  1355.  Add the following infinite loop between the  SUB and  END SUB
  1356.  statements:
  1357.  
  1358.   DOCLS
  1359.  LOCATE 2, 1
  1360.  PRINT "The time is: "; TIME$;
  1361.  SLEEP 1
  1362.  
  1363.  
  1364.  Now choose Split from the View menu to open another window. Display
  1365.  the main module in the top window by typing Shift+F2 (View Next SUB).
  1366.  After the last statement in the main module, type:
  1367.  
  1368.   CALL PrintTime
  1369.  Run the program by pressing F5.
  1370.  
  1371.  Press Ctrl+Break to interrupt the infinite loop and return to QBX.
  1372.  QBX highlights the last instruction executed (in this case, LOOP
  1373.  ).
  1374.  
  1375.  To save the program you just created:
  1376.  
  1377.     1.From the File menu, choose Save.
  1378.  
  1379.     2.Type the filename TIME.BAS, select Text Format, and press Enter.
  1380.  saves the file as text. Text format files can be used by PWB,
  1381.  CodeView, and other tools. Binary format files can only be used by QBX
  1382.  and the BASIC Compiler.
  1383.  
  1384.  
  1385.  Exit QBX by choosing Exit from the File menu. You can view the file
  1386.  you just saved by typing the following command from the command
  1387.  line:
  1388.  
  1389.   TYPE TIME.BAS
  1390.  
  1391.  The system displays the file as follows:
  1392.  DECLARE SUB PrintTime ()
  1393.  Now$ = TIME$
  1394.  Call PrintTime
  1395.  
  1396.  SUB PrintTime
  1397.      LOCATE 2
  1398.      PRINT "The time is: " + TIME$
  1399.      SLEEP 1
  1400.  END SUB
  1401.  
  1402.  Notice that QBX adds a  DECLARE statement and puts procedures
  1403.  after the main module in the file when it saves the file.
  1404.  
  1405.  
  1406.  Other Statements Added by QBX
  1407.  
  1408.  In addition to the  DECLARE statement, QBX automatically adds a
  1409.   DEF type statement to procedures under certain conditions.
  1410.  For example, if you start your program with a
  1411.  
  1412.  A-Z statement, QBX adds a copy of that statement to the beginning of
  1413.  each new procedure you create.
  1414.  
  1415.  If your program has existing procedures when you add a DEF type
  1416.  statement to the main (calling) module, those procedures are not changed.
  1417.  Only new procedures get the automatic  DEF type
  1418.  statements.
  1419.  
  1420.  Since the default data type in BASIC is single-precision, QBX will
  1421.  add a  DEFSNG statement to any previously existing procedures
  1422.  that did not already have a  DEF type statement.
  1423.  These statements can only be seen by saving the file as text and
  1424.  viewing it outside QBX. For this reason, it is a good idea to start
  1425.  your program with a  DEF type statement.
  1426.  
  1427.  
  1428.  Using the Immediate Window
  1429.  
  1430.  The Immediate window at the bottom of the screen in QBX is a useful
  1431.  tool for executing a few lines of BASIC code without running the
  1432.  currently loaded program. Each line that you type in the Immediate
  1433.  window is executed when you press Enter. For example:
  1434.  
  1435.  Run QBX. Press F6 to move the cursor to the Immediate window, and
  1436.  type:
  1437.  
  1438.   CLS"Today's date is: " + DATE$
  1439.  
  1440.  Each time you press Enter at the end of a line, QBX executes that
  1441.  line of code and displays the output screen. You can cut lines from your
  1442.  program and paste them into the Immediate window. You can then scroll to
  1443.  the beginning of the pasted line and execute them one at a time by
  1444.  pressing Enter after each.
  1445.  
  1446.  Lines typed in the Immediate window are not saved with your program.
  1447.  When you exit QBX, the Immediate window is cleared.
  1448.  
  1449.  
  1450.  Using Quick Libraries
  1451.  
  1452.  QBX uses special-format libraries called Quick libraries to make
  1453.  common routines available within the environment. To use a Quick
  1454.  library, you must specify it with the /L option when you start QBX. For
  1455.  example:
  1456.  
  1457.  QBX /L CHRTBEFR.QLB
  1458.  
  1459.  This command line starts QBX and loads the Presentation Graphics
  1460.  Quick library. The Presentation Graphics routines will be available to
  1461.  programs as you work in the environment.
  1462.  
  1463.  For more information on Quick libraries, see Chapter 19, "Creating
  1464.  and Using Quick Libraries," in the  Programmer's Guide.
  1465.  
  1466.  Important
  1467.  
  1468.  Quick libraries created for QuickBASIC version 4.5 or earlier must be
  1469.  recreated from the original source code, and non-BASIC routines included
  1470.  in Quick libraries may need rewriting or relinking. For programming
  1471.  considerations when writing Quick libraries and instructions on creating
  1472.  Quick libraries, see Chapter 19, "Creating and Using Quick Libraries,"
  1473.  in the  Programmer's Guide.
  1474.  
  1475.  
  1476.  Compiling a Program
  1477.  
  1478.  To compile a program from QBX, load a BASIC source file and choose
  1479.  Make EXE from the Run menu. Figure 3.2 shows the Make EXE File dialog
  1480.  box that QBX displays.
  1481.  
  1482.  
  1483.  By default, QBX uses the compiler options that cause your compiled
  1484.  program to run the way that it is interpreted within QBX. If a Quick
  1485.  library is loaded, QBX uses /O, /Ot, /Fs, /Lr, /FPi, /T, and /C:512 by
  1486.  default. If a Quick library is not loaded, QBX uses /O, /Ot, /Lr, /FPa,
  1487.  /T, and /C:512. For descriptions of the BASIC Compiler options, see
  1488.  online Help or Chapter 16, "Compiling with BC," in the
  1489.  Programmer's Guide.
  1490.  
  1491.  To change these defaults, you can select any of the displayed
  1492.  compiler options or you can type additional options in the Additional
  1493.  Options field.
  1494.  
  1495.  When you select Make EXE from the Make EXE File dialog box, QBX
  1496.  shells to DOS and runs the BASIC Compiler and LINK to build the
  1497.  executable file. If you have a Quick library loaded, QBX links your
  1498.  program with the object module library (.LIB) with the same base name as
  1499.  the loaded Quick library (.QLB).
  1500.  
  1501.  If an error occurs when compiling or linking, the build halts and the
  1502.  error is displayed; you can press any key to return to QBX.
  1503.  
  1504.  If the build is successful, you are returned to QBX.
  1505.  
  1506.  
  1507.  Debugging a Program
  1508.  
  1509.  To help locate errors in program logic, QBX provides the following
  1510.  features:
  1511.  
  1512.    ■  Symbol Help
  1513.    ■  Watches
  1514.    ■  Watchpoints
  1515.    ■  Breakpoints
  1516.    ■  CodeView support
  1517.  
  1518.  
  1519.  Symbol Help
  1520.  
  1521.  When you ask for Help on a symbol, QBX displays a schematic of where
  1522.  and how that symbol is used in your program. Figure 3.3 shows the Help
  1523.  screen that is displayed when you ask for Help on the Answer symbol in
  1524.  the BOOKLOOK.BAS program.
  1525.  
  1526.  
  1527.  
  1528.  Symbol Help is useful for resolving type mismatch errors and
  1529.  duplicate symbol names. Getting Help on a symbol makes it easy to
  1530.  determine a symbol's data type and the procedures in which it is
  1531.  used.
  1532.  
  1533.  
  1534.  Watches
  1535.  
  1536.  Watches let you observe the value of an expression as your program
  1537.  executes. This is especially helpful when your program yields unexpected
  1538.  results. Placing a watch on an expression and stepping through the
  1539.  program can help you locate where the problem is occurring.
  1540.  
  1541.  To add a watch:
  1542.  
  1543.     1.  Select the expression you want to observe.
  1544.  
  1545.     2.  From the Debug menu, choose Add Watch.
  1546.  expression's name and current value are displayed in a one-line
  1547.  window immediately below the menu bar.
  1548.  
  1549.  
  1550.  As you run your program, QBX updates the value in the Watch window
  1551.  whenever the value of the expression changes. For example, set a watch
  1552.  on N% in the following lines of code:
  1553.  
  1554.  FOR N% = 0 to 10 STEP 5
  1555.  NEXT N%
  1556.  
  1557.  Step through the procedure by pressing F8 five times. The value of N%
  1558.  displayed in the Watch window changes from 0 to 5 to 10.
  1559.  
  1560.  You can set an instant watch to view the current value of an
  1561.  expression without adding a watch. An instant watch shows only the
  1562.  current value of the expression.
  1563.  
  1564.  To set an instant watch:
  1565.  
  1566.     1.  Select the expression to view.
  1567.  
  1568.     2.  From the Debug menu, choose Instant Watch.
  1569.  The current value of the expression is displayed in a dialog box.
  1570.  
  1571.     3.  Choose Cancel to exit the dialog box without adding
  1572.  a watch or press Enter to add a watch for the expression.
  1573.  
  1574.  
  1575.  To remove a watch, choose Delete Watch from the Debug menu, then
  1576.  select the watch to remove.
  1577.  
  1578.  To remove all watches, choose Delete All Watch from the Debug
  1579.  menu.
  1580.  
  1581.  
  1582.  Watchpoints and Breakpoints
  1583.  
  1584.  "Watchpoints" are conditional statements that stop program execution
  1585.  when an expression is true (nonzero). "Breakpoints" are markers that
  1586.  stop program execution at a fixed location in the program. Watchpoints
  1587.  and breakpoints make it easier to get to a specific point in the logic
  1588.  or structure of the program while debugging.
  1589.  
  1590.  To set a watchpoint:
  1591.  
  1592.     1.  Select the expression to watch.
  1593.  
  1594.     2.  From the Debug menu, choose Watchpoint.
  1595.  When you run the program by pressing F5, QBX will halt the program and
  1596.  take you to the current statement as soon as the value of the expression
  1597.  becomes nonzero.
  1598.  
  1599.  
  1600.  
  1601.  To remove a watchpoint:
  1602.  
  1603.     1. From the Debug menu, choose Delete Watch.
  1604.  
  1605.     2. Select the watchpoint to remove and press Enter.
  1606.  
  1607.  
  1608.  
  1609.  To set a breakpoint:
  1610.  
  1611.     1. Place the cursor on a line of code where you want the program to stop
  1612.  executing.
  1613.  
  1614.     2. From the Debug menu, choose Toggle Breakpoint.
  1615.  When you run the program by pressing F5, QBX will halt the program as soon
  1616.  as it reaches line of code with the breakpoint.
  1617.  
  1618.  
  1619.  To remove a breakpoint, place the cursor on the line with the
  1620.  breakpoint and choose Toggle Breakpoint from the Debug menu.
  1621.  
  1622.  
  1623.  CodeView Support
  1624.  
  1625.  To use CodeView with programs created in QBX, you must save the
  1626.  source file in text format. CodeView cannot interpret files saved in QBX
  1627.  binary format.
  1628.  
  1629.  After saving your program, compile it specifying the CodeView option
  1630.  (/Zi or /Zd). You can then load the file into CodeView from the command
  1631.  line. For information on getting started with CodeView, see Chapter 5,
  1632.  "Using CodeView." For detailed information about the CodeView
  1633.  environment and how expressions are evaluated in CodeView, see the
  1634.  CodeView online Help.
  1635.  
  1636.  
  1637.  Customizing the Environment
  1638.  
  1639.  You can add items to the menu bar and remap key assignments within
  1640.  the QBX environment.
  1641.  
  1642.  
  1643.  Adding Items to the Menu Bar
  1644.  
  1645.  To add an item to the menu bar:
  1646.  
  1647.     1. From the Utility menu, choose Customize Menu.
  1648.  
  1649.     2. Select Add from the Customize Menu dialog box.
  1650.  
  1651.     3. Type the appropriate information in the displayed fields,
  1652.  and choose OK. For information about the field in the Customize Menu
  1653.  dialog box, press F1.
  1654.  
  1655.  
  1656.  The new item will appear on the Utility menu.
  1657.  
  1658.  
  1659.  Remapping Key Assignments
  1660.  
  1661.  The default QBX editing and command keys can be modified by loading
  1662.  one of the following files with the /K: option when you start QBX:
  1663.  
  1664. ╓┌───────────────────┌───────────────────────────────────────────────────────╖
  1665.  Load this file      To change settings to those for this editor
  1666.  ────────────────────────────────────────────────────────────────────────────
  1667.  ME.KEY              Microsoft Editor
  1668.  BRIEF.KEY           BRIEF
  1669.  EPSILON.KEY         Epsilon
  1670.  QBX.KEY             QBX
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  For example, to change the default settings to those of the Microsoft
  1676.  Editor, start QBX with the following command line:
  1677.  
  1678.   QBX /k:ME.KEY
  1679.  
  1680.  When you change the default key settings, the change is saved in
  1681.  QBX.INI and those settings become the new default.
  1682.  
  1683.  You can further customize these key assignments by using the MKKEY
  1684.  utility as follows:
  1685.  
  1686.     1.  Decode the key assignment file. For example:
  1687.  MKKEY -c ba -i QBX.KEY -o MYKEY.TXT
  1688.  
  1689.     2.  Edit the decoded file (in this case, MYKEY.TXT).
  1690.  
  1691.     3.  Encode the modified key assignment file. For example:
  1692.  MKKEY -c ab -i MYKEY.TXT -o MYKEY.KEY
  1693.  
  1694.     4.  Load the new key assignment file in QBX. For example:
  1695.  QBX /k:MYKEY.KEY
  1696.  
  1697.  
  1698.  For more information on customizing key assignments, see the online
  1699.  Help topic "Configuring Keys" from the Help table of contents in QBX.
  1700.  For more information about MKKEY, see Appendix C in the  BASIC Language
  1701.  Reference.
  1702.  
  1703.  
  1704.  Controlling the Environment
  1705.  
  1706.  You can control various aspects of the environment by using the QBX
  1707.  command-line options. The QBX command line has the following syntax:
  1708.  
  1709.  QBX  options  programname /CMD  string
  1710.  
  1711. ╓┌───────────────────────────────────────┌───────────────────────────────────╖
  1712.  Option                                  Short description
  1713.  ────────────────────────────────────────────────────────────────────────────
  1714.  /AH                                     Allows dynamic arrays of records,
  1715.                                          fixed-length strings, and
  1716.  
  1717.  
  1718.  /B                                      Displays QBX in black and white.
  1719.  
  1720.  /C:  buffersize                         For use with the  OPEN COM
  1721.                                          statement. Sets the size of the
  1722.                                          buffer
  1723.  
  1724.  Option                                  Short description
  1725.  ────────────────────────────────────────────────────────────────────────────
  1726. 
  1727.  
  1728.  /Ea                                     Allows arrays in expanded memory.
  1729.                                          Do not use /Ea with the /Es
  1730.  
  1731.  
  1732.  /E: n                                   Limits the amount of expanded
  1733.                                          memory reserved for QBX use. If
  1734.                                          /E:
  1735.  
  1736.  
  1737.  /Es                                     Shares expanded memory between QBX
  1738.                                          Quick library and
  1739.  
  1740.  
  1741.  /G                                      Sets QBX to update a CGA screen as
  1742.                                          quickly as possible.
  1743.  
  1744.  /H                                      Displays the highest resolution
  1745.  Option                                  Short description
  1746.  ────────────────────────────────────────────────────────────────────────────
  1747. /H                                      Displays the highest resolution
  1748.                                          possible on your hardware.
  1749.  
  1750.  /K: keyfile                             Specifies a user-configurable key
  1751.                                          file to be loaded into QBX.
  1752.  
  1753.  /L  libraryname                         Loads a Quick library. If
  1754.                                          libraryname
  1755.  
  1756.  
  1757.  /MBF                                    Causes the QBX conversion
  1758.                                          functions to treat IEEE-format
  1759.                                          numbers
  1760.  
  1761.  
  1762.  /Nofrills                               Makes additional memory available
  1763.                                          for program use by reducing the
  1764.  
  1765.  
  1766.  Option                                  Short description
  1767.  ────────────────────────────────────────────────────────────────────────────
  1768. 
  1769.  /NOHI                                   Allows the use of a monitor that
  1770.                                          does not support high intensity.
  1771.  
  1772.  
  1773.  /CMD  string                            Passes string to the  COMMAND$
  1774.  function.
  1775.  
  1776.  
  1777.  
  1778.  
  1779.   ────────────────────────────────────────────────────────────────────────────
  1780.  
  1781.  
  1782.  Chapter 4  Using Programmer's WorkBench
  1783.  ────────────────────────────────────────────────────────────────────────────
  1784.  
  1785.  The Programmer's WorkBench (PWB) is an advanced development
  1786.  environment that features a powerful editor and integrates the compiler,
  1787.  LINK, NMAKE, and the CodeView debugger. PWB is intended for tasks, such
  1788.  as developing under OS/2, that are not supported by QBX. Unlike QBX, PWB
  1789.  does not interpret BASIC code. This means that some features available
  1790.  in QBX, such as the Immediate window and executing a program
  1791.  line-by-line, are not available. In PWB, you must use CodeView to debug
  1792.  programs.
  1793.  
  1794.  This chapter explains how to perform the following tasks:
  1795.  
  1796.    ■  Starting PWB and using keyboard commands.
  1797.  
  1798.    ■  Loading and saving a file, setting or clearing a program list, and
  1799.  using special features (such as marks and anchors) to help you write and
  1800.  modify your programs.
  1801.  
  1802.    ■  Selecting build options and creating an executable file.
  1803.  
  1804.    ■  Preparing a file for debugging, viewing compiler errors, using the
  1805.  source browser, and invoking CodeView.
  1806.  
  1807.    ■  Changing the default settings and key assignments, creating macros,
  1808.  and reducing the time it takes PWB to load.
  1809.  
  1810.    ■  Using the PWB command-line syntax.
  1811.  
  1812.  
  1813.  Note
  1814.  
  1815.  Setup installs PWB only if you choose to install mixed-language tools
  1816.  from the Specify Files to Install menu during Setup. If you did not
  1817.  choose mixed-language tools and you wish to use PWB, you should run
  1818.  Setup again with the mixed-language tools option chosen.
  1819.  
  1820.  
  1821.  Running PWB
  1822.  
  1823.  To start PWB for the first time, type:
  1824.  
  1825.   PWB
  1826.  
  1827.  Figure 4.1 shows the PWB environment.
  1828.  
  1829.  
  1830.  
  1831.  Important
  1832.  
  1833.  PWB includes extensive online Help. If you request Help and get an
  1834.  error message indicating that no Help files were open or that they could
  1835.  not be found, check your HELPFILES environment variable. HELPFILES can
  1836.  be set by running NEW-VARS.BAT (DOS) or
  1837.  
  1838.  (OS/2) from the command line before starting PWB. HELPFILES can also
  1839.  be set from within PWB by choosing Environment from the Options menu. If
  1840.  you set HELPFILES from within PWB, that setting will not have an effect
  1841.  in CodeView.
  1842.  
  1843.  Within PWB, environment tasks can be accomplished by using either the
  1844.  mouse or the keyboard. The following table lists commonly used default
  1845.  key combinations by category and task:
  1846.  
  1847. ╓┌──────────────────┌──────────────────┌──────────────────┌──────────────────╖
  1848.  Category                              To do this         Press
  1849.  ────────────────────────────────────────────────────────────────────────────
  1850.  Category                              To do this         Press
  1851.  ────────────────────────────────────────────────────────────────────────────
  1852.  Edit                                  Select text        Shift+direction
  1853.                                                           key
  1854.  
  1855.                                        Copy selected      Ctrl+Ins
  1856.                                        text
  1857.  
  1858.                                        Cut selected text  Shift+Del
  1859.  
  1860.                                        Cut a single line  Ctrl+Y
  1861.  
  1862.                                        Paste copied or    Shift+Ins
  1863.                                        cut text
  1864.  
  1865.                                        Undo previous      Alt+Backspace
  1866.                                        edit
  1867.  
  1868.                                        Redo edit          Ctrl+Backspace
  1869.  
  1870.                                        Search forward     F3
  1871.  Category                              To do this         Press
  1872.  ────────────────────────────────────────────────────────────────────────────
  1873.                                       Search forward     F3
  1874.  
  1875.                                        Search backward    F4
  1876.  
  1877.  File operations    Open a program     Alt+F, O
  1878.  
  1879.                                        Save a program     Shift+F2
  1880.  
  1881.                                        Exit (save         Alt+F4
  1882.                                        changes)
  1883.  
  1884.                                        Quit (abandon      F9, F8
  1885.                                        changes)
  1886.  
  1887.                                        Refresh (abandon   Shift+F7
  1888.                                        changes)
  1889.  
  1890.                                        Load previous      F2
  1891.                                        file
  1892.  Category                              To do this         Press
  1893.  ────────────────────────────────────────────────────────────────────────────
  1894.                                       file
  1895.  
  1896.                                        Shell to system    Shift+F9
  1897.  
  1898.  Debug/Browse       Next               Ctrl+Num+
  1899.                     definition/refere
  1900.                     nce
  1901.  
  1902.                                        Previous           Ctrl+Num-
  1903.                                        definition/refere
  1904.                                        nce
  1905.  
  1906.                                        Next build error   Shift+F3
  1907.  
  1908.                                        Previous build     Shift+F4
  1909.                                        error
  1910.  
  1911.  Windows                               Next window        F6
  1912.  
  1913.  Category                              To do this         Press
  1914.  ────────────────────────────────────────────────────────────────────────────
  1915. 
  1916.                                        Previous window    Shift+F6
  1917.  
  1918.                                        Resize a window    Ctrl+F8
  1919.  
  1920.                                        Maximize a window  Ctrl+F10
  1921.  
  1922.  Help                                  Get Help on a      F1
  1923.                                        topic
  1924.  
  1925.                                        View table of      Shift+F1
  1926.                                        contents
  1927.  
  1928.                                        Exit Help          Esc
  1929.  
  1930.  Redisplay last     Alt+F1
  1931.  Help
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  Writing a Program
  1939.  
  1940.  After you start PWB, you can immediately begin writing source code in
  1941.  the window that appears. PWB supports programming in BASIC, C, and other
  1942.  Microsoft languages. Unlike QBX, PWB does not interpret your program as
  1943.  you write it. Also unlike QBX, PWB does not check your BASIC syntax or
  1944.  automatically add  DECLARE  statements as you write your
  1945.  program. To check syntax in PWB, you must compile your program and view
  1946.  the compile results. For more information on how to do this, see the
  1947.  sections "Compiling and Linking a Program" and "Debugging a Program"
  1948.  later in this chapter.
  1949.  
  1950.  
  1951.  Loading and Saving a File
  1952.  
  1953.  To load a file in PWB, you can either type the filename on the
  1954.  command line when you start PWB or choose Open from the File menu within
  1955.  PWB.
  1956.  
  1957.  
  1958.  Note
  1959.  
  1960.  If you are planning to use PWB in combination with QBX, you must save
  1961.  your source files in text format from QBX before you try to load them in
  1962.  PWB. PWB cannot use files saved in QBX binary format.
  1963.  
  1964.  To save a file, choose Save from the File menu.
  1965.  
  1966.  PWB maintains a history of the files you have opened, which is
  1967.  displayed at the bottom of the File menu. To return to a file displayed
  1968.  in this list, choose its name from the File menu. Figure 4.2 shows the
  1969.  File menu with several files in history.
  1970.  
  1971.  
  1972.  
  1973.  When you edit a file and then exit PWB, the environment saves a list
  1974.  of the files you worked on in a special file named CURRENT.STS. PWB
  1975.  creates CURRENT.STS in the first directory indicated by your INIT
  1976.  environment variable. The next time you run PWB, it automatically opens
  1977.  the last file you worked on unless you explicitly specify a filename on
  1978.  the command line or use the /D or /DS options. For PWB command-line
  1979.  syntax and options, see the section "Controlling the Environment" later
  1980.  in this chapter.
  1981.  
  1982.  
  1983.  Navigating in a File
  1984.  
  1985.  PWB provides marks and anchors to help you navigate and edit large
  1986.  files. A "mark"
  1987.  is an invisible placeholder that you can set at a specified location in
  1988.  a file to go to that location quickly in the future. An "anchor" is a
  1989.  placeholder that determines the boundary of a block of selected text to
  1990.  cut, copy, or delete.
  1991.  
  1992.  
  1993.  Setting and Using Marks
  1994.  
  1995.  To set a mark:
  1996.  
  1997.     1. Place the cursor at the location you want to mark, then
  1998.  choose Define Mark from the Search menu.
  1999.  PWB displays the Define Mark dialog box.
  2000.  
  2001.     2. Type a name that you want to assign to the mark and press
  2002.  Enter. Note that spaces are not allowed in mark names.
  2003.  
  2004.  
  2005.  
  2006.  To go to a mark:
  2007.  
  2008.     1. From the Search menu, choose Goto Mark.
  2009.  displays the Go To Mark dialog box.
  2010.  
  2011.     2. Select the mark from the displayed list and choose OK.
  2012.  
  2013.  
  2014.  
  2015.  Creating and Using a Mark File
  2016.  
  2017.  Marks created as shown in the preceding section are temporary and are
  2018.  erased when you exit PWB. To create marks that can be reused, you must
  2019.  create a mark file or select an existing one before setting your
  2020.  marks.
  2021.  
  2022.  To create a new mark file:
  2023.  
  2024.     1. From the Search menu, choose Set Mark File.
  2025.  PWB displays the Set Mark File dialog box.
  2026.  
  2027.     2.Type the name of the mark file you wish to create and press
  2028.  Enter. (The mark file should have an .MRK file extension to help you
  2029.  identify it in the future.)
  2030.  
  2031.  PWB displays a dialog box asking if you want to create the file.
  2032.  
  2033.     3. Choose Yes.
  2034.  
  2035.  
  2036.  
  2037.  To select an existing mark file:
  2038.  
  2039.     1. From the Search menu, choose Set Mark File.
  2040.  PWB displays the Set Mark File dialog box.
  2041.  
  2042.     2. Select a mark file from the displayed list and choose OK.
  2043.  
  2044.  
  2045.  
  2046.  After you create a new mark file or select an existing one, it
  2047.  becomes the current mark file and any temporary marks are cleared. When
  2048.  you set new marks, they are added to the current mark file by
  2049.  default.
  2050.  
  2051.  
  2052.  Setting and Using Anchors
  2053.  
  2054.  Anchors help you select large blocks of text to cut, copy, or
  2055.  delete.
  2056.  
  2057.  To set an anchor, place the cursor at the position you wish to anchor
  2058.  and choose Set Anchor from the Edit menu. You can only set one anchor at
  2059.  a time; moving the cursor and choosing Set Anchor again resets the
  2060.  anchor to the new position.
  2061.  
  2062.  To select text between the current cursor position and the anchor,
  2063.  choose Select To Anchor from the Edit menu. PWB highlights the selected
  2064.  text.
  2065.  
  2066.  
  2067.  Programming with Multiple Files
  2068.  
  2069.  To work on a project containing multiple files, you must create a
  2070.  program list. A "program
  2071.  list" is a special PWB file that contains the build instructions and
  2072.  filenames for a project.
  2073.  
  2074.  To create a program list:
  2075.  
  2076.     1 From the Make menu, choose Set Program List.
  2077.  PWB displays the Set Program List dialog box.
  2078.  
  2079.     2. Type the name of the program list you wish to create and
  2080.  press Enter. (The filename should have an .MAK file extension to help you
  2081.  identify it in the future.)
  2082.  
  2083.  PWB displays a dialog box asking you if you want to create the file.
  2084.  
  2085.     3. Choose Yes.
  2086.  PWB displays the Edit Program List dialog box.
  2087.  
  2088.     4. Select the files to include in the project from the
  2089.  displayed list. Do not select BASIC include files (.BI), since they
  2090.  will be included when the program is compiled.
  2091.  
  2092.     5. Choose OK when you are done.
  2093.  
  2094.  
  2095.  
  2096.  Build options are maintained in a state file that is maintained along
  2097.  with the .MAK file. A "state file" is a file containing information
  2098.  about the PWB editing session, such as current build options and file
  2099.  history. The state file maintained with a .MAK file has the same base
  2100.  name as the .MAK file, but has a .STS filename extension. When you set a
  2101.  program list, build options revert to those last saved in the state
  2102.  file. For information on setting build options, see the section
  2103.  "Compiling and Linking a Program" later in this chapter.
  2104.  
  2105.  To use an NMAKE .MAK file in PWB, follow the procedure used to create
  2106.  a program list, but select the Use as a Non-PWB Makefile checkbox in the
  2107.  Set Program List dialog box before you press Enter in step 2.
  2108.  
  2109.  
  2110.  Note
  2111.  
  2112.  PWB .MAK files are not compatible with QBX .MAK files and vice versa.
  2113.  If you are working on a project in both environments, you should create
  2114.  a different .MAK file for each environment.
  2115.  
  2116.  
  2117.  Compiling and Linking a Program
  2118.  
  2119.  Executable files can be created directly from the PWB environment.
  2120.  Options can be saved for debug and release versions of the executable
  2121.  file. All of the environment, compiler, and LINK options are set from
  2122.  the Options menu.
  2123.  
  2124.  
  2125.  Changing Environment Variables
  2126.  
  2127.  To change environment variables from those in effect when PWB was
  2128.  run:
  2129.  
  2130.     1. From the Options menu, choose Environment.
  2131.  PWB displays the Environment Options dialog box.
  2132.  
  2133.     2. Type the new environment variables in the fields provided.
  2134.  Press Tab to move to the next option, and press Enter when you are done.
  2135.  
  2136.  
  2137.  
  2138.  The new environment variables take effect immediately and remain in
  2139.  effect until you exit PWB. To make permanent changes to environment
  2140.  variables, edit your AUTOEXEC.BAT file (DOS) or your CONFIG.SYS file
  2141.  (OS/2).
  2142.  
  2143.  
  2144.  Setting Debug or Release Version
  2145.  
  2146.  PWB maintains lists of debug and release options for compiling and
  2147.  linking a program. By default, debug options create an executable file
  2148.  for use with CodeView; release options create an optimized executable
  2149.  file without CodeView information. Setting release or debug version
  2150.  makes it easy to switch between the two sets of options quickly.
  2151.  
  2152.  To set whether the executable file will be a debug version or a
  2153.  release version:
  2154.  
  2155.     1. From the Options menu, choose Build Options.
  2156.  PWB displays the Build Options dialog box.
  2157.  
  2158.     2. Select Debug or Release from the dialog box.
  2159.  
  2160.     3. Choose OK.
  2161.  
  2162.  
  2163.  
  2164.  Debug and release version options are set from the compiler and LINK
  2165.  options dialog boxes. To change compiler and LINK options for debug or
  2166.  release versions, see "Setting Compiler Options" and "Setting LINK
  2167.  Options" later in this chapter.
  2168.  
  2169.  
  2170.  Setting Main Language and Initial Build Options
  2171.  
  2172.  Since PWB is a mixed-language programming environment, many of the
  2173.  build options that are valid in some languages are not valid in others.
  2174.  PWB provides you with a way to set a main programming language and to
  2175.  create default build options based on the target environment. When
  2176.  working with BASIC, you should always leave Main Language set to BASIC.
  2177.  When working exclusively in another language, such as C, you will want
  2178.  to change the Main Language.
  2179.  
  2180.  To change the Main Language:
  2181.  
  2182.     1. From the Options menu, choose Build Options.
  2183.  PWB displays the Build Options dialog box.
  2184.  
  2185.     2. Select Set Main Language.
  2186.  PWB displays the Set Main Language dialog box.
  2187.  
  2188.     3.Select a language from the displayed list, and choose OK.
  2189.  
  2190.     4.Select Set Initial Build Options box.
  2191.  PWB displays the Set Initial Build Options dialog box.
  2192.  
  2193.     5.Select the line from the displayed list that best describes the
  2194.  executable file you want to build, and choose OK.
  2195.  
  2196.     6.Choose OK again.
  2197.  
  2198.  
  2199.  
  2200.  Three valid initial build options are provided for BASIC. You can
  2201.  save your current build options to create a new group of initial build
  2202.  options that you can use with future projects. To create a new group of
  2203.  initial build options for BASIC:
  2204.  
  2205.     1. Set Main Language to BASIC (see the preceding procedure).
  2206.  
  2207.     2. Set the build options. These include the settings for the debug
  2208.  and release versions of compiler, LINK, and Source Browser options.
  2209.  
  2210.     3. From the Options menu, choose Build Options.
  2211.  PWB displays the Build Options dialog box.
  2212.  
  2213.     4. Select Save Current Build Options.
  2214.  PWB displays the Save Current Build Options dialog box.
  2215.  
  2216.     5. Type a name to identify your current build settings,
  2217.  and press Enter.
  2218.  
  2219.     6. Choose OK.
  2220.  
  2221.  
  2222.  PWB saves initial build options in your state file. (For more
  2223.  information on state files, see the section "Reducing Load Time" later
  2224.  in this chapter.) After initial build options are saved, they are
  2225.  available from the Set Initial Build Options dialog box.
  2226.  
  2227.  
  2228.  Setting Compiler Options
  2229.  
  2230.  To set the BASIC compiler options within PWB:
  2231.  
  2232.     1. From the Options menu, choose BASIC Compiler Options.
  2233.  PWB displays the BASIC Compiler Options dialog box.
  2234.  
  2235.     2. Select the appropriate displayed options, then select Set Debug
  2236.  Options or Set Release Options.
  2237.  
  2238.     3. Select the appropriate options from the BASIC Compiler Debug/Release
  2239.  Options dialog box, and choose OK.
  2240.  
  2241.     4. Type any additional options you wish to specify in the Additional
  2242.  Options field, and choose OK.
  2243.  
  2244.  
  2245.  
  2246.  Note
  2247.  
  2248.  It is possible to set options in the Additional Options field that
  2249.  conflict with the options specified in the BASIC Compiler Options dialog
  2250.  box. Conflicting options will cause the compile to fail.
  2251.  
  2252.  
  2253.  Setting LINK Options
  2254.  
  2255.  To set LINK options within PWB:
  2256.  
  2257.     1. From the Options menu, choose LINK Options.
  2258.  PWB displays the LINK Options dialog box.
  2259.  
  2260.     2. Select the appropriate displayed options, then select Set Debug
  2261.  Options or Set Release Options.
  2262.  
  2263.     3. Select the appropriate options from the LINK Debug/Release Options
  2264.  dialog box, and choose OK.
  2265.  
  2266.     4. Type any additional options or libraries you wish to specify in the
  2267.  Additional Libraries and Additional Options fields, and choose OK.
  2268.  
  2269.  
  2270.  Note
  2271.  
  2272.  Some LINK options, such as /INCREMENTAL and /TINY, are not valid for
  2273.  BASIC and will cause the build to fail. For a list of the valid LINK
  2274.  options and their uses, see Chapter 18, "Using LINK and LIB," in the
  2275.   Programmer's Guide.
  2276.  
  2277.  
  2278.  Building an Executable File
  2279.  
  2280.  PWB offers four choices from the Make menu for building an executable
  2281.  file. These selections allow you to:
  2282.  
  2283.    ■  Compile or compile and link a single file.
  2284.  
  2285.    ■  Compile changed files and relink with unchanged object files in a
  2286.  project.
  2287.  
  2288.    ■  Compile and link all files (changed and unchanged) in a project.
  2289.  
  2290.  
  2291.  For information on creating a project, see the section "Programming
  2292.  with Multiple Files" earlier in this chapter.
  2293.  
  2294.  
  2295.  Compiling a Single File
  2296.  
  2297.  Compiling a single file can be used as a first step in debugging a
  2298.  new program or as preparation for compiling and linking files in a
  2299.  program list.
  2300.  
  2301.  To compile a single file:
  2302.  
  2303.     1. Open the file to be compiled.
  2304.  
  2305.     2. Set the compiler options.
  2306.  
  2307.     3. From the Make menu, choose Compile File.
  2308.  PWB compiles the file. Any errors, are displayed in the Compile Results
  2309.  window.
  2310.  
  2311.     4. PWB displays a dialog box confirming that the compile has
  2312.  completed. Select one of the buttons or press Esc to return to the active
  2313.  window.
  2314.  
  2315.  
  2316.  
  2317.  Compiling and Linking a Single File
  2318.  
  2319.  To compile and link a single-file program:
  2320.  
  2321.     1. Open the file to compile and link.
  2322.  
  2323.     2. Set build, compiler, and link options as needed.
  2324.  
  2325.     3. From the Make Menu, choose Build or Rebuild All. The Build
  2326.  command recompiles the file if it has changed since it was last compiled,
  2327.  then links the file with the appropriate library to create an executable
  2328.  file. Rebuild All compiles the file whether or not it has changed, then
  2329.  links the file with the appropriate library to create an executable
  2330.  file.
  2331.  
  2332.  If the build fails, PWB displays compile or LINK errors in the Compile
  2333.  Results window.
  2334.  
  2335.     4. PWB displays a dialog box confirming that the build has completed.
  2336.  Select one of the buttons or press Esc to return to the active
  2337.  window.
  2338.  
  2339.  
  2340.  
  2341.  Compiling and Linking Files in a Project
  2342.  
  2343.  PWB gives you two options for compiling and linking the files in a
  2344.  project: you can recompile only files that have changed and link with
  2345.  unchanged object files, or compile and link all files whether or not
  2346.  they have changed.
  2347.  
  2348.  To compile and link files in a project:
  2349.  
  2350.     1. Set or create a program list for the project (see "Programming
  2351.  with Multiple Files" earlier in this chapter).
  2352.  
  2353.     2. Set build, compiler, and link options as needed.
  2354.  
  2355.     3. From the Make Menu, select Build or Rebuild All. Build compiles
  2356.  only changed files in the project and links them with existing (unchanged)
  2357.  object files. Rebuild All compiles and links all files in the project.
  2358.  
  2359.  If the build fails, PWB displays compile or LINK errors in the Compile
  2360.  Results window.
  2361.  
  2362.     4. PWB displays a dialog box confirming that the build has completed.
  2363.  Select one of the buttons or press Esc to return to the active window.
  2364.  
  2365.  
  2366.  The preceding procedure uses the same compiler options for all files
  2367.  in the program list. To build a project using different compile options
  2368.  for a single file within that project:
  2369.  
  2370.     1. From the Make menu, choose Clear Program List.
  2371.  
  2372.     2. From the File menu, choose Open to open the file to compile.
  2373.  
  2374.     3. Set the compiler options for the file.
  2375.  
  2376.     4. From the Make menu, choose Compile.
  2377.  
  2378.     5. From the Make menu, choose Set Program List and select the program
  2379.  list for the project.
  2380.  
  2381.     6. From the Make Menu, choose Build.
  2382.  PWB does not recompile the file you compiled in step 4, since it has not
  2383.  changed. It will, however, recompile any changed files using the compile
  2384.  options last set for the program list, then link the objects with the
  2385.  appropriate library to create an executable file.
  2386.  
  2387.  
  2388.  
  2389.  Debugging a Program
  2390.  
  2391.  PWB provides the following diagnostic tools to help you locate
  2392.  errors, debug, and maintain your programs:
  2393.  
  2394.    ■  Compile Results window
  2395.  
  2396.    ■  Source browser
  2397.  
  2398.    ■  CodeView support
  2399.  
  2400.  
  2401.  
  2402.  Viewing Compiler Results
  2403.  
  2404.  If errors occur when you compile or build a program, PWB displays the
  2405.  errors in the Compile Results window, as shown in Figure 4.3.
  2406.  
  2407.  
  2408.  PWB automatically takes you to the location in your source file where
  2409.  the first error occurred. To go to the next error, press Shift+F3. To
  2410.  return to the previous error, press Shift+F4.
  2411.  
  2412.  To close the Compiler Results window, choose Compile Results from the
  2413.  View menu.
  2414.  
  2415.  
  2416.  Using the Source Browser
  2417.  
  2418.  The PWB Source Browser provides a way to view relationships within a
  2419.  program and to quickly locate specific procedures, variables, and
  2420.  constants.
  2421.  
  2422.  In order to use the Source Browser, it must be turned on before
  2423.  compiling and linking. Once the Source Browser is on and the program has
  2424.  been compiled and linked, the selections on the Browse menu become
  2425.  active. The Browse menu is shown in Figure 4.4.
  2426.  
  2427.  
  2428.  Browser Terminology
  2429.  
  2430.  Since the Source Browser can be used with programs written in
  2431.  languages other than BASIC, some of the terms the Browser uses to refer
  2432.  to symbols may not be familiar. Keep in mind the following
  2433.  equivalents:
  2434.  
  2435. ╓┌───────────────────────────────┌───────────────────────────────────────────╖
  2436.  Source Browser term             BASIC equivalent
  2437.  ────────────────────────────────────────────────────────────────────────────
  2438.  Source Browser term             BASIC equivalent
  2439.  ────────────────────────────────────────────────────────────────────────────
  2440.  Functions                       Procedures ( SUB
  2441.  
  2442.  Types                           User-defined types
  2443.  Macros                          Constants
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  Turning On the Source Browser
  2449.  
  2450.  To generate information for the PWB Source Browser, you must turn on
  2451.  browse information and compile the program:
  2452.  
  2453.     1. From the Options menu, choose Browse Options.
  2454.  PWB displays the Browse Options dialog box.
  2455.  
  2456.     2. Select Generate Browse Information and any additional options.
  2457.  
  2458.     3. Choose OK.
  2459.  
  2460.     4. Compile and link the program.
  2461.  
  2462.  
  2463.  By default, PWB creates full browser information by compiling with
  2464.  the /FBx option. The /FBx option generates browser information for
  2465.  global and local definitions. To generate information for global
  2466.  definitions only, thus reducing the size of the resulting Browser files,
  2467.  you can perform the following steps before compiling and linking:
  2468.  
  2469.     1. From the Options menu, choose BASIC Compiler Options.
  2470.  PWB displays the BASIC Compiler Options dialog box.
  2471.  
  2472.     2. Select Set Debug Options or Set Debug/Release Options.
  2473.  
  2474.     3. From the Set Options dialog box, choose Restricted Browse Info /FBr,
  2475.  and choose OK.
  2476.  
  2477.     4. Choose OK again.
  2478.  
  2479.  
  2480.  When you compile and link from PWB with the Source Browser turned on,
  2481.  the BASIC compiler generates a Browser information file with an .SBR
  2482.  extension. PWB then uses PWBRMAKE.EXE to convert this file into one
  2483.  which the Browser can read. This new file has a .BSC file extension.
  2484.  
  2485.  
  2486.  Locating Program Symbols
  2487.  
  2488.  The Source Browser helps you quickly find where procedures,
  2489.  variables, user-defined types, and constants are defined and referred
  2490.  to.
  2491.  
  2492.  To locate a definition:
  2493.  
  2494.     1. From the Browse menu, choose Goto Definition.
  2495.  PWB displays the Goto Definition dialog box as shown in Figure 4.5.
  2496.  
  2497.     2. Select the item you wish to locate from the Names list box.
  2498.  PWB displays the locations where the definition occurs in the Defined in:
  2499.  list box.
  2500.  
  2501.     3. Select the occurrence of the definition you wish to go to
  2502.  from the  Defined in: list box.
  2503.  
  2504.     4. Choose OK.
  2505.  
  2506.  PWB takes you to the location in the file where the selected definition
  2507.  occurs.
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  To locate a reference:
  2513.  
  2514.     1. From the Browse menu, choose Goto Reference.
  2515.  PWB displays the Goto Reference dialog box.
  2516.  
  2517.     2. Select the item to locate from the Names list box.
  2518.  PWB displays the locations where the reference occurs in the Referenced
  2519.  in: list box.
  2520.  
  2521.     3. Select the occurrence of the reference you wish to go to
  2522.  from the  Referenced in: list box.
  2523.  
  2524.     4. Choose OK.
  2525.  PWB takes you to the location in the file where the selected reference
  2526.  occurs.
  2527.  
  2528.  
  2529.  To go to the next reference or definition of a symbol, press
  2530.  Ctrl+Keypad Plus Sign (+).
  2531.  
  2532.  To return to the previous reference or definition of a symbol, press
  2533.  Ctrl+Keypad Minus Sign (-)
  2534.  
  2535.  
  2536.  Viewing Relationships Between Symbols
  2537.  
  2538.  The Source Browser helps you view relationships between procedures,
  2539.  variables, user-defined types, and constants. These relationships
  2540.  include where a symbol is defined and used, where a procedure is called,
  2541.  what calls are made by a procedure or module, etc.
  2542.  
  2543.  To view how a single symbol relates to the rest of the program:
  2544.  
  2545.     1. From the Browse menu, choose View Relationship.
  2546.  PWB displays the View Relationship dialog box, as shown in Figure
  2547.  4.6.
  2548.  
  2549.     2. Select Program Symbols from the Operation list box.
  2550.  
  2551.     3. Select the symbol you want to view from the list box.
  2552.  
  2553.     4. Select the operation you want to perform from the Operation list
  2554.  box.
  2555.  
  2556.     5. Choose OK.
  2557.  
  2558.  
  2559.  To redisplay all the symbols, select Program Symbols from the
  2560.  Operation list box and choose OK.
  2561.  
  2562.  
  2563.  To view a listing of the different types of symbols and where they
  2564.  are used:
  2565.  
  2566.     1. From the Browse menu, choose List References.
  2567.  PWB displays the List References dialog box.
  2568.  
  2569.     2. Select the types of symbols to list.
  2570.  
  2571.     3. Choose OK.
  2572.  PWB creates a file named  containing the call tree and displays
  2573.  it in the active window, as shown in Figure 4.7.
  2574.  
  2575.  To view an outline of where procedures are called (referred to as a
  2576.  "call tree"):
  2577.  
  2578.     1. From the Browse menu, choose Call Tree.
  2579.  PWB displays the Call Tree dialog box.
  2580.  
  2581.     2. Select a file to view from the Files list box or a procedure
  2582.  to view from the Functions list box.
  2583.  
  2584.     3. Choose OK.
  2585.  PWB creates a file named  containing the listing and displays it
  2586.  in the active window, as shown in Figure 4.8.
  2587.  
  2588.  
  2589.  To view an outline of a program:
  2590.  
  2591.     1. From the Browse menu, choose Outline.
  2592.  PWB displays the Outline dialog box.
  2593.  
  2594.     2. Select the file to view from the File List list box.
  2595.  
  2596.     3. Select the type of symbols you want to include in the
  2597.  outline from the options under the Show Only label.
  2598.  
  2599.     4. Choose OK.
  2600.  PWB creates a file named  containing the outline and displays it
  2601.  in the active window, as shown in Figure 4.9.
  2602.  
  2603.  
  2604.  
  2605.  Hint
  2606.  
  2607.  By default, the  file replaces the current program file in
  2608.  the active window. You can set PWB to create a new window for the
  2609.  file by choosing Split Window from the Browse menu before
  2610.  viewing symbol relationships.
  2611.  
  2612.  
  2613.  Using CodeView
  2614.  
  2615.  To start CodeView from PWB:
  2616.  
  2617.     1. Build an executable file using the CodeView options for the
  2618.  compiler (/Zi or /Zd) and linker (/CO). These are set by default if you
  2619.  are building a debug version of the program. See the section "Setting
  2620.  Debug or Release Version" earlier in this chapter.
  2621.  
  2622.     2. From the Options menu, choose CodeView Options to set the CodeView
  2623.  command-line options.
  2624.  
  2625.     3. From the Run menu, choose Debug.
  2626.  PWB exits and loads CodeView.
  2627.  
  2628.  
  2629.  When you exit CodeView, PWB is restarted.
  2630.  
  2631.  For more information on using CodeView to debug your programs, see
  2632.  Chapter 5, "Using CodeView."
  2633.  
  2634.  
  2635.  Customizing the Environment
  2636.  
  2637.  Within PWB you can customize many features of the environment, such
  2638.  as screen colors, editor behavior, and key assignments. You can also
  2639.  define new functions as macros and assign them to keystrokes.
  2640.  
  2641.  
  2642.  Changing Editing Settings
  2643.  
  2644.  To change how the environment looks and behaves:
  2645.  
  2646.     1. From the Options menu, choose Editor Settings.
  2647.  PWB displays the current editor settings in the active window.
  2648.  
  2649.     2. Scroll down to see all of the settings. Online Help is
  2650.  available for each of the settings.
  2651.  
  2652.     3. Change the settings as appropriate. The new settings take
  2653.  effect when you move the cursor to the next line.
  2654.  
  2655.  
  2656.  To make the changes permanent, choose Save from the File menu. PWB
  2657.  saves the changes to the TOOLS.INI file. If you do not save the changes,
  2658.  they are discarded when you exit PWB.
  2659.  
  2660.  To return to the current file, press F2.
  2661.  
  2662.  
  2663.  Assigning Keystrokes
  2664.  
  2665.  To change key assignments or to assign new functions to keys:
  2666.  
  2667.     1. From the Options menu, choose Key Assignments.
  2668.  PWB displays the current key assignments in the active window.
  2669.  
  2670.     2. Scroll down to see all of the assignments. Online Help is
  2671.  available for each of the editor functions.
  2672.  
  2673.     3. Change the key assignments as appropriate. The new
  2674.  assignments take effect when you move the cursor to the next line.
  2675.  
  2676.  
  2677.  To make the changes permanent, choose Save from the File menu. PWB
  2678.  saves the changes to the TOOLS.INI file. If you do not save the changes,
  2679.  they are discarded when you exit PWB.
  2680.  
  2681.  To return to the current file, press F2.
  2682.  
  2683.  The key assignments are divided into sections for each part of PWB. A
  2684.  label at the beginning of each section indicates where the assignments
  2685.  are used. For example, the [pwb] tag indicates that the subsequent
  2686.  assignments apply to the entire PWB environment; the [pwb-pwbbasic] tag
  2687.  indicates assignments that apply only to the BASIC Compiler selection
  2688.  from the Options menu; and the [pwb-pwbhelp] tag indicates settings that
  2689.  apply to the online Help system.
  2690.  
  2691.  A table of key assignments unused by PWB is included after the
  2692.  [pwb-pwbutils] tag. These key combinations may be used for currently
  2693.  unassigned editor functions or for new functions created as macros.
  2694.  
  2695.  
  2696.  Creating Macros
  2697.  
  2698.  To record a macro:
  2699.  
  2700.     1. From the Edit menu, choose Record On.
  2701.  PWB displays the Set Macro Record dialog box.
  2702.  
  2703.     2. Type the name you want to assign to the macro in the Name field.
  2704.  
  2705.     3. Tab to the Key Assignment field and type the names of the
  2706.  keystrokes you want to assign to the macro. If you place the cursor
  2707.  between the braces, { }, and press the key sequence you want to assign
  2708.  to the macro, the correct description of the key sequence is displayed
  2709.  in the field to the right.
  2710.  
  2711.     4. Choose OK.
  2712.  
  2713.     5. Perform the actions you want to record.
  2714.  
  2715.     6. Choose Record On again to end the recording.
  2716.  
  2717.  
  2718.  To make the recorded macro permanent:
  2719.  
  2720.     1. From the Edit menu, choose Edit Macro.
  2721.  PWB displays the currently defined macros in the active window.
  2722.  
  2723.     2. From the File menu, choose Save.
  2724.  
  2725.     3. Press F2 to return to the current file.
  2726.  
  2727.  
  2728.  
  2729.  When you make a macro permanent, PWB writes the macro definition and
  2730.  key assignment to your TOOLS.INI file. To modify the macro after you
  2731.  have made it permanent, you must edit the TOOLS.INI file.
  2732.  
  2733.  Examining macro definitions in TOOLS.INI is a good way to learn the
  2734.  syntax of macros. Example macros are included in the TOOLS.PRE file
  2735.  included with BASIC. Online Help is also available on how to create and
  2736.  modify macros in PWB.
  2737.  
  2738.  
  2739.  Reducing Load Time
  2740.  
  2741.  When you start PWB, it automatically reads your TOOLS.INI file and a
  2742.  state file named CURRENT.STS from the directory defined in your INIT
  2743.  environment variable. Together, these files control the editor settings,
  2744.  macro definitions, and key assignments used by PWB. Since reading these
  2745.  files takes time, you can reduce load time by:
  2746.  
  2747.    ■  Keeping the PWB entries in TOOLS.INI as short as possible.
  2748.  
  2749.    ■  Keeping CURRENT.STS as small as possible.
  2750.  
  2751.    ■  Not reading one or both of these files when you start PWB.
  2752.  
  2753.  
  2754.  
  2755.  PWB also automatically loads any extension files it finds whose
  2756.  filenames start with the letters "PWB" in the directory from which you
  2757.  start PWB. These extension files make certain functions, such as the
  2758.  BASIC Compiler options, available in the environment. You can further
  2759.  reduce load time by disabling this auto-load feature and explicitly
  2760.  loading only the extensions you need.
  2761.  
  2762.  
  2763.  Minimizing TOOLS.INI
  2764.  
  2765.  The entries for PWB in your TOOLS.INI file appear after the [pwb]
  2766.  label in that file. TOOLS.INI can be edited and saved in the same way as
  2767.  any other file. Macros and settings that you may not use can be
  2768.  commented out by placing a semicolon (;) as the first character on the
  2769.  line. Lines that have been commented out are not read when PWB starts
  2770.  and will reduce load time slightly.
  2771.  
  2772.  
  2773.  Minimizing CURRENT.STS
  2774.  
  2775.  PWB creates the CURRENT.STS file to save file history and some editor
  2776.  settings (such as build options and file history). This file can be kept
  2777.  small by reducing the number of files you keep in history and by keeping
  2778.  the default editor settings. To reduce the number of files PWB keeps in
  2779.  history, you can reduce the number assigned to the tmpsav switch after
  2780.  the [pwb] label in the TOOLS.INI file. Reducing this number reduces the
  2781.  number of files that can be recalled from the File menu without using
  2782.  the Open File dialog box.
  2783.  
  2784.  
  2785.  Ignoring TOOLS.INI and CURRENT.STS
  2786.  
  2787.  You can prevent PWB from reading TOOLS.INI or CURRENT.STS or both
  2788.  files by using one of the /D options when you start PWB from the command
  2789.  line. The /DS option prevents CURRENT.STS from being read. The /DT
  2790.  option prevents TOOLS.INI from being read. The /DST option prevents both
  2791.  files from being read. Although these options prevent the information in
  2792.  these files from being available to PWB, they can be useful for some
  2793.  programming tasks.
  2794.  
  2795.  Starting PWB with /DS is especially useful when working with a
  2796.  program list, since PWB creates a startup file to save the editor
  2797.  settings for each program list you create. When you set a program list,
  2798.  PWB automatically reads the new editor settings from the startup file
  2799.  for the program list. This file has the same base name as your .MAK
  2800.  file, but has an .STS filename extension. For more information on PWB
  2801.  command-line options, see the section "Controlling the Environment"
  2802.  later in this chapter.
  2803.  
  2804.  
  2805.  Loading PWB Extensions Explicitly
  2806.  
  2807.  PWB does not automatically load its extensions if you include the /DA
  2808.  option when you start PWB from the command line. This significantly
  2809.  reduces the time it takes to start PWB, but also limits the features
  2810.  that are available in the environment. You can restore features by
  2811.  explicitly loading extensions through settings in the TOOLS.INI file.
  2812.  For example:
  2813.  
  2814.  [pwb - .BAS .BI]
  2815.  
  2816.  LOAD: C:\BC7\BIN\PWBBASIC.MXT;C:\BC7\BIN\PWBUTILS.MXT
  2817.  
  2818.  These lines explicitly load the BASIC and utilities PWB extensions
  2819.  when you edit a file with the .BAS or .BI filename extension. If these
  2820.  lines exist in your TOOLS.INI file and you start PWB with the following
  2821.  command line, only the BASIC functions are available:
  2822.  
  2823.  PWB /DA test.bas
  2824.  
  2825.  The following table lists the filenames of the PWB extensions and
  2826.  describes the functions they provide:
  2827.  
  2828. ╓┌───────────┌───────────┌───────────┌─┌───────────┌───────────┌─┌───────────╖
  2829.  Real-mode   Protected-  Provides
  2830.  file        mode file   support
  2831.                          for
  2832.  ────────────────────────────────────────────────────────────────────────────
  2833.  PWBBASIC.M  PWBBASIC.P  BASIC
  2834.  XT          XT          Compiler
  2835.                          functions.
  2836.  
  2837.  Real-mode   Protected-  Provides
  2838.  file        mode file   support
  2839.                          for
  2840. 
  2841.  PWBROWSE.M  PWBROWSE.P  Source
  2842.  XT          XT          Browser
  2843.                          functions.
  2844.  
  2845.  PWBC.MXT    PWBC.PXT    C Compiler    included                  disks, but
  2846.                          functions.    on the                    is not
  2847.                          This file     BASIC                     installed
  2848.                          is            distributi                by Setup.
  2849.                                        on
  2850.  
  2851.  PWBHELP.MX  PWBHELP.PX  Online
  2852.  T           T           Help
  2853.                          functions.
  2854.  
  2855.  PWBUTILS.M  PWBUTILS.P  LINK,                     build
  2856.  XT          XT          NMAKE,                    functions.
  2857.                          CodeView,
  2858.  Real-mode   Protected-  Provides
  2859.  file        mode file   support
  2860.                          for
  2861.                         CodeView,
  2862.                          and
  2863.  
  2864.  
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  Controlling the Environment
  2870.  
  2871.  The full syntax for starting PWB from the command line is as
  2872.  follows:
  2873.  
  2874.  PWB  options  programname   programname ...
  2875.  
  2876.  Unlike QBX,  programname  must include its filename extension if one
  2877.  exists. If you specify more than one  programname, the first
  2878.  name you specify is the first file PWB edits. The remaining files are
  2879.  loaded if you select choose Next from the File menu.
  2880.  
  2881. ╓┌───────────────────────────────────────┌───────────────────────────────────╖
  2882.  Option                                  Action
  2883.  ────────────────────────────────────────────────────────────────────────────
  2884.  /e  string                              Executes the PWB commands
  2885.                                          specified in  string
  2886.  
  2887.  
  2888.  /t  file                                Indicates that the specified  file
  2889.  
  2890.  
  2891.  
  2892.  /DA | S | T                             Prevents PWB initialization files
  2893.                                          from being read at startup. The
  2894.  
  2895.  
  2896.  /PF  file
  2897.  
  2898.  
  2899.  /r                                      Specifies that all files opened
  2900.  Option                                  Action
  2901.  ────────────────────────────────────────────────────────────────────────────
  2902. /r                                      Specifies that all files opened
  2903.                                          are read-only.
  2904.  
  2905.  /m  position                            Puts the cursor at the file
  2906.                                          location specified by position
  2907.  
  2908.  
  2909.  PWB /m 120.50 BOOKLOOK.BAS
  2910.  
  2911.                                          The preceding command line loads
  2912.                                          the file BOOKLOOK.BAS and places
  2913.  
  2914.  
  2915.  /?                                      Lists the command-line options for
  2916.                                          running PWB.
  2917.  
  2918.  
  2919.  
  2920.   ────────────────────────────────────────────────────────────────────────────
  2921.  
  2922.  
  2923.  
  2924.  Chapter 5  Using CodeView
  2925.  ────────────────────────────────────────────────────────────────────────────
  2926.  
  2927.  The Microsoft CodeView debugger helps you locate, identify, and
  2928.  resolve bugs in programs under DOS or OS/2. CodeView can help you debug
  2929.  programs compiled from within QBX or PWB, or from the command line.
  2930.  CodeView can be accessed directly from the Programmer's WorkBench (PWB).
  2931.  Together, PWB and CodeView provide a complete development system for
  2932.  mixed-language and OS/2 program development.
  2933.  
  2934.  This chapter describes:
  2935.  
  2936.    ■   Preparing your programs for debugging with CodeView.
  2937.  
  2938.    ■   Running CodeView.
  2939.  
  2940.    ■   Debugging a program.
  2941.  
  2942.    ■   Controlling the flow of execution while debugging.
  2943.  
  2944.    ■   Displaying and changing variables.
  2945.  
  2946.    ■   Advanced CodeView debugging techniques.
  2947.  
  2948.    ■   Customizing CodeView using the TOOLS.INI file.
  2949.  
  2950.    ■   Controlling CodeView with command-line options.
  2951.  
  2952.  
  2953.  
  2954.  Preparing BASIC Files for CodeView
  2955.  
  2956.  CodeView can debug programs created with any editor or environment.
  2957.  QBX and PWB provide CodeView options for compiling within the
  2958.  environment. With QBX, however, you must save your source file in text
  2959.  format before compiling with the CodeView option. Source files saved in
  2960.  QBX binary format are not compatible with CodeView.
  2961.  
  2962.  
  2963.  Programming Style
  2964.  
  2965.  To make it easier to debug programs in CodeView, you should avoid the
  2966.  following programming practices:
  2967.  
  2968.    ■   Using the colon (:) to place multiple BASIC statements on a single
  2969.  line.
  2970.  
  2971.    ■   CodeView can step through a program one line at a time. If more
  2972.  than one statement occurs on a line, CodeView treats the line as a
  2973.  single statement.
  2974.  
  2975.    ■   Placing executable statements in include files.
  2976.  
  2977.    ■   You cannot trace through executable statements that occur in an
  2978.  include file. Placing executable statements in include files is not a
  2979.  good programming practice.
  2980.  
  2981.    ■   Using non-unique array names.
  2982.  
  2983.    ■   Arrays should be named uniquely. If a variable has the same name
  2984.  as an array in your program, CodeView assumes that symbol is a variable,
  2985.  not an array. You will not be able to perform some operations on that
  2986.  array from the CodeView Command window.
  2987.  
  2988.  
  2989.  
  2990.  Compiling and Linking
  2991.  
  2992.  To debug a program in CodeView, you must compile the program with the
  2993.  /Zi or /Zd options and link using the /CO option. The /Zi option makes
  2994.  the executable file larger. You can reduce the size of programs by
  2995.  compiling with /Zd. You will not be able to view symbols in the Local
  2996.  window within CodeView, however.
  2997.  
  2998.  You should not use the optimize (/Ot) option when compiling a program
  2999.  for use with CodeView. Although CodeView can debug an executable file
  3000.  compiled with /Ot, you will not be able to pause program execution on
  3001.  lines containing  SUB,  FUNCTION, or  DEF FN statements.
  3002.  
  3003.  Object files compiled for use with CodeView must be linked using the
  3004.  /CO option. When linking in DOS, you cannot use the /EXEPACK and /CO
  3005.  together. If your program needs to be packed to fit in memory, use the
  3006.  CVPACK utility to compress the executable file for debugging.
  3007.  
  3008.  The syntax for CVPACK is:
  3009.  
  3010.  CVPACK /HELP | /P  filename
  3011.  
  3012.  If you specify the /P option, CVPACK rewrites the file as compactly
  3013.  as possible. If you don't specify the /P, CVPACK rewrites the file as
  3014.  quickly as possible. In either case, the program takes up the same
  3015.  amount of memory.
  3016.  
  3017.  
  3018.  Running CodeView
  3019.  
  3020.  To start CodeView from the command line, use the CV real-mode or CVP
  3021.  protected-mode command and specify an executable file. For example:
  3022.  
  3023.  CV TEST.EXE
  3024.  
  3025.  To start CodeView from PWB in real or protected mode, choose Debug
  3026.  from the Run menu. By default, CodeView displays three windows, as shown
  3027.  in Figure 5.1.
  3028.  
  3029.  
  3030.  The "Local window" displays the current symbols along with their
  3031.  addresses, types, and values. This window is empty until you begin
  3032.  executing your program.
  3033.  
  3034.  The "Source window" displays the program's source code. Since the
  3035.  program loaded in CodeView is a compiled executable program, you cannot
  3036.  make changes to the source from within CodeView. The Source window shows
  3037.  you where you are in a program and lets you execute the program
  3038.  statement-by-statement.
  3039.  
  3040.  The "Command window" lets you enter CodeView commands and display and
  3041.  evaluate BASIC expressions. Although you cannot make changes to a
  3042.  program from CodeView, you can use the Command window to change the
  3043.  value of variables, write data to memory, and perform a variety of other
  3044.  tasks. CodeView supports a limited number of BASIC intrinsic functions
  3045.  which can be called from the Command window. See the CodeView online
  3046.  Help on BASIC intrinsic functions for more information.
  3047.  
  3048.  
  3049.  Important
  3050.  
  3051.  CodeView includes extensive online Help. If you request Help and get
  3052.  an error message indicating that no Help files were open or that they
  3053.  could not be found, check your HELPFILES environment variable. HELPFILES
  3054.  can be set by running NEW-VARS.BAT (DOS) or NEW-VARS.CMD (OS/2) from the
  3055.  command line before starting CodeView.
  3056.  
  3057.  HELPFILES in the PWB environment has no effect in CodeView.
  3058.  
  3059.  Within CodeView, environment tasks can be performed by using either
  3060.  the mouse or the keyboard. The following table lists commonly used key
  3061.  combinations by category and task. The Command window equivalent is
  3062.  given where one exists. (See the online Help on CodeView commands for a
  3063.  complete list and description of CodeView commands.)
  3064.  
  3065.  
  3066.  Note
  3067.  
  3068.  The Edit tasks are used to copy and paste expressions, values, and
  3069.  blocks of memory. You cannot Paste into the Source window.
  3070.  
  3071.  
  3072.  Debugging Your Program
  3073.  
  3074.  CodeView is similar to QuickBASIC Extended (QBX) in that you can
  3075.  watch the value of variables while you execute parts of your program.
  3076.  Like QBX, you can execute one line at a time, one procedure at a time,
  3077.  or up to a specific location. Unlike QBX, you cannot rewrite your
  3078.  program within CodeView.
  3079.  
  3080.  CodeView also lets you directly manipulate the values stored in
  3081.  variables and in memory.
  3082.  
  3083.  
  3084.  Running Your Program
  3085.  
  3086.  To execute a single line of code, press F8.
  3087.  
  3088.  To execute a line of code or without tracing into procedures, press
  3089.  F10.
  3090.  
  3091.  To quickly execute up to a specific location in a program:
  3092.  
  3093.     1. In the Source window, scroll to the location at which to stop.
  3094.  
  3095.     2. Click the right mouse button at that location.
  3096.  CodeView executes up to that location at normal execution speed.
  3097.  
  3098.  
  3099.  To run a program one line at a time:
  3100.  
  3101.     1. From the Run menu, choose Animate.
  3102.  CodeView immediately begins executing the program.
  3103.  
  3104.     2. Press any key to stop.
  3105.  
  3106.  
  3107.  
  3108.  Important
  3109.  
  3110.  When you run your BASIC program in CodeView under DOS, you will not
  3111.  be able to use the DOS Shell command from the File menu. This is because
  3112.  BASIC reserves all remaining conventional memory while the program is
  3113.  running. To be able to use the DOS Shell command you should terminate or
  3114.  restart your BASIC program.
  3115.  
  3116.  
  3117.  Viewing Current Data
  3118.  
  3119.  When you start executing a program in CodeView, the debugger
  3120.  automatically displays all current variables in the Local window. The
  3121.  Local window shows the address, data type, name, and value of each
  3122.  variable in the current procedure. For example:
  3123.  
  3124.  2FCE:0062  STRING         FULLNAME$ = "Dan Quayle"
  3125.  
  3126.  The value 2FCE:0062 is the address of the variable in memory, STRING
  3127.  is the data type, FULLNAME$ is the variable name, and "Dan Quayle" is
  3128.  the current value of the variable.
  3129.  
  3130.  For arrays and user-defined data types, CodeView displays a summary
  3131.  line. For example:
  3132.  
  3133.  +2FCE:0070 INTEGER    AZ%[array] = ?CANNOT DISPLAY
  3134.  +2FCE:004a type  TESTRECOR FILEBUFFER = {...}
  3135.  
  3136.  The plus sign (+) to the left of the memory address shows that there
  3137.  is more information. To see the elements in the structure TESTRECOR,
  3138.  select the TESTRECOR line. The line expands as follows:
  3139.  
  3140.  -2FCE:0070 type    TESTRECOR FILEBUFFER
  3141.      STRING * 20    NAMEFIELD = "Jeff Webb"
  3142.      SINGLE *       SCOREFIELD = "1370"
  3143.  
  3144.  The minus sign (-) to the left of the memory address shows that the
  3145.  line is fully expanded.
  3146.  
  3147.  You cannot expand BASIC arrays. Instead, you must set watches on
  3148.  elements in the array to see their values.
  3149.  
  3150.  
  3151.  Using Watches
  3152.  
  3153.  Watches let you observe the value of a variable or expression as your
  3154.  program executes. Since CodeView displays the value of local variables
  3155.  in the Local window, CodeView's watches are mainly useful when the Local
  3156.  window is not displayed or for observing array elements and
  3157.  expressions.
  3158.  
  3159.  To add a variable to the Watch window:
  3160.  
  3161.     1. Place the cursor on the variable and press Ctrl+W.
  3162.  CodeView displays the Add Watch dialog box.
  3163.  
  3164.     2. Choose OK.
  3165.  CodeView adds the variable to the Watch window, as shown in Figure 5.2.
  3166.  
  3167.  
  3168.  A variable may be followed by the message "Watch Expression Not in
  3169.  Context." This message appears when program execution has not yet
  3170.  reached the statement in which the variable is defined. Global
  3171.  variables, which can be watched from anywhere in the program, never
  3172.  cause CodeView to display this message.
  3173.  
  3174.  To remove a variable from the Watch window, place the cursor on any
  3175.  line in the Watch window and press Ctrl+Y to delete the line.
  3176.  
  3177.  You can place as many variables as you like in the Watch window; the
  3178.  quantity is limited only by available memory. CodeView automatically
  3179.  updates all watched variables as the program runs. This can slow
  3180.  execution speed considerably.
  3181.  
  3182.  
  3183.  Displaying Expressions in the Watch Window
  3184.  
  3185.  The Add Watch dialog box prompts for an expression, not simply a
  3186.  variable name. As this suggests, you can enter an expression (that is,
  3187.  any valid combination of variables, constants, and operators) for
  3188.  CodeView to evaluate and display.
  3189.  
  3190.  You are not limited to evaluating BASIC expressions. The Language
  3191.  command from the Options menu offers a choice of BASIC, C, or FORTRAN
  3192.  evaluation for all expressions. The ability to select the language
  3193.  evaluator is especially useful when debugging mixed-language
  3194.  programs.
  3195.  
  3196.  By reducing several variables to a single, easily read value, an
  3197.  expression can be easier to interpret than the components that comprise
  3198.  it.
  3199.  
  3200.  
  3201.  Displaying Array Elements Dynamically
  3202.  
  3203.  You  can display a single element of an array using a specific
  3204.  subscript. You can also specify a variable array element, which changes
  3205.  as some other variable changes. For example, suppose that the loop
  3206.  variable p is a subscript for the array CatalogPrice@. The Watch window
  3207.  expression CatalogPrice@(p) displays only the array element currently
  3208.  specified by p, not the entire array.
  3209.  
  3210.  You can mix constant and variable subscripts. For example, the
  3211.  expression BigArray%(3,i) displays the element in the third row of the
  3212.  array to which the index variable i points.
  3213.  
  3214.  
  3215.  Using Quick Watch
  3216.  
  3217.  A quick watch shows the current value of a variable. This is useful
  3218.  for quickly finding the value of a variable at some point in the program
  3219.  without adding it to the Watch window.
  3220.  
  3221.  To display a quick watch:
  3222.  
  3223.     1. Place the cursor on the variable to watch.
  3224.  
  3225.     2. From the Watch menu, choose Quick Watch (or press Shift+F9).
  3226.  CodeView displays the Quick Watch dialog box with the value of the
  3227.  variable.
  3228.  
  3229.  
  3230.  The Quick Watch display automatically expands user-defined types to
  3231.  their first level. You can expand or contract an element just as you
  3232.  would in the Watch window by placing the cursor on the appropriate line
  3233.  and pressing Enter.
  3234.  
  3235.  
  3236.  Displaying Memory
  3237.  
  3238.  You can view data at specific memory addresses using CodeView.
  3239.  
  3240.  To display memory, choose Memory from the View menu. CodeView
  3241.  displays the Memory window, as shown in Figure 5.3.
  3242.  
  3243.  
  3244.  Up to two Memory windows can be open at once.
  3245.  
  3246.  By default, memory is displayed as hexadecimal byte values, with 16
  3247.  bytes per line. At the end of each line is a second display of the same
  3248.  memory in ASCII form. Values that correspond to printable ASCII
  3249.  characters (decimal 32 through 127) are displayed in that form. Values
  3250.  outside this range are shown as periods.
  3251.  
  3252.  Byte values are not always the most convenient way to view memory. If
  3253.  the area of memory you're examining contains character strings or
  3254.  floating-point values, you might prefer to view them in a directly
  3255.  readable form.
  3256.  
  3257.  To change the way data is displayed in the current Memory window:
  3258.  
  3259.     1. From the Options menu, choose Memory Window.
  3260.  CodeView displays the Memory Window Options dialog box.
  3261.  
  3262.     2. Select the format for display, and choose OK.
  3263.  
  3264.  
  3265.  You can also directly cycle through these display formats by pressing
  3266.  F3.
  3267.  
  3268.  If a section of memory cannot be displayed as a valid floating-point
  3269.  number, the number shown includes the characters NAN (not a number).
  3270.  
  3271.  
  3272.  Displaying the Processor Registers
  3273.  
  3274.  To view processor registers, choose Register from the View menu.
  3275.  CodeView opens a window on the right side of the screen, as shown in
  3276.  Figure 5.4. The current values of the microprocessor's registers appear
  3277.  in this window.
  3278.  
  3279.  At the bottom of the window is a group of mnemonics representing the
  3280.  processor flags. When you first open the Register window, all values are
  3281.  shown in normal-intensity video. Any subsequent changes are marked in
  3282.  high-intensity video. For example, suppose the overflow flag is not set
  3283.  when the Register window is first opened. The corresponding mnemonic is
  3284.  NV and appears in light gray. If the overflow flag is subsequently set,
  3285.  the mnemonic changes to OV and appears in bright white.
  3286.  
  3287.  Choosing the 386 Instructions command (DOS only) from the Options
  3288.  menu displays the registers as 32-bit values if your computer uses an
  3289.  80386 processor. Selecting this command a second time reverts to a
  3290.  16-bit display. This command is not available in protected mode; the
  3291.  registers are shown in 16-bit display only.
  3292.  
  3293.  You can also display the registers of an 8087/287/387 coprocessor in
  3294.  a separate window by choosing the 8087 command from the View menu. If
  3295.  your program uses the coprocessor emulator, the emulated registers are
  3296.  displayed instead.
  3297.  
  3298.  
  3299.  Modifying the Values of Variables, and Memory
  3300.  
  3301.  You can easily change the values of numeric variables, registers, or
  3302.  memory locations displayed in the Watch, Local, Memory, Register, or
  3303.  8087 window. Simply place the cursor at the value you want to change and
  3304.  edit it to the appropriate value. To undo the last change you made,
  3305.  press Alt+Backspace. You cannot directly change the value of string
  3306.  variables.
  3307.  
  3308.  The starting address of each line of memory displayed is shown at the
  3309.  left of the Memory window, in  segment: address  form.
  3310.  Altering the address automatically shifts the display to the
  3311.  corresponding section of memory. If that section is not used by your
  3312.  program, memory locations are displayed as double question marks
  3313.  (??).
  3314.  
  3315.  When you select Byte display from the Memory Window Options dialog
  3316.  box, CodeView presents both a hexadecimal and an ASCII representation of
  3317.  the data in memory. (Byte display is the default.) You can change data
  3318.  in memory either by entering new hex values over the hexadecimal
  3319.  representation of your data or by entering character values over the
  3320.  character representation.
  3321.  
  3322.  To toggle a processor flag, click left on its mnemonic. You can also
  3323.  place the cursor on a mnemonic, then press any key (except Tab or
  3324.  Spacebar). Repeat to restore the flag to its previous setting.
  3325.  
  3326.  The effect of changing a register, flag, or memory location may vary
  3327.  from no effect at all to crashing the operating system. You should be
  3328.  cautious when altering  machine-level
  3329.   values; most of the items you would want to change can be altered from
  3330.  the Local or Watch window.
  3331.  
  3332.  Direct manipulation of register values can be valuable, however, when
  3333.  you are debugging a BASIC program that calls assembly language routines.
  3334.  You can change register values to test assumptions before making changes
  3335.  in your source code and recompiling.
  3336.  
  3337.  
  3338.  Setting Breakpoints
  3339.  
  3340.  You can skip over the parts of the program that you don't want to
  3341.  examine by specifying one or more lines as breakpoints .
  3342.   When you start the program by pressing F5, the program executes at full
  3343.  speed up to the first breakpoint, then pauses. Pressing F5 continues
  3344.  program execution up to the next breakpoint, and so on.
  3345.  
  3346.  You can set as many breakpoints as you like (limited only by
  3347.  available memory). There are two ways to set breakpoints:
  3348.  
  3349.    ■   Double-click anywhere on the desired breakpoint line. The selected
  3350.  line is highlighted to show that it is a breakpoint. (CodeView
  3351.  highlights lines that have been selected as breakpoints.) To remove the
  3352.  breakpoint, double-click on the line a second time.
  3353.  
  3354.    ■   Place the cursor anywhere on the line at which you want execution to
  3355.  pause. Press F9 to select the line as a breakpoint. Press F9 a second
  3356.  time to remove the breakpoint.
  3357.  
  3358.  
  3359.  A breakpoint line must be a program line that represents executable
  3360.  code. You cannot select a blank line, a comment line, or a declaration
  3361.  line (such as a variable declaration) as a breakpoint.
  3362.  
  3363.  A breakpoint can also be set at a function or an explicit address. To
  3364.  set a breakpoint at a function, enter its name in the Set Breakpoint
  3365.  dialog box. To set a breakpoint at an address, enter the address in
  3366.   segment: offset form.
  3367.  
  3368.  Once execution has paused, you can continue execution by pressing
  3369.  F5.
  3370.  
  3371.  
  3372.  Setting Conditional Breakpoints
  3373.  
  3374.  CodeView lets you set conditional statements that stop execution when
  3375.  an expression becomes true or changes value. (QBX refers to these
  3376.  conditional breakpoints as "watchpoints.")
  3377.  
  3378.  To set a conditional breakpoint:
  3379.  
  3380.     1. From the Watch menu, choose Set Breakpoint.
  3381.  CodeView displays the Set Breakpoint dialog box, as shown in Figure 5.5.
  3382.  
  3383.     2. Select one of the conditional break options from the dialog box, such
  3384.  as Break When Expression is True.
  3385.  If you select one of the Break at Location options, CodeView takes you
  3386.  to the line number displayed in the Location field when the breakpoint
  3387.  is reached. If you select one of the other two options, CodeView takes
  3388.  you to the last statement that was executed.
  3389.  
  3390.     3. Choose OK.
  3391.  
  3392.  
  3393.  Note
  3394.  
  3395.  When a breakpoint is tied to a variable, CodeView must check the
  3396.  variable's value after each machine instruction is executed. This slows
  3397.  execution greatly. For maximum speed when debugging, either tie
  3398.  conditional breakpoints to specific lines, or set conditional
  3399.  breakpoints only after you have reached the section of code that needs
  3400.  to be debugged.
  3401.  
  3402.  
  3403.  Replaying a Debug Session
  3404.  
  3405.  CodeView can automatically create a history file with all the
  3406.  debugging instructions and input data you entered when testing a
  3407.  program. This history file is used to replay the debug session to a
  3408.  specific point.
  3409.  
  3410.  To record a debug session, choose History On from the Run menu.
  3411.  
  3412.  To stop recording, choose History On a second time.
  3413.  
  3414.  Recordings can be used to keep track of debugging. You can quit after
  3415.  a long debugging session, then pick up the session later in the same
  3416.  place.
  3417.  
  3418.  The principal use of recording a debug session is to allow you to
  3419.  back up when you make an error or overshoot the section of code with the
  3420.  bug. For example, you may have to execute a function manually many times
  3421.  before its bug appears. If you then enter a command that alters the
  3422.  machine's or program's status and thereby lose the information you need
  3423.  to find the cause of the bug, you have to restart the program and
  3424.  manually repeat every debugging step to return to that point. Even
  3425.  worse, if you don't remember the exact sequence of events that exposed
  3426.  the bug, it could take hours to find your way back.
  3427.  
  3428.  Recording your session eliminates this problem. Choosing Undo from
  3429.  the Run menu automatically restarts the program and rapidly executes
  3430.  every debug command up to (but not including) the last one you entered.
  3431.  You can repeat this process as many times as you like until you return
  3432.  to the desired point in execution.
  3433.  
  3434.  To add steps to an existing recorded session, choose History On, then
  3435.  select Replay. When replay has completed, perform whatever new debugging
  3436.  steps you want, then select History On a second time to terminate
  3437.  recording. The new tape contains both the original and the added
  3438.  commands.
  3439.  
  3440.  
  3441.  Note
  3442.  
  3443.  CodeView records only those mouse commands that apply to CodeView.
  3444.  Mouse commands recognized by the application being debugged are not
  3445.  recorded.
  3446.  
  3447.  
  3448.  Replay Limitations Under OS/2
  3449.  
  3450.  There are some limitations to dynamic replay when debugging under
  3451.  OS/2:
  3452.  
  3453.    ■   n The program must not respond to asynchronous events. (Replay under
  3454.  OS/2 Presentation Manager is not currently supported because it violates
  3455.  this restriction.)
  3456.  
  3457.    ■   Breakpoints must be specified at specific source lines or for
  3458.  specific symbols (rather than by absolute addresses), or replay may
  3459.  fail.
  3460.  
  3461.    ■   Single-thread programs behave normally during replay. However, one of
  3462.  the threads in a multithread program may cause an asynchronous event,
  3463.  violating the first restriction. Multithread programs are, therefore,
  3464.  more likely to fail during replay.
  3465.  
  3466.    ■   Multiprocess replay will fail. Each new process invokes a new
  3467.  CodeView session. The existence of multiple sessions makes it
  3468.  impractical to record the sequence of events if you execute commands in
  3469.  a session other than the original.
  3470.  
  3471.  
  3472.  
  3473.  Advanced CodeView Techniques
  3474.  
  3475.  Once you are comfortable displaying and changing variables, stepping
  3476.  through the program, and using dynamic replay, you may want to
  3477.  experiment with advanced techniques.
  3478.  
  3479.  
  3480.  Setting Command-Line Arguments
  3481.  
  3482.  If your program retrieves command-line arguments, you can specify
  3483.  them with the Set Runtime Arguments command from the Run menu. Enter the
  3484.  arguments in the Command Line field before you begin execution.
  3485.  (Arguments entered after execution begins cause an automatic
  3486.  restart.)
  3487.  
  3488.  
  3489.  Multiple Source Windows
  3490.  
  3491.  You can open two Source windows simultaneously. The windows can
  3492.  display two different sections of the same program, or one can show the
  3493.  high-level listing and the other the assembly language listing. In the
  3494.  latter case, the contents of the windows are synchronized. The next
  3495.  assembly language instruction to be executed matches the next line of
  3496.  source code.
  3497.  
  3498.  You can move freely between these windows, executing a single line of
  3499.  source code or a single assembly instruction at a time.
  3500.  
  3501.  
  3502.  Using Breakpoints Efficiently
  3503.  
  3504.  Breakpoints slow execution when debugging. You can increase
  3505.  CodeView's speed by using the /R command-line switch if you have an
  3506.  80386-based computer. This switch enables the 386's four debug
  3507.  registers, which support breakpoint checking in hardware rather than in
  3508.  software.
  3509.  
  3510.  
  3511.  Printing Selected Items
  3512.  
  3513.  To print all or part of the contents of any window:
  3514.  
  3515.     1. From the File menu, choose Print.
  3516.  CodeView displays the Print dialog box.
  3517.  
  3518.     2. Select the information to print and whether to append the
  3519.  information to an existing file or to overwrite the file.
  3520.  By default, print output is to the file CODEVIEW.LST in the current
  3521.  directory. If you want the output to go to a printer, enter the
  3522.  appropriate device name (such as LPT1: or COM2:) in the To File Name
  3523.  field.
  3524.  
  3525.     3. Choose OK.
  3526.  
  3527.  
  3528.  
  3529.  Handling Register Variables
  3530.  
  3531.  A register variable is stored in one of the microprocessor's
  3532.  registers, rather than in RAM. This speeds access to the variable.
  3533.  
  3534.  A conventional variable can become a register variable when the
  3535.  compiler stores an often-used variable, such as a loop variable, in a
  3536.  register to speed execution.
  3537.  
  3538.  Register variables can cause problems during debugging. As with local
  3539.  variables, they are only visible within the function where they are
  3540.  defined. In addition, a register variable may not always be displayed
  3541.  with its current value.
  3542.  
  3543.  
  3544.  Redirecting CodeView Input and Output
  3545.  
  3546.  The Command window accepts DOS-like commands that redirect input and
  3547.  output. These commands can also be included on the command line that
  3548.  invokes CodeView. Whatever follows the /C option on the command line is
  3549.  treated as a CodeView command to be immediately executed at startup. For
  3550.  example:
  3551.  
  3552.  CV /c infile; t >outfile myprog
  3553.  
  3554.  This command line redirects input to infile, which can contain
  3555.  startup commands for CodeView. When CodeView exhausts all commands in
  3556.  the input file, focus automatically shifts to the Command window. Output
  3557.  is sent to outfile and echoed to the Command window. The t must precede
  3558.  the  >   command for output to be sent to the Command window.
  3559.  
  3560.  Redirection is a useful way to automate CodeView startup. It also
  3561.  lets you keep a viewable record of command-line input and output, a
  3562.  feature not available with dynamic replay. (No record is kept of mouse
  3563.  operations.) Some applications (particularly interactive ones) may need
  3564.  modification to allow for redirection of input to the application
  3565.  itself.
  3566.  
  3567.  
  3568.  Customizing CodeView with the TOOLS.INI File
  3569.  
  3570.  The TOOLS.INI file customizes the behavior and user interface of
  3571.  several Microsoft products. You should place it in a directory pointed
  3572.  to the INIT environment variable. (If you do not use the INIT
  3573.  environment variable, CodeView looks for TOOLS.INI only in its source
  3574.  directory.)
  3575.  
  3576.  The CodeView section of TOOLS.INI is preceded by the following
  3577.  line:
  3578.  
  3579.  [cv]
  3580.  
  3581.  If you are running the protected-mode version of CodeView, use  [cvp]
  3582.   instead. If you run both versions, include both: [cv cvp].
  3583.  
  3584.  Most of the TOOLS.INI customizations control screen colors, but you
  3585.  can also specify options, such as startup commands or the name of the
  3586.  file receiving CodeView output. Online Help contains full information
  3587.  about all TOOLS.INI switches for CodeView.
  3588.  
  3589.  
  3590.  Controlling CodeView with Command-Line Options
  3591.  
  3592.  The following options can be added to the command line that invokes
  3593.  CodeView:
  3594.  
  3595.  Option   Effect
  3596.  /2       Two-monitor debugging. One display shows the output of the
  3597.           application; the other shows CodeView.
  3598.  
  3599.  /25      Display in 25-line mode.
  3600.  
  3601.  /43      Display in 43-line mode. (EGA or VGA only)
  3602.  
  3603.  /50      Display in 50-line mode. (VGA only)
  3604.  
  3605.  /B       Display in black and white.
  3606.  
  3607.  /C commands:  All items following this switch are treated as CodeView
  3608.  commands to be executed immediately upon startup. Commands must be
  3609.  separated with a semicolon (;).
  3610.  
  3611.  /D buffersize:  Use disk overlays, where  buffersize
  3612.  is the decimal size of the overlay buffer, in kilobytes. The acceptable
  3613.  range is 16K to 128K, with the default size 64K. (DOS only)
  3614.  
  3615.  /E       Use expanded memory for symbolic information. (DOS only)
  3616.  
  3617.  /F       Flip screen video pages. When your application does not use
  3618.           graphics, up to eight video screen pages are available.
  3619.           Switching from CodeView to the output screen is accomplished
  3620.           more quickly than swapping (/S) by directly selecting the
  3621.           appropriate video page. Cannot be used with /S. (DOS only)
  3622.  
  3623.  /I[0|1]  /I0 enables nonmaskable-interrupt and 8259-interrupt trapping.
  3624.           This enables Ctrl+C and Ctrl+Break for PCs that CodeView does
  3625.           not recognize as IBM-compatible. /I or /I1 turns off interrupt
  3626.           trapping. (DOS only)
  3627.  
  3628.  /K       Use this option if you encounter a deadlock situation because
  3629.           the keyboard buffer is full when you restart the program you
  3630.           are debugging, exit CodeView before your program finishes
  3631.           execution, or debug an application that does not accept
  3632.           keystrokes.
  3633.  
  3634.  /L dlls: Load DLLs specified. DLLs must be separated by a
  3635.  semicolon (;). (OS/2 only)
  3636.  
  3637.  /M       Disable the mouse for CodeView. Does not affect the use of the
  3638.           mouse in the application being debugged.
  3639.  
  3640.  /N[0|1]  /N0 enables nonmaskable-interrupt trapping. This enables Ctrl+C
  3641.           and Ctrl+Break for PCs that CodeView does not recognize as
  3642.           IBM-compatible. /N or /N1 turns off interrupt trapping.only)
  3643.  
  3644.  /O       Debug child processes ( offspring). (OS/2 only)
  3645.  
  3646.  /R       Use 386 hardware debug registers. (DOS only)
  3647.  
  3648.  /S       Swap screen in buffers. When your program uses graphics, all
  3649.           eight screen buffers must be used. Switching from CodeView
  3650.           to the output screen is accomplished by saving the previous
  3651.           screen in a buffer. Cannot be used with /F. (DOS only)
  3652.  
  3653.  /X       Use extended memory for symbolic information. (DOS only)
  3654.  
  3655.  
  3656.  
  3657.   ────────────────────────────────────────────────────────────────────────────
  3658.  
  3659.  
  3660.  
  3661.  Chapter 6  Using Online Help
  3662.  ────────────────────────────────────────────────────────────────────────────
  3663.  
  3664.  The Microsoft Advisor online Help system is more than a learning
  3665.  tool--it's a reference database designed especially for
  3666.  professional programmers. Help gives you instant reference information
  3667.  about the BASIC language, development environments, compiler options,
  3668.  utilities, and error messages. You can also copy sample code from a Help
  3669.  screen and paste it directly into your BASIC source file. Using the
  3670.  Microsoft Help File Creation utility (HELPMAKE), you can even create
  3671.  your own Help files.
  3672.  
  3673.  This chapter describes:
  3674.    ■   Installing Help.
  3675.    ■   Organization of Help.
  3676.    ■   Navigating in Help.
  3677.    ■   Copying and pasting Help information.
  3678.    ■   Creating your own Help files.
  3679.    ■   Using QuickHelp.
  3680.  
  3681.  
  3682.  Installing Help
  3683.  
  3684.  Use the Setup program to install Help. In the Specify Files to
  3685.  Install menu, turn on the Help Files for Chosen Tools check box. Setup
  3686.  includes all the Help files you need when it installs Microsoft
  3687.  BASIC.
  3688.  
  3689.  At this point, you can use online Help in the QuickBASIC Extended
  3690.  (QBX) environment. To use Help in the Programmer's WorkBench (PWB),
  3691.  CodeView, and QuickHelp environments, you must specify where each of
  3692.  these applications should look for their Help files by setting the
  3693.  HELPFILES environment variable. HELPFILES can be set in several
  3694.  different places. PWB, CodeView, and QuickHelp search the following
  3695.  locations in the order shown and use the first HELPFILES setting they
  3696.  find:
  3697.  
  3698.    ■    1. Environment selection from the PWB Options menu.
  3699.  (This only has an effect in PWB.)
  3700.  
  3701.    ■    2. TOOLS.INI file.
  3702.  
  3703.    ■    3. AUTOEXEC.BAT file (DOS) or CONFIG.SYS file (OS/2).
  3704.  
  3705.  
  3706.  If HELPFILES is not set in one of these locations, PWB and QuickHelp
  3707.  will search for help files in the current directory and in the
  3708.  directories listed in the PATH environment variable.
  3709.  
  3710.  You can set HELPFILES and other environment variables for a session
  3711.  by running the
  3712.  
  3713.  (DOS) or NEW-VARS.CMD (OS/2) file from the command line. You may want
  3714.  to incorporate the settings in these files into your AUTOEXEC.BAT (DOS)
  3715.  or CONFIG.SYS (OS/2) files. For information on how to do this, see the
  3716.  section "After Running Setup" in Chapter 2.
  3717.  
  3718.  
  3719.  Help Topics and Hyperlinks
  3720.  
  3721.  Online Help is organized as a set of topics. Instead of thumbing
  3722.  through a manual, you can move from one topic to another related topic
  3723.  by using links (or cross-references). Help remembers the last 20 screens
  3724.  you've viewed, so you can retrace your path at any time.
  3725.  
  3726.  
  3727.  Explicit Cross-References
  3728.  
  3729.  Explicit cross-references, called "hyperlinks," are tied to a word or
  3730.  phrase at a specific location in Help. You simply select a hyperlink,
  3731.  using the mouse or keyboard, to move to a new screen of related
  3732.  information.
  3733.  
  3734.  Special characters set off hyperlink buttons. Figure 6.1 shows
  3735.  examples.
  3736.  
  3737.  
  3738.  To move forward between hyperlinks, press the Tab key; Shift+Tab
  3739.  moves you backward. You can also type the first letter of a hyperlink to
  3740.  move to that hyperlink.
  3741.  
  3742.  
  3743.  Implicit Cross-References
  3744.  
  3745.  All BASIC keywords (functions, statements, operators, and
  3746.  metacommands) are implicit cross-references. Implicit cross-references
  3747.  have no special formatting. For example, the word "open" provides
  3748.  context-sensitive help on the  OPEN
  3749.   statement wherever it appears, whether in your programs or in a Help
  3750.  screen. To use an implicit cross-reference, place the cursor on or
  3751.  immediately following the keyword, and then press F1 or click the right
  3752.  mouse button.
  3753.  
  3754.  
  3755.  Help Categories
  3756.  
  3757.  There are five categories of help:
  3758.    ■   Using Help
  3759.    ■   Keyword and symbol Help
  3760.    ■   Topic-based Help
  3761.    ■   Programming environment Help
  3762.    ■   Error message Help
  3763.  
  3764.  
  3765.  
  3766.  Using Help
  3767.  
  3768.  You can get information about the online Help system itself at any
  3769.  time by choosing the Using Help command from the Help menu. The Using
  3770.  Help screen provides a quick overview of the Help system and gives
  3771.  instructions for accessing Help with the keyboard or mouse.
  3772.  
  3773.  
  3774.  Keyword and Symbol Help
  3775.  
  3776.  Online Help provides context-sensitive help for BASIC keywords and
  3777.  for symbols in your program, such as procedures and variables.
  3778.  
  3779.  
  3780.  Keyword Help
  3781.  
  3782.  Keywords include functions, statements, operators, and metacommands.
  3783.  Every keyword in Microsoft BASIC is an implicit cross-reference. To get
  3784.  information on any BASIC keyword (in your program or within the online
  3785.  Help system), place the cursor on the keyword, and press F1 or click the
  3786.  right mouse button. For example, type   do
  3787.    in the QBX View window, and then press F1. The Syntax screen for the
  3788.   DO ... LOOP statement appears, as shown in Figure 6.2.
  3789.  
  3790.  
  3791.  If you want to see a programming example using the  DO ... LOOP
  3792.  statement, move to the Help window, then choose the Example hyperlink.
  3793.  If you need additional information, choose the Details hyperlink.
  3794.  
  3795.  
  3796.  Note
  3797.  
  3798.  You can browse the complete list of BASIC keywords by choosing the
  3799.  Keywords by Task hyperlink from the BASIC Help Table of Contents
  3800.  screen.
  3801.  
  3802.  
  3803.  Symbol Help
  3804.  
  3805.  To get information on any symbol in your program from QBX, position
  3806.  the cursor anywhere on the symbol and then press F1 or click the right
  3807.  mouse button. The Help system will identify the symbol (variable,
  3808.  function, etc.) and where it is used in your program. This type of Help
  3809.  is only available in QBX.
  3810.  
  3811.  To view symbol information in PWB, you must use the Source Browser.
  3812.  For instructions on using the Source Browser, see Chapter 4, "Using
  3813.  PWB."
  3814.  
  3815.  
  3816.  Topic-Based Help
  3817.  
  3818.  You can use the Help system to get an overview of available topics
  3819.  when you have a general idea of the information you need. For example,
  3820.  suppose you want to learn about QBX's customizable keystrokes, but you
  3821.  don't know where to look. Choose the Contents hyperlink in any Help
  3822.  window, or choose Contents from the Help menu. The BASIC Help Table of
  3823.  Contents screen appears, as shown in Figure 6.3.
  3824.  
  3825.  
  3826.  The BASIC Help Table of Contents screen is broken into five
  3827.  subgroups: Orientation, Language Elements, Command-Line Options, Quick
  3828.  Reference, and Keys.
  3829.  
  3830.  
  3831.  Programming Environment Help
  3832.  
  3833.  You can get context-sensitive Help on any menu command or dialog box.
  3834.  For example, to learn about the Create File command in the QBX File
  3835.  menu:
  3836.  
  3837.     1 Open the File menu.
  3838.  
  3839.     2 Press the Down direction key to highlight Create File
  3840.  (do not press Enter), and then press F1. The Help screen for the Create
  3841.  File command appears, as shown in Figure 6.4.
  3842.  
  3843.  
  3844.  You can also get help about a dialog box. Press F1 or click the Help
  3845.  button to display information about the dialog box.
  3846.  
  3847.  
  3848.  Error Message Help
  3849.  
  3850.  Whenever you encounter an error message, you can press F1 to get help
  3851.  on the cause of the error. Most error message Help screens contain
  3852.  suggestions on how to avoid the error.
  3853.  
  3854.  
  3855.  Navigating in the Help System
  3856.  
  3857.  The following table summarizes Help keystrokes.
  3858.  
  3859. ╓┌───────────────────────────────────────┌───────────────────────────────────╖
  3860.  Press this key                          To do this
  3861.  ────────────────────────────────────────────────────────────────────────────
  3862.  F1                                      Get Help on the selected item.
  3863.  
  3864.  Shift+F1                                In QBX, get help on using the Help
  3865.                                          system. In PWB, CodeView, and
  3866.  Press this key                          To do this
  3867.  ────────────────────────────────────────────────────────────────────────────
  3868.                                         system. In PWB, CodeView, and
  3869.  
  3870.  
  3871.  Alt+F1                                  Display previous Help screen. You
  3872.                                          can retrace your path through
  3873.  
  3874.  
  3875.  Esc                                     Close the Help window.
  3876.  
  3877.  PgDn                                    Scroll Help information down when
  3878.                                          the Help window is active.
  3879.  
  3880.  PgUp                                    Scroll Help information up when
  3881.                                          the Help window is active.
  3882.  
  3883.  Tab                                     Move to the next hyperlink in the
  3884.                                          active Help window.
  3885.  
  3886.  Shift+Tab                               Move to the previous hyperlink in
  3887.  Press this key                          To do this
  3888.  ────────────────────────────────────────────────────────────────────────────
  3889. Shift+Tab                               Move to the previous hyperlink in
  3890.                                          the active Help window..
  3891.  
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  Copying and Pasting Help Information
  3897.  
  3898.  You can copy any text that appears in the Help window to another
  3899.  window. To test a sample program from the Help window, just copy it to
  3900.  the program window and then choose Start (QBX) or Execute (PWB) from the
  3901.  Run menu.
  3902.  
  3903.  To copy and paste, follow these steps:
  3904.  
  3905.     1 Select the text you want to copy.
  3906.  
  3907.     2 Press Ctrl+Ins.
  3908.  
  3909.     3 In the program window, place the cursor where you want to
  3910.  insert the text, and then press Shift+Ins.
  3911.  
  3912.  
  3913.  Creating Custom Help Files
  3914.  
  3915.  The HELPMAKE utility allows you to create or modify Help files for
  3916.  use with Microsoft products. For example, you could write Help text
  3917.  describing a new function you have written for a Quick library. You can
  3918.  then display Help information about your function just as you would
  3919.  display Microsoft-supplied Help information.
  3920.  
  3921.  HELPMAKE translates Help text files into a Help database accessible
  3922.  from the QBX programming environment or other Microsoft language
  3923.  products. You can either create Help files from scratch, or you can use
  3924.  HELPMAKE to decompress the Microsoft-supplied Help database and then
  3925.  modify it.
  3926.  
  3927.  For complete information on building your own Help system, see
  3928.  Chapter 22, "Customizing Online Help," in the  Programmer's
  3929.  Guide, or select HELPMAKE from the main Help Table of
  3930.  Contents in PWB.
  3931.  
  3932.  
  3933.  Using QuickHelp
  3934.  
  3935.  Microsoft QuickHelp lets you read Microsoft Advisor Help files
  3936.  without running a programming environment. This is useful if you are
  3937.  running Microsoft Windows or OS/2 and you want to keep Help information
  3938.  open in a window at all times. QuickHelp is also useful for reading Help
  3939.  databases that you have created for your own applications.
  3940.  
  3941.  To start QuickHelp, type:
  3942.  
  3943.   QH
  3944.  
  3945.  
  3946.  QuickHelp searches for Help files in the paths and the order
  3947.  described in the section "Installing Help" earlier in this chapter. In
  3948.  addition, QuickHelp also uses the QH environment variable to define
  3949.  additional directories to search. For example:
  3950.  
  3951.  SET HELPFILES=C:\BC7\HELP
  3952.  
  3953.  SET QH=C:\LANMAN\HELP
  3954.  
  3955.  If these lines are entered from the command line, QuickHelp will
  3956.  search in C:\BC7\HELP and C:\LANMAN\HELP for Help files. PWB and
  3957.  CodeView, however, will not search in C:\LANMAN\HELP unless it is
  3958.  included in the HELPFILES environment variable.
  3959.  
  3960.  
  3961.   ────────────────────────────────────────────────────────────────────────────
  3962.  
  3963.  
  3964.  
  3965.  Chapter 7  Memory Management in DOS
  3966.  ────────────────────────────────────────────────────────────────────────────
  3967.  
  3968.  This chapter explains how to increase the amount of memory available
  3969.  under DOS to help you create the largest possible running applications
  3970.  using each of the Microsoft BASIC environments. It shows you how to take
  3971.  advantage of extended and expanded memory by using one or more of the
  3972.  three device drivers included in the package: HIMEM.SYS, SMARTDRV.SYS,
  3973.  or RAMDRIVE.SYS.
  3974.  
  3975.  
  3976.  Overview
  3977.  
  3978.  You can use a variety of techniques to make more memory available for
  3979.  program use, such as:
  3980.  
  3981.    ■   Removing all unnecessary memory-resident programs and device drivers.
  3982.  (Check your CONFIG.SYS and AUTOEXEC.BAT files to see what you have
  3983.  installed.)
  3984.  
  3985.    ■   Using extended and/or expanded memory. Extended and expanded memory
  3986.  are available through the use of add-on memory boards. Some system
  3987.  boards have extended or expanded memory built in as well. Add-on memory
  3988.  boards include extended memory, expanded memory, and some boards that
  3989.  can be configured for either. Expanded and extended memory are used in
  3990.  different ways:
  3991.  
  3992.    - Extended memory. You can use the HIMEM.SYS device driver provided
  3993.  with this package or another extended-memory driver.
  3994.  
  3995.    - Expanded-memory emulators. Many extended-memory drivers
  3996.  can use some or all memory to emulate expanded memory. Information in
  3997.  this chapter about expanded-memory hardware applies to expanded-memory
  3998.  emulators as well.
  3999.  
  4000.    - Expanded memory. Expanded memory provides up to 1.2
  4001.  megabytes of buffer space to the ISAM portion of a BASIC program.
  4002.  
  4003.  You can use extended and expanded memory at the same time.
  4004.  However, only one expanded-memory driver and one extended-memory manager
  4005.  can run on the system. Use an expanded-memory emulator only if you have
  4006.  no expanded-memory hardware.
  4007.  
  4008.  
  4009.  
  4010.  Using Extended Memory (XMS)
  4011.  
  4012.  Extended memory requires an 80286 or later processor. The
  4013.  extended-memory device drivers compatible with BASIC observe the
  4014.  Extended Memory Specification (XMS), version 2.0 and higher. You can use
  4015.  the HIMEM.SYS device driver provided in this package, or you can use
  4016.  your own extended-memory driver if it supports XMS version 2.0 or
  4017.  higher.
  4018.  
  4019.  
  4020.  The HIMEM.SYS Device Driver
  4021.  
  4022.  The HIMEM.SYS device driver provides a 64K area immediately above one
  4023.  megabyte called the High Memory Area (HMA). Only one piece of software
  4024.  can reside in HMA.
  4025.  
  4026.  You must have DOS version 3.0 or later to run HIMEM.SYS. To install
  4027.  HIMEM.SYS, place the following statement in your CONFIG.SYS file:
  4028.  
  4029.  device=[ drive:][ path]HIMEM.SYS [/HMAMIN= tsrmin]
  4030.    [/NUMHANDLES= handles][/SHADOW=[ON | OFF]][/MACHINE= machine]
  4031.  
  4032.  In the preceding syntax,  tsrmin  is the minimum size, in kilobytes,
  4033.  that a memory-resident program must have to be placed in HMA. The default
  4034.  value of 0 lets any memory-resident program request use of this area
  4035.  for extended memory.
  4036.  
  4037.  The  handles  field sets the maximum number of Extended Memory
  4038.  Block handles that HIMEM.SYS supports. Each piece of software that you load
  4039.  into extended memory above HMA requires an additional handle. The handles
  4040.  field defaults to 32 and must be between 1 and 128. Each additional handle
  4041.  requires 6 bytes of memory.
  4042.  
  4043.  The /SHADOW option enables or disables shadow RAM. Some computers
  4044.  make ROM  faster by "shadowing" it in RAM -- that is, copying the
  4045.  ROM code into RAM memory at startup. This uses some extended memory. On
  4046.  systems with 384K of extended memory, HIMEM.SYS automatically disables
  4047.  shadowing. You can use /SHADOW=ON to explicitly enable shadowing on
  4048.  systems with less than 384K of extended memory.
  4049.  
  4050.  The /MACHINE option tells HIMEM.SYS what type of computer you are
  4051.  using. In most cases, HIMEM.SYS automatically detects the type of
  4052.  machine you are using. Currently, the only system which requires this
  4053.  switch is the Acer 1100. If you are using this system, you should use
  4054.  the option /MACHINE:ACER1100.
  4055.  
  4056.  
  4057.  Other Extended-Memory Device Drivers
  4058.  
  4059.  In general, extended-memory device drivers make memory available by
  4060.  using three kinds of addresses:
  4061.  
  4062.    ■   A 64K area starting at address FFFF:0010, just above conventional
  4063.  memory.
  4064.  
  4065.    ■   Addresses above this 64K area. This region can be accessed by
  4066.  temporarily switching into protected mode, then copying the contents to
  4067.  a lower address.
  4068.  
  4069.    ■   Unused addresses above 640K but below one megabyte. These are areas
  4070.  reserved by the system but currently unused.
  4071.  
  4072.  
  4073.  HIMEM.SYS supports the first two kinds of addressing.
  4074.  
  4075.  Some extended-memory device drivers can move memory-resident programs
  4076.  into the third area--unused addresses below one megabyte. Doing so
  4077.  makes more conventional memory available.
  4078.  
  4079.  For example, if you have an 80386 processor and the 386MAX.SYS device
  4080.  driver (from Qualitas, Inc.), you may be able to move the ISAM TSR into
  4081.  unused address space. This requires a sufficiently large contiguous area
  4082.  of memory and is dependent on your system configuration. Install
  4083.  386MAX.SYS in your CONFIG.SYS file, and then execute the following
  4084.  DOS-level commands:
  4085.  
  4086.      386MAX loadhigh
  4087.      PROISAMD
  4088.      386MAX loadlow
  4089.  
  4090.  The first command directs the 386MAX driver to load software into
  4091.  high memory (above 640K). PROISAMD is the full version of the ISAM
  4092.  memory-resident program (database creation and access). The third
  4093.  command restores normal loading.
  4094.  
  4095.  
  4096.  Using Expanded Memory (EMS)
  4097.  
  4098.  Expanded memory is compatible with all 8086-family processors. It is
  4099.  implemented by a paging mechanism to swap up to 64K into an
  4100.  8086-addressable area. The expanded-memory device drivers compatible
  4101.  with BASIC observe the Lotus-Intel-Microsoft (LIM) Expanded Memory
  4102.  Specification (EMS). To ensure compatibility with QBX and ISAM, use
  4103.  device drivers that support the LIM 4.0 specification.
  4104.  
  4105.  To use expanded memory, you must install an expanded-memory device
  4106.  driver in your CONFIG.SYS file. Hardware manufacturers supply a device
  4107.  driver with their expanded memory board. Two of the device drivers
  4108.  included in this package, RAMDRIVE.SYS and SMARTDRV.SYS, can be used
  4109.  with expanded memory.
  4110.  
  4111.  
  4112.  Note
  4113.  
  4114.  All of the features described in this section also apply to
  4115.  expanded-memory emulators.
  4116.  
  4117.  
  4118.  Using RAMDRIVE
  4119.  
  4120.  The RAMDRIVE.SYS device driver lets you use a portion of your
  4121.  computer's memory as an additional hard disk. This disk is referred to
  4122.  as a RAM disk or virtual disk and is much faster than a physical hard
  4123.  disk.
  4124.  
  4125.  You can place a RAM disk in conventional, extended, or expanded
  4126.  memory. On most machines, RAMDRIVE.SYS runs fastest with expanded
  4127.  memory. RAMDRIVE.SYS always uses some conventional memory. The exact
  4128.  amount depends on your hardware configuration and varies between
  4129.  systems.
  4130.  
  4131.  The system reads and writes to the RAM disk almost as fast as to main
  4132.  memory. If you set the TMP environment variable to a directory on a RAM
  4133.  disk, a number of programming tools (notably LINK and ISAM) will use the
  4134.  RAM disk to hold temporary files, thus speeding up operations. You can
  4135.  also copy libraries and frequently used executable files to RAMdrive at
  4136.  the beginning of a session to increase speed. Placing source files on
  4137.  the RAM disk is risky since all information is deleted from the RAM disk
  4138.  when you reboot.
  4139.  
  4140.  To install RAMDRIVE.SYS, include the following command line in your
  4141.  CONFIG.SYS file:
  4142.  
  4143.  device=[ drive:][ path]RAMDRIVE.SYS[disksize]
  4144.   [sectorsize][entries][{/A | /E | /U}]
  4145.  
  4146.  
  4147.  The following list explains the meaning of each option:
  4148.  
  4149.  Option         Description
  4150.  disksize       Disk size in kilobytes. The default size is 64K, the
  4151.                 minimum is 16K, and the maximum is 4096K.
  4152.  
  4153.  sectorsize     Sector size in bytes. The default size is 512 bytes. The
  4154.                 other legal values are 128, 256, and 1024. If in doubt,
  4155.                 use the default.
  4156.  
  4157.  entries        Limits the number of root directory entries (files and
  4158.                 subdirectories). The default size is 64, the minimum is
  4159.                 2, and the maximum is 1024.
  4160.  
  4161.  /A             Uses expanded memory. (This memory must conform to the
  4162.                 4.0 specification.) If you use /A, you cannot use /E
  4163.                 or /U.
  4164.  
  4165.  /E             Uses extended memory, making use of addresses above the
  4166.                 one-megabyte address space. If you use /E, you cannot
  4167.                 use /A or /U.
  4168.  
  4169.  /U             Applicable only to AT 6300 PLUS motherboard. Specifies
  4170.                 that some or all of the 384K of extra memory on an AT
  4171.                 6300 PLUS motherboard is to be used as an extra RAM drive.
  4172.                 1K of the 384K is reserved as overhead for RAMDRIVE.SYS.
  4173.                 If you use /U, you cannot use /A or /E.
  4174.  
  4175.  
  4176.  
  4177.  Note
  4178.  
  4179.  Any use of RAMDRIVE.SYS or SMARTDRV.SYS uses some conventional
  4180.  memory.
  4181.  
  4182.  The versions of RAMDRIVE.SYS and SMARDRV.SYS provided with BASIC are
  4183.  compatible with Windows version 3.0. They are not compatible with
  4184.  Windows versions 2.11 and earlier.
  4185.  
  4186.  
  4187.  Using SMARTDrive
  4188.  
  4189.  The SMARTDRV.SYS device driver lets you use a portion of your
  4190.  computer's memory as a disk-cache area. This mechanism serves as a
  4191.  temporary holding area for recently accessed data from the hard disk,
  4192.  which significantly reduces data-access time if the desired information
  4193.  is in cache.
  4194.  
  4195.  You can place the SMARTDrive disk cache in either extended or
  4196.  expanded memory.
  4197.  
  4198.  To install SMARTDRV.SYS, include the following command line in your
  4199.  CONFIG.SYS file:
  4200.  
  4201.  device=[drive:][path]SMARTDRV.SYS[normal cachesize]
  4202.     [minimum cachesize][/A]
  4203.  
  4204.  
  4205.  The following list explains the meaning of each option:
  4206.  
  4207.  
  4208.  Option               Description
  4209.  ----------------------------------------------------------------------
  4210.  normalcachesize      Size of the disk cache in kilobytes. The default
  4211.                       size is 256K for extended memory and all of
  4212.                       available memory for expanded memory. Several
  4213.                       megabytes is a typical size for a disk cache;
  4214.                       you'll generally see little difference in
  4215.                       performance unless the cache is well over 500K
  4216.                       in size.
  4217.  
  4218.  minimumcachesize     The smallest disk cache in kilobytes. Windows
  4219.                       will reduce disk cache to this number when running
  4220.                       in real mode.to make more memory available for its
  4221.                       own use.
  4222.  
  4223.  /A                   Uses expanded memory. If this option is not present,
  4224.                       then SMARTDrive attempts to use extended memory.
  4225.  
  4226.  
  4227.  
  4228.  Generally, the memory assigned to SMARTDRV.SYS cannot be used by
  4229.  other software. However, CodeView and Windows can share memory with
  4230.  SMARTDrive. Any remaining memory is used for disk-cache operations.
  4231.  
  4232.  
  4233.  ISAM Use of Expanded Memory
  4234.  
  4235.  By default, ISAM uses about 1.2 megabytes of expanded memory for
  4236.  buffer space (or as much as available, whichever is less). This helps to
  4237.  free conventional memory and improves performance by providing far more
  4238.  buffers than could exist in conventional memory.
  4239.  
  4240.  Depending on how much expanded memory you have, ISAM's use of 1.2
  4241.  megabytes may affect the performance of other programs that need this
  4242.  memory. To limit the amount of expanded memory that ISAM uses, use the
  4243.  /Ie command-line option with the BASIC Compiler or when starting the
  4244.  ISAM memory-resident program:
  4245.  
  4246.  /Ie: emsreserve
  4247.  
  4248.  In the syntax above,  emsreserve is the number of kilobytes to
  4249.  reserve for other software. The setting /Ie:-1 is a special value that
  4250.  disables ISAM's use of expanded memory altogether.
  4251.  
  4252.  For example, the following command line starts the ISAM
  4253.  memory-resident program and reserves 800K of expanded memory for other
  4254.  software, such as QBX or CodeView:
  4255.  
  4256.  PROISAMD /Ie:800
  4257.  
  4258.  Use /Ie in conjunction with the QBX /Es option if your program code
  4259.  or a loaded Quick library manages expanded memory. (See "Competing Use
  4260.  of Expanded Memory" later in this chapter.)
  4261.  
  4262.  Several other options affect how ISAM handles buffers. For complete
  4263.  documentation on how to configure and install ISAM, as well as how the
  4264.  number of buffers affects programs, see Chapter 10, "Database
  4265.  Programming with ISAM," in the  Programmer's Guide.
  4266.  
  4267.  
  4268.  Considerations for QBX
  4269.  
  4270.  The QBX environment and ISAM together require 450K to run (QBX itself
  4271.  requires over 300K). If you have 640K of conventional memory, QBX will
  4272.  support a moderate-sized program without trouble, but large programs may
  4273.  require the use of extended or expanded memory, especially if you use
  4274.  ISAM.
  4275.  
  4276.  
  4277.  Using the /NOFRILLS Option
  4278.  
  4279.  You can use the /NOFRILLS option (abbreviated as /NOF) to make
  4280.  additional memory available for program use. However, using /NOFRILLS
  4281.  reduces the functionality of the QBX environment.
  4282.  
  4283.  When you start QBX and use the /NOF command-line option, QBX uses
  4284.  about 19K less memory but does not support any of the following
  4285.  menus:
  4286.  
  4287.    ■   Utility menu
  4288.    ■   Options menu
  4289.    ■   Help menu
  4290.  
  4291.  
  4292.  The /NOF option does not change the structure of the menu bar or
  4293.  status line, but the three menus are unavailable and cannot be
  4294.  opened.
  4295.  
  4296.  
  4297.  Extended Memory
  4298.  
  4299.  QBX uses extended memory by moving approximately 60K of its own
  4300.  executable code out of conventional memory. All the code removed
  4301.  represents space freed for use by your programs.
  4302.  
  4303.  When using the HIMEM.SYS device driver, you should set  tsrmin
  4304.  to 63 (64,512 bytes) to ensure that QBX has access to the high-memory
  4305.  area. The  handles field has no effect on QBX, since these
  4306.  handles give access to addresses higher than the 64K area which QBX can
  4307.  use.
  4308.  
  4309.  For example, the following entry in your CONFIG.SYS file installs
  4310.  HIMEM.SYS and ensures that extended memory is available for QBX:
  4311.  
  4312.  device=C:\DEVICE\HIMEM.SYS /HMAMIN=63
  4313.  
  4314.  
  4315.  Expanded Memory
  4316.  
  4317.  When you start the QBX environment, expanded memory may have already
  4318.  been allocated to memory-resident programs, most notably ISAM. QBX uses
  4319.  as much of the the remaining expanded memory as it needs.
  4320.  
  4321.  You can limit the amount of expanded memory used by QBX by using the
  4322.  /E: command-line option:
  4323.  
  4324.  /E: emslimit
  4325.  
  4326.  In the preceding syntax,  emslimit
  4327.  determines the maximum amount of expanded memory that QBX will use, in
  4328.  kilobytes. A value of 0 disables QBX usage of expanded memory and can
  4329.  improve the execution speed of some operations.
  4330.  
  4331.  Assuming some expanded memory is available, QBX takes advantage of
  4332.  the memory in two ways:
  4333.  
  4334.    ■   QBX automatically moves each unit of program code smaller than 16K
  4335.  into expanded memory. Each procedure is a unit of code. The module-level
  4336.  code also constitutes a unit of code.
  4337.  
  4338.  To see how large each procedure is, use the View SUBs command
  4339.  (press F2). This command lists each unit of code together with size in
  4340.  kilobytes, rounded to the nearest kilobyte. You can determine which
  4341.  units are larger than 16K and should be divided into smaller units (see
  4342.  Figure 7.1). To guarantee best results, View SUBs should show sizes
  4343.  ranging from 0 to 15, inclusive.
  4344.  
  4345.    ■   If you give the /Ea command-line option, QBX moves arrays into
  4346.  expanded memory if they do not contain variable-length strings and are
  4347.  smaller than 16K. This option has a drawback: arrays residing in
  4348.  expanded memory cannot be passed to modules written in other languages
  4349.  (although you can pass array elements). Therefore, you may not want to
  4350.  use /Ea with mixed-language programs.
  4351.  
  4352.  This option affects all types of arrays except arrays of variable-
  4353.  length strings, which are not placed in expanded memory.
  4354.  
  4355.  
  4356.  The following QBX command line allows 500K of expanded memory to be
  4357.  used and moves arrays out of conventional memory:
  4358.  
  4359.  QBX /E:500 /Ea
  4360.  
  4361.  
  4362.  Note
  4363.  
  4364.  Once inside the QBX environment, you can determine how much expanded
  4365.  memory is actually available to QBX by executing the statement
  4366.  FRE(-3).
  4367.  
  4368.  
  4369.  Competing Use of Expanded Memory
  4370.  
  4371.  A Quick library can make use of expanded memory directly by using
  4372.  assembly code that calls the expanded-memory interrupt. However, Quick
  4373.  libraries that do this must compete with QBX for use of the memory. QBX
  4374.  will use as many 16K pages of expanded memory as required, according to
  4375.  the rules described in the previous section (assuming that the memory is
  4376.  available).
  4377.  
  4378.  In order to use expanded memory for Quick libraries, you need to keep
  4379.  two things in mind:
  4380.  
  4381.    ■   You must use the /Es command-line option when starting QBX. This
  4382.  option saves and restores the EMS state before and after every ISAM
  4383.  statement or call to a Quick library. This save-and-restore operation
  4384.  involves significant overhead, so don't use it unless you have a Quick
  4385.  library that manages expanded memory.
  4386.  
  4387.    ■   You may want to limit QBX use of expanded memory by using the /E:
  4388.  command-line option. This option is not always necessary, because QBX
  4389.  does not reserve more memory than it can use. However, the /E: option is
  4390.  useful for guaranteeing that your program always has the expanded memory
  4391.  it needs.
  4392.  
  4393.  
  4394.  The following example enables saving and restoring of the EMS state,
  4395.  and restricts the QBX environment to using at most 500K of expanded
  4396.  memory:
  4397.  
  4398.  QBX /E:500 /Es
  4399.  
  4400.  
  4401.  Considerations for Programmer's WorkBench
  4402.  
  4403.  PWB uses disk-based virtual memory for loaded source files. This
  4404.  means that the size of the program you create is limited only by the
  4405.  amount of free disk space you have and the amount of memory available
  4406.  for compiling and linking the program. It is possible, however, to run
  4407.  out of memory for PWB itself if you load a large number of PWB
  4408.  extensions or have a memory-resident program, such as PROISAM, loaded.
  4409.  
  4410.  You can make more memory available in PWB by not automatically
  4411.  loading the extension files. The /DA options disables the auto-load
  4412.  function. You can then explicitly load only the extensions you need by
  4413.  customizing your TOOLS.INI file. For more information, see the section
  4414.  "Loading PWB Extensions Explicitly" in Chapter 4.
  4415.  
  4416.  
  4417.  Considerations for CodeView
  4418.  
  4419.  When you debug a program in CodeView, three components compete for
  4420.  memory:
  4421.  
  4422.    ■   The program being debugged
  4423.    ■   The program's symbolic information
  4424.    ■   CodeView itself
  4425.  
  4426.  
  4427.  To make the most memory available to the executable being debugged,
  4428.  CodeView automatically uses expanded memory, extended memory, or disk
  4429.  overlays. In addition, CodeView provides a utility for compressing
  4430.  program symbol information (CVPACK). For more information on CVPACK, see
  4431.  Chapter 5, "Using CodeView."
  4432.  
  4433.  
  4434.  Extended Memory
  4435.  
  4436.  If HIMEM.SYS or another extended-memory device driver is installed,
  4437.  CodeView automatically places all of the program symbol information and
  4438.  all but 16K of CodeView itself in extended memory, leaving the remaining
  4439.  conventional memory available for program execution.
  4440.  
  4441.  The /X option is not required to use extended memory with CodeView,
  4442.  but if you specify /X and an extended memory driver is not installed,
  4443.  CodeView displays an error.
  4444.  
  4445.  
  4446.  Expanded Memory
  4447.  
  4448.  If extended memory is not available and RAMDRIVE.SYS. SMARTDRV.SYS,
  4449.  or a compatible expanded memory manager is installed, CodeView uses
  4450.  available expanded memory for program symbol information and for
  4451.  CodeView overlays.
  4452.  
  4453.  In order for CodeView to use expanded memory, no single module's
  4454.  symbol information can exceed 48K. If symbol information exceeds this
  4455.  limit, try reducing filename information by not specifying paths when
  4456.  you compile and using /Zd instead of /Zi.
  4457.  
  4458.  The /E option is not required to use expanded memory with CodeView,
  4459.  but if you specify /E and an expanded memory driver is not installed,
  4460.  CodeView displays an error.
  4461.  
  4462.  
  4463.  Overlays
  4464.  
  4465.  If extended or expanded memory are not available, CodeView uses 64K
  4466.  disk overlays for its executable. You can use the /Dbuffersize
  4467.   option to improve performance by reducing the size of the overlay,
  4468.  making more memory available, or increasing the size of the overlay.
  4469.  
  4470.  CodeView will not use overlays smaller than 16K nor larger than 128K.
  4471.  Therefore, the minimum effective value for  buffersize
  4472.   is 16 and the maximum is 128.
  4473.  
  4474.