home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft_Programmers_Library.7z / MPL / msc / pdsinst.txt < prev    next >
Encoding:
Text File  |  2013-11-08  |  120.9 KB  |  2,996 lines

  1.  Microsoft  C - Installing and Using the Professional Development System
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  ────────────────────────────────────────────────────────────────────────────
  11.   Microsoft (R) C - Installing and Using the Professional Development System
  12.  
  13.                         FOR MS (R) OS/2 AND MS-DOS (R)
  14.                               OPERATING SYSTEMS
  15.  ────────────────────────────────────────────────────────────────────────────
  16.  
  17.  
  18.                             MICROSOFT CORPORATION
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  Information in this document is subject to change without notice and does
  28.  not represent a commitment on the part of Microsoft Corporation. The
  29.  software described in this document is furnished under a license agreement
  30.  or nondisclosure agreement. The software may be used or copied only in
  31.  accordance with the terms of the agreement. It is against the law to copy
  32.  the software on any medium except as specifically allowed in the license or
  33.  nondisclosure agreement. No part of this manual may be reproduced or
  34.  transmitted in any form or by any means, electronic or mechanical, including
  35.  photocopying and recording, for any purpose without the express written
  36.  permission of Microsoft.
  37.  (C) Copyright Microsoft Corporation, 1990. All rights reserved.
  38.  
  39.  
  40.  Printed and bound in the United States of America.
  41.  
  42.  
  43.  Microsoft, MS, MS-DOS, and CodeView are registered trademarks
  44.  and Windows is a trademark of Microsoft Corporation.
  45.  
  46.  386-Max is a trademark of Qualitas, Inc.
  47.  
  48.  BRIEF is a registered trademark of UnderWare, Inc.
  49.  
  50.  IBM is a registered trademark of International Business
  51.  Machines Corporation.
  52.  
  53.  UNIX is a registered trademark of American Telephone
  54.  and Telegraph Company.
  55.  
  56.  
  57.  
  58.  Document No.  LN06516-1189 OEMO711-6Z
  59.  
  60.  10
  61.   9
  62.   8
  63.   7
  64.   6
  65.   5
  66.   4
  67.   3
  68.   2
  69.   1
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  Chapter 1  The Microsoft(R) C Professional Development System
  80.  
  81.       Before You Proceed
  82.              System Requirements
  83.              Package Contents
  84.       Features New to Version 6.0
  85.       Why Microsoft Programmer's WorkBench?
  86.  
  87.  Chapter 2  Installing Microsoft C
  88.  
  89.       Running SETUP
  90.              Supplying SETUP Information
  91.              Correcting Mistakes
  92.              First Screen: Installing Libraries
  93.              Second Screen: Installing Additional Files
  94.              Third Screen: Specifying Directories
  95.              Checking Available Disk Space
  96.              SETUP Options
  97.              Configuring Your System
  98.              Choosing a Target Operating Environment
  99.       Configuring Extended Memory for CodeView
  100.       Customizing Microsoft C
  101.  
  102.  Chapter 3  Using the Programmer's WorkBench
  103.  
  104.       Starting PWB
  105.              Specifying a Source File
  106.              Command-Line Options
  107.       Using Windows and Menus
  108.              Windows
  109.              Menus
  110.              Dialog Boxes
  111.              Getting Help
  112.       Using the Editor
  113.              Moving Around in a Source File
  114.              Customizing the Editor
  115.       Compiling and Linking
  116.              Building Programs in PWB
  117.              Compiling and Linking from the Command Line
  118.       Debugging Programs
  119.              Using the Browser
  120.              Debugging with CodeView
  121.              Running IO.C
  122.              Debugging IO.C
  123.       Getting More Details
  124.  
  125.  Chapter 4  Using the On-Line Reference
  126.  
  127.       Structure of the Microsoft Advisor
  128.       Navigating Through the Microsoft Advisor
  129.              Using the Help Menu
  130.              Using the F1 Key
  131.              Using Hyperlinks
  132.              Using Help Windows and Dialog Boxes
  133.              Accessing Different Types of Information
  134.              Specifying Temporary Help Files
  135.       Using QuickHelp
  136.              Using the /HELP Switch
  137.              Using the QH Command
  138.  
  139.  
  140.  
  141.  Chapter 1  The Microsoft(R) C Professional Development System
  142.  ────────────────────────────────────────────────────────────────────────────
  143.  
  144.  The Microsoft C Professional Development System is a collection of tools
  145.  designed to increase DOS and OS/2 programming efficiency. The system offers
  146.  
  147.  
  148.  
  149.    ■   A customizable editor that is capable of being extended
  150.  
  151.    ■   An optimizing and incremental compiler
  152.  
  153.    ■   An intelligent linker
  154.  
  155.    ■   A project-oriented Make utility
  156.  
  157.    ■   A source-level browser
  158.  
  159.    ■   A complete on-line reference system
  160.  
  161.    ■   A source-level, window-oriented debugger
  162.  
  163.  
  164.  The Programmer's WorkBench (PWB) integrates these tools, creating an
  165.  environment in which you can edit, compile, link, and debug your programs.
  166.  
  167.  This book is a general introduction to the Microsoft C Professional
  168.  Development System. This chapter introduces some of the features of the
  169.  Professional Development System. Chapter 2 describes how to install the
  170.  Professional Development System. Chapter 3 introduces the Programmer's
  171.  WorkBench. Chapter 4 shows how to use the on-line reference system─a
  172.  complete reference to the Professional Development System and the C
  173.  language, which is available both within PWB and at the OS/2 and DOS command
  174.  lines.
  175.  
  176.  ────────────────────────────────────────────────────────────────────────────
  177.  NOTE
  178.  
  179.  Microsoft documentation uses the term "OS/2" to refer to the OS/2 systems─
  180.  Microsoft Operating System/2 (MS(R) OS/2) and IBM(R)  OS/2. Similarly, the
  181.  term "DOS" refers to both the MS-DOS(R) and IBM Personal Computer DOS
  182.  operating systems. The name of a specific operating system is used when it
  183.  is necessary to note features that are unique to the system.
  184.  ────────────────────────────────────────────────────────────────────────────
  185.  
  186.  If you'd like further information about a topic as you read through this
  187.  book, you can consult
  188.  
  189.  
  190.    ■   Advanced Programming Techniques
  191.  
  192.    ■   The C Reference guide
  193.  
  194.    ■   The on-line reference system (as discussed in Chapter 4)
  195.  
  196.  
  197.  All of these sources are included in the Microsoft C package; they present
  198.  detailed information about the various components of the Professional
  199.  Development System.
  200.  
  201.  
  202.  Before You Proceed
  203.  
  204.  Before installing Microsoft C, take a few minutes to make sure your computer
  205.  meets minimum system requirements and that your package is complete.
  206.  
  207.  
  208.  System Requirements
  209.  
  210.  Microsoft C requires the following configuration:
  211.  
  212.  
  213.    ■   An IBM Personal Computer or 100% compatible running DOS version 3.0 or
  214.        later or OS/2 version 1.1 or later.
  215.  
  216.    ■   An 8088 processor (a minimum of an 8 megahertz, 80286 processor is
  217.        recommended).
  218.  
  219.    ■   512K (kilobytes) of available memory (RAM) for operating under DOS (1
  220.        megabyte of RAM is recommended).
  221.  
  222.    ■   3 megabytes of RAM for operating under OS/2 (4 megabytes of RAM are
  223.        recommended).
  224.  
  225.    ■   At least 384K of extended memory if you want to debug large DOS
  226.        programs.
  227.  
  228.    ■   One hard-disk drive with a minimum of 8 megabytes of free space.
  229.        (Depending on the options you want, you may need up to 20 megabytes of
  230.        disk space.)
  231.  
  232.    ■   One 1.2 megabyte, 5.25-inch floppy disk drive or one 720K, 3.5-inch
  233.        floppy disk drive.
  234.  
  235.  
  236.  Programs compiled with Microsoft C version 6.0 support DOS versions 2.1 and
  237.  later.
  238.  
  239.  
  240.  Package Contents
  241.  
  242.  Check your Microsoft C package to see if everything is there. If any pieces
  243.  are missing, contact the retailer from whom you purchased Microsoft C.
  244.  
  245.  In the package, you should find the following items:
  246.  
  247.  
  248.    ■   Registration card. There are many advantages to being a registered
  249.        owner of Microsoft C version 6.0, including notification of future
  250.        software releases and easy access to customer assistance. Please take
  251.        the time to fill out and mail the registration card now. (If you are
  252.        already a registered owner of an earlier version of Microsoft C, a
  253.        registration card is not included with the update.)
  254.  
  255.    ■   Disks. The distribution disk labeled "Setup/Compiler" contains a file
  256.        named PACKING.LST that lists the location and description of all disk
  257.        files in the Microsoft C package. Files on the disks are compacted and
  258.        are uncompressed with the Setup program as they are installed.
  259.        Microsoft C is distributed on 5.25-inch high density disks or 3.5-inch
  260.        disks. If you need 360K disks to install the compiler, please send in
  261.        the 3.5-inch media order card contained in the C 6.0 package or call
  262.        Microsoft Customer Service (1-800-426-9400).
  263.  
  264.    ■   Installing and Using Microsoft C. It explains how to install and use
  265.        Microsoft C.
  266.  
  267.    ■   Advanced Programming Techniques. This book discusses advanced topics
  268.        concerning Microsoft C. Part 1, "Improving Program Performance,"
  269.        examines options and methods for producing more efficient code. Part
  270.        2, "Improving Programmer Productivity," describes tools and techniques
  271.        the Professional Development System offers to help you work more
  272.        efficiently. Part 3, "Special Environments," discusses graphics,
  273.        mixed-language programming, and portability. Part 4, "OS/2 Support,"
  274.        discusses developing OS/2 applications with the Professional
  275.        Development System.
  276.  
  277.    ■   C Reference. This book includes a summary of compiler, linker, editor,
  278.        the Microsoft CodeView(R) debugger, and other tool commands; a brief
  279.        language reference; and a complete list of library functions.
  280.  
  281.    ■   Product Assistance Request. If you need to contact Microsoft Product
  282.        Support, be sure to fill out this questionnaire before calling.
  283.  
  284.    ■   Documentation Feedback Card. To help Microsoft improve its
  285.        documentation, a postage-paid survey mailer is included. Please take
  286.        the time to fill out the card with any comments or suggestions.
  287.  
  288.  
  289.  
  290.  Features New to Version 6.0
  291.  
  292.  If you've used an earlier version of Microsoft C, you'll find many new
  293.  capabilities in version 6.0, and you'll discover that you can perform
  294.  familiar operations more quickly:
  295.  
  296.  
  297.    ■   Speed up development with the integrated PWB environment, including a
  298.        fast-turnaround incremental compiler and linker.
  299.  
  300.    ■   Increase program efficiency with global optimization and smaller
  301.        run-time libraries.
  302.  
  303.    ■   Build programs more easily with the new Make facility (NMAKE) and
  304.        PWB's powerful project capabilities.
  305.  
  306.    ■   Insert assembly code directly into your C source code with the
  307.        integrated in-line assembler.
  308.  
  309.    ■   Track down program bugs and logic errors more quickly with the new
  310.        Microsoft CodeView debugger version 3.0. With an 80286 or 80386
  311.        processor and 1 megabyte or more of RAM, you can debug a program of
  312.        any size in real mode.
  313.  
  314.    ■   Access all C run-time, language, compiler, linker, and utility
  315.        documentation with the Microsoft Advisor and QuickHelp on-line
  316.        reference systems.
  317.  
  318.    ■   Cross-reference program functions and variables with the PWB Source
  319.        Browser.
  320.  
  321.    ■   Create OS/2 applications with increased support for dynamic-link
  322.        libraries (DLLs), multiple threads, and improved debugging options.
  323.  
  324.    ■   Use based pointers to control placement of data in segments and
  325.        generate better code for far-pointer manipulation.
  326.  
  327.    ■   Pass function parameters more efficiently with the _fastcall calling
  328.        convention.
  329.  
  330.    ■   Edit source code with PWB's mouse- and window-oriented editor, which
  331.        has all the functionality of the Microsoft Editor.
  332.  
  333.  
  334.  
  335.  Why Microsoft Programmer's WorkBench?
  336.  
  337.  The Programmer's WorkBench offers a wide array of features that can cut
  338.  development time and increase your productivity.
  339.  
  340.  One feature that sets PWB apart from other development systems is its fully
  341.  integrated, mouse- and window-based development environment. Most operations
  342.  can be performed with menu selections or single keyboard commands. You never
  343.  need to leave PWB to edit, build, debug, and run a program.
  344.  
  345.  PWB is built around the Microsoft Editor. The editor is completely
  346.  extensible and can easily be configured to meet your personal needs. The
  347.  editor combines advanced features such as macros and regular-expression
  348.  search capabilities with the simplicity of a window-based application (see
  349.  Figure 1.1).
  350.  
  351.  (This figure may be found in the printed book).
  352.  
  353.  As you develop your program, you can find information in the Microsoft
  354.  Advisor on-line reference system instead of paging through manuals. A menu
  355.  command provides complete information on the C language and run-time
  356.  libraries. The Microsoft Advisor also supplies details on PWB, the compiler,
  357.  linker, CodeView, and even the reference system itself. Figure 1.2 shows
  358.  summary information on printf.
  359.  
  360.  (This figure may be found in the printed book).
  361.  
  362.  When you're ready to compile the program, you don't need to remember the
  363.  full range of command-line compiler options. All of the options are
  364.  conveniently available in a PWB dialog box and can be clicked on or off (see
  365.  Figure 1.3). Setting options is simply a matter of using the mouse or
  366.  keyboard to select compiler, linker, NMAKE, and CodeView switches.
  367.  
  368.  PWB uses the powerful NMAKE tool to speed up development. NMAKE examines
  369.  each module of a program to determine whether changes have been made that
  370.  require the module to be recompiled. NMAKE then automatically compiles the
  371.  modules as necessary and links them. When you're ready to build your
  372.  program, you just select a single menu command to start the process. PWB
  373.  invokes NMAKE and builds an application, using the options you set.
  374.  
  375.  If any errors are encountered, PWB displays an error window with a full
  376.  listing of the compile and link errors (see Figure 1.4). The editor
  377.  indicates the source line containing the error, and you can use the on-line
  378.  reference system to provide comprehensive information about each error.
  379.  
  380.  (This figure may be found in the printed book).
  381.  
  382.  (This figure may be found in the printed book).
  383.  
  384.  Once a program has been successfully built, you can run it from within PWB
  385.  to test it. If you need to make modifications, you can interrupt the program
  386.  and return directly to PWB to make the changes.
  387.  
  388.  Another useful PWB feature is the Source Browser. With the Browser you can
  389.  examine your code and display information about function and variable
  390.  relationships (see Figure 1.5). This option is helpful in tracking program
  391.  flow and isolating bugs.
  392.  
  393.  (This figure may be found in the printed book).
  394.  
  395.  For bugs that are more difficult to locate and understand, use PWB's Debug
  396.  Build option, and invoke the CodeView debugger directly from PWB. Then you
  397.  can step and trace through your code at the source level and examine
  398.  variables, registers, and memory (see Figure 1.6).
  399.  
  400.  Once you locate the bug you can exit CodeView and return directly to PWB,
  401.  where you can fix the problem. When the code is completely debugged, a final
  402.  release program can be built by using PWB's Release Build option.
  403.  
  404.  (This figure may be found in the printed book).
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  Chapter 2  Installing Microsoft C
  412.  ────────────────────────────────────────────────────────────────────────────
  413.  
  414.  This chapter describes how to install Microsoft C on your system, configure
  415.  extended memory for use with CodeView, and customize components of
  416.  Microsoft C.
  417.  
  418.  Files on the disks are compressed; SETUP.EXE is provided for installing
  419.  Microsoft C under DOS and OS/2 operating environments. SETUP uncompresses
  420.  and copies a variety of files─the compiler, the linker, the Programmer's
  421.  WorkBench (PWB), the library manager, libraries, the help system, and
  422.  others─from the distribution disks to your hard disk. SETUP also can build
  423.  combined libraries from component libraries such as math libraries,
  424.  memory-model-specific base libraries, and graphics libraries; and can build
  425.  additional libraries as needed.
  426.  
  427.  Before you run the SETUP utility, back up the distribution disks and make
  428.  sure you have enough disk space (between 5 and 10 megabytes, depending on
  429.  which options you select) to install the Professional Development System.
  430.  Then read the first part of the README.DOC file to see whether it has any
  431.  information concerning the installation process.
  432.  
  433.  ────────────────────────────────────────────────────────────────────────────
  434.  NOTE
  435.  
  436.  If you are installing Microsoft C from 3.5-inch disks, SETUP.EXE is found on
  437.  the disk labeled "Setup." If you are using 5.25-inch disks, SETUP is on the
  438.  disk labeled "Setup and Compiler."
  439.  
  440.  ────────────────────────────────────────────────────────────────────────────
  441.  
  442.  
  443.  Running SETUP
  444.  
  445.  Insert the disk containing the SETUP program in drive A, make that drive the
  446.  current drive, then run SETUP.EXE. The program first displays a screen
  447.  reminding you to read the documentation before installing Microsoft C (see
  448.  Figure 2.1). This initial screen also points out that the default answers to
  449.  SETUP's questions are usually good when you first install Microsoft C. Press
  450.  ENTER to proceed.
  451.  
  452.  (This figure may be found in the printed book).
  453.  
  454.  
  455.  Supplying SETUP Information
  456.  
  457.  Before SETUP can install Microsoft C, it needs information about your system
  458.  and the type of programming you intend to do. This first stage of SETUP is a
  459.  series of questions divided among three screens. Default answers to the
  460.  questions appear in brackets; you can press ENTER to accept the defaults, or
  461.  you can type in your own answers to override the defaults. Detailed
  462.  information on the questions appears at the bottom of each screen. Each
  463.  screen concludes by asking if you want to change any of your choices. Press
  464.  N and then ENTER to move to the next screen.
  465.  
  466.  ────────────────────────────────────────────────────────────────────────────
  467.  NOTE
  468.  
  469.  The questions that are displayed on your screen may differ slightly from the
  470.  questions that are shown in this chapter. For example, if DOS is specified
  471.  as the host operating mode, later questions will refer to DOS.
  472.  ────────────────────────────────────────────────────────────────────────────
  473.  
  474.  
  475.  Correcting Mistakes
  476.  
  477.  If you want to change any of your choices, press Y. The questions will be
  478.  repeated, but the choices you previously made become the default answers.
  479.  
  480.  To exit the SETUP program at any time without saving default answers, press
  481.  CTRL+C.
  482.  
  483.  ────────────────────────────────────────────────────────────────────────────
  484.  NOTE
  485.  
  486.  The SETUP program doesn't erase any files from the distribution disks. If
  487.  you make a mistake during the setup process, just run SETUP again.
  488.  ────────────────────────────────────────────────────────────────────────────
  489.  
  490.  
  491.  First Screen: Installing Libraries
  492.  
  493.  On the first SETUP screen (see Figure 2.2), you supply information SETUP
  494.  uses to build run-time library files on your hard disk.
  495.  
  496.  (This figure may be found in the printed book).
  497.  
  498.  
  499.  Selecting the Operating Mode
  500.  
  501.  Microsoft C can run under both OS/2 and DOS, and it can create executable
  502.  files for either environment. Select the host operating mode under which
  503.  your computer will usually run. Applications intended for OS/2 and DOS use
  504.  different libraries. Specify the target operating mode for which you will
  505.  most frequently be developing executable files. Both modes may optionally be
  506.  selected.
  507.  
  508.  
  509.  Building Combined Libraries
  510.  
  511.  SETUP can create combined libraries for the memory model, math options, and
  512.  operating modes you specify. Combined libraries reduce the amount of time
  513.  required for linking.
  514.  
  515.  The component libraries can be left on your hard disk after combined
  516.  libraries are built. However, you should delete them to free disk space
  517.  unless you plan to build additional combined libraries in the near future.
  518.  
  519.  You have the option of including the graphics libraries GRAPHICS.LIB and
  520.  PGCHART.LIB in your combined libraries. GRAPHICS.LIB contains numerous
  521.  functions for drawing lines, rectangles, circles, and other shapes.
  522.  PGCHART.LIB contains functions for creating presentation-quality,
  523.  high-resolution graphs. (Under OS/2 protected mode, you also have the option
  524.  of including another library, GRTEXTP.LIB, in your combined library. This
  525.  library provides support for OS/2 text-mode functions.) If you choose not to
  526.  include these libraries in the combined libraries, they will be copied onto
  527.  your disk as separate libraries. If you then use routines from these
  528.  libraries, you will need to explicitly specify the libraries when you link.
  529.  
  530.  
  531.  The first time you install Microsoft C, you should create only one or two
  532.  combined libraries. If you need other memory models, math packages, or
  533.  operating modes, rerun the SETUP program with the /L option.
  534.  
  535.  
  536.  Choosing Math Options
  537.  
  538.  The math options you choose determine which math component libraries are
  539.  included in your combined libraries. The default provided by SETUP depends
  540.  on whether it detects a math coprocessor.
  541.  
  542.  Programs that use the 8087 library run only on a machine equipped with a
  543.  math coprocessor. The 80x87 option generates applications that perform fast
  544.  floating-point math.
  545.  
  546.  Programs linked with the emulator library will run on any computer, whether
  547.  or not it has a coprocessor. If the computer has a coprocessor, the emulator
  548.  library uses the coprocessor to perform all floating-point math operations.
  549.  Otherwise, the library emulates a coprocessor.
  550.  
  551.  The alternate math library uses an alternate number representation; when a
  552.  coprocessor is not present, programs using this library run faster than
  553.  programs using the emulator. (Even if a coprocessor is installed, the
  554.  alternate math library routines will not use it.) Selecting the alternate
  555.  math library sacrifices some accuracy for increased execution speed and
  556.  decreased program size.
  557.  
  558.  ────────────────────────────────────────────────────────────────────────────
  559.  NOTE
  560.  
  561.  You may include all math libraries in your libraries, but doing so triples
  562.  the number of combined libraries SETUP builds, thus tripling installation
  563.  time and increasing storage requirements. If you intend to install all
  564.  possible library configurations, you'll need approximately 6 megabytes of
  565.  free space on your hard disk just for libraries. If you install just one
  566.  library, you'll need about 3.3 megabytes.
  567.  ────────────────────────────────────────────────────────────────────────────
  568.  
  569.  For more information on math options, see Chapter 4, "Controlling
  570.  Floating-Point Math Operations," in Advanced Programming Techniques.
  571.  
  572.  
  573.  Choosing Memory Models
  574.  
  575.  Microsoft C supports six standard memory models. Table 2.1 illustrates the
  576.  relationship between the available memory models and the limits placed on
  577.  their code and data segments.
  578.  
  579.  Table 2.1  Memory Models
  580.  
  581. ╓┌─────────────┌───────────────────┌─────────────────────────────────────────╖
  582.  Memory Model  Code Segment Limit  Data Segment Limit
  583.  ────────────────────────────────────────────────────────────────────────────
  584.  Tiny          64K                 64K (CODE + DATA)
  585.  
  586.  Small         64K                 64K
  587.  
  588.  Medium        None                64K
  589.  
  590.  Memory Model  Code Segment Limit  Data Segment Limit
  591.  ────────────────────────────────────────────────────────────────────────────
  592. 
  593.  Compact       64K                 None
  594.  
  595.  Large         None                None
  596.  
  597.  Huge          None                None
  598.  
  599.  ────────────────────────────────────────────────────────────────────────────
  600.  
  601.  
  602.  
  603.  For more information on memory models, see Chapter 2, "Managing Memory," in
  604.  Advanced Programming Techniques.
  605.  
  606.  
  607.  Specifying Default Library Names
  608.  
  609.  SETUP normally gives each combined library a name of the form mLIBCfs.LIB,
  610.  where m is S, M ,C, or L (memory model); f is A, E, or 7 (math library); and
  611.  s is R or P (operating mode).
  612.  
  613.  This question will vary according to the target operating system you
  614.  selected. If you chose OS/2, you will be asked whether to use the default
  615.  OS/2 library names. If you selected both operating modes, you will be asked
  616.  whether to use the default libraries for OS/2 and DOS.
  617.  
  618.  If you selected only one operating mode, or if you selected both but plan to
  619.  program in one mode predominantly, you should have SETUP give default names
  620.  to all libraries built for that mode.
  621.  
  622.  
  623.  Second Screen: Installing Additional Files
  624.  
  625.  Your answers to questions on this screen determine whether PWB is installed
  626.  (see Figure 2.3).
  627.  
  628.  (This figure may be found in the printed book).
  629.  
  630.  
  631.  Installing PWB
  632.  
  633.  You may choose not to install PWB if you plan to use only the command-line
  634.  version of the compiler and linker. If you install PWB, you can choose to
  635.  configure the PWB editor so that it is similar to the BRIEF(R) editor.
  636.  
  637.  
  638.  Installing the Microsoft Mouse
  639.  
  640.  If you have chosen OS/2 real mode and DOS as the host operating mode, you
  641.  are asked whether you want to install the most recent version of the
  642.  Microsoft Mouse device driver.
  643.  
  644.  
  645.  Copying Patch Files
  646.  
  647.  If you have chosen OS/2 real mode and DOS as the host operating mode, you
  648.  have the option of installing a patch for dealing with floating-point
  649.  exceptions found under PC-DOS version 3.20.
  650.  
  651.  
  652.  Third Screen: Specifying Directories
  653.  
  654.  On this screen, you specify the directories into which SETUP copies library,
  655.  header, and other files (see Figure 2.4). You can choose to override the
  656.  default options for directory names. Be sure to enter complete path names
  657.  for your own directories. If the specified directories don't exist, SETUP
  658.  asks whether you want to create them.
  659.  
  660.  (This figure may be found in the printed book).
  661.  
  662.  The questions about protected-mode executable files and dynamic link
  663.  libraries appear only if OS/2 protected mode has been selected as the target
  664.  operating mode.
  665.  
  666.  ────────────────────────────────────────────────────────────────────────────
  667.  NOTE
  668.  
  669.  The questions about executable files concern the location of development
  670.  tools, not the executable files you create with Microsoft C.
  671.  ────────────────────────────────────────────────────────────────────────────
  672.  
  673.  
  674.  Checking Available Disk Space
  675.  
  676.  Before moving to stage two, SETUP checks your hard disk to see how much free
  677.  space is available. If you don't have enough room to install Microsoft C, an
  678.  error message informs you how much space is required for the files you've
  679.  requested.
  680.  
  681.  If you don't have enough room on your hard disk, you can either delete
  682.  existing hard-disk files or reduce the number of requested libraries.
  683.  
  684.  ────────────────────────────────────────────────────────────────────────────
  685.  NOTE
  686.  
  687.  If you feel that SETUP has incorrectly sized your disk for some reason, you
  688.  can disable space checking by using the /NOFREE option.
  689.  ────────────────────────────────────────────────────────────────────────────
  690.  
  691.  
  692.  SETUP Options
  693.  
  694.  SETUP has several options: /?, /COPY, /HELP, /LIB, /NOFREE, and /NOHELP.
  695.  With the exception of /? and /HELP, you should not use any of the options
  696.  the first time you run SETUP. The /? and /HELP options (see Figure 2.5)
  697.  present information about the options.
  698.  
  699.  (This figure may be found in the printed book).
  700.  
  701.  The /COPY option uncompresses and copies individual files from the
  702.  distribution disks. The /LIB option builds additional combined libraries
  703.  after you have already installed Microsoft C, without going through the
  704.  entire setup process. /NOFREE instructs SETUP not to check for available
  705.  free disk space before uncompressing and copying files. The /NOHELP option
  706.  suppresses the SETUP help information displayed at the bottom of the screen.
  707.  
  708.  
  709.  
  710.  Configuring Your System
  711.  
  712.  When SETUP has finished creating the combined libraries and placing them in
  713.  the directories you specified, it creates files that are used for
  714.  configuring your system.
  715.  
  716.  If you selected OS/2 real mode or DOS as the host environment, SETUP creates
  717.  three files: NEW-VARS.BAT, NEW-CONF.SYS, and TOOLS.PRE. The files
  718.  NEW-VARS.BAT and NEW-CONF.SYS are placed in the directory C:\C600\BIN; the
  719.  file TOOLS.PRE is placed in the directory C:\C600\INIT. (These are the
  720.  default directory names. If you have overridden them with your own choices,
  721.  SETUP places these files in the directories you specified.)
  722.  
  723.  If you selected OS/2 protected mode as the host environment, SETUP creates
  724.  two files: NEW-VARS.CMD and TOOLS.PRE. The file NEW-VARS.CMD is placed in
  725.  the directory C:\C600\BINP; the file TOOLS.PRE is placed in the directory
  726.  C:\C600\INIT. (These are the default directory names. If you have overridden
  727.  them with your own choices, SETUP places these files in the directories you
  728.  specified.)
  729.  
  730.  To permanently configure your system for Microsoft C, you must add the
  731.  respective file contents to your AUTOEXEC.BAT (or STARTUP.CMD), CONFIG.SYS,
  732.  and TOOLS.INI files, and reboot your system. You can, however, run
  733.  NEW-VARS.BAT or NEW-VARS.CMD to set environment variables before you use
  734.  Microsoft C.
  735.  
  736.  
  737.  Changing AUTOEXEC.BAT or STARTUP.CMD
  738.  
  739.  The NEW-VARS.BAT and NEW-VARS.CMD files contain batch file commands that set
  740.  environment variables. Insert these commands into the AUTOEXEC.BAT or
  741.  STARTUP.CMD file. Table 2.2 describes the meaning of each variable.
  742.  
  743.  Table 2.2  Environment Variables
  744.  
  745. ╓┌─────────────────────────────────┌─────────────────────────────────────────
  746.  Variable                          Description
  747.  ─────────────────────────────────────────────────────────────────────────────
  748.  PATH                              Path to search for applications
  749.  
  750.  LIB                               Location of run-time libraries
  751.  
  752.  INCLUDE                           Location of include (.H) files
  753.  
  754.  HELPFILES                         Location of help (.HLP) files
  755.  
  756.  INIT                              Location of initialization files
  757.  
  758.  Variable                          Description
  759.  ─────────────────────────────────────────────────────────────────────────────
  760. 
  761.  TEMP                              Location of PWB/LINK temporary files
  762.  
  763.  ─────────────────────────────────────────────────────────────────────────────
  764.  
  765.  
  766.  
  767.  
  768.  Modifying CONFIG.SYS
  769.  
  770.  If the host operating mode is OS/2 real mode or DOS, be sure the  files  and
  771.   buffer  values in CONFIG.SYS are large enough for Microsoft C. The values
  772.  in NEW-CONF.SYS are minimums. The values in CONFIG.SYS should be greater
  773.  than or equal to these amounts. Additionally, with OS/2, make sure the
  774.  LIBPATH=  line of the CONFIG.SYS file specifies the location of the file
  775.  MSHELP.DLL. OS/2 users who want to use the CodeView debugger must also
  776.  include the statement  IOPL=YES.
  777.  
  778.  To use the extended memory features of CodeView under DOS, set
  779.  DEVICE=HIMEM.SYS  (with HIMEM's fully qualified path name). See the section
  780.  in this chapter titled "Configuring Extended Memory for CodeView" for
  781.  additional information on running CodeView with extended memory in a DOS
  782.  environment.
  783.  
  784.  
  785.  Modifying TOOLS.INI
  786.  
  787.  SETUP creates a file called TOOLS.PRE. This file contains various PWB
  788.  settings, such as those that specify libraries. You should add the contents
  789.  of the TOOLS.PRE file to your existing TOOLS.INI file; if TOOLS.INI does not
  790.  exist, you should rename TOOLS.PRE to TOOLS.INI.
  791.  
  792.  The TOOLS.INI file contains many configuration options, which help you
  793.  customize the following utilities in Microsoft C:
  794.  
  795.  
  796.    ■   PWB
  797.  
  798.    ■   The CodeView debugger
  799.  
  800.    ■   The Microsoft Advisor help system
  801.  
  802.    ■   The NMAKE utility
  803.  
  804.  
  805.  You can use the PWB editor or a word processor to change the settings in the
  806.  TOOLS.INI file. These are some of the options you can change:
  807.  
  808.  
  809.    ■   The colors and the number of lines displayed by CodeView and PWB
  810.  
  811.    ■   Macros for PWB
  812.  
  813.    ■   Key assignments for PWB
  814.  
  815.    ■   Default key settings for PWB
  816.  
  817.    ■   The location of help files used by the Microsoft Advisor
  818.  
  819.    ■   Options for NMAKE
  820.  
  821.  
  822.  A complete table of TOOLS.INI settings is available in on-line help and the
  823.  C Reference.
  824.  
  825.  
  826.  Choosing a Target Operating Environment
  827.  
  828.  In many cases you will program primarily for either the OS/2 protected mode
  829.  or the DOS 3.x - OS/2 real mode and use one combined library. Allowing SETUP
  830.  to make either DOS or OS/2 the default environment is the easiest method,
  831.  but you can also manually choose a target environment.
  832.  
  833.  
  834.  Choosing Defaults for a Single Mode
  835.  
  836.  Start by deciding which operating mode will be the default environment. Then
  837.  give the combined library for that mode the default combined-library name.
  838.  The composition of library names is explained in the section "Specifying
  839.  Default Library Names."
  840.  
  841.  For example, the following steps will create a protected-mode executable
  842.  file using the small memory model and the emulation floating-point library:
  843.  
  844.  
  845.  
  846.    1.  Use SETUP to create SLIBCEP.LIB, the combined library for the small
  847.        memory model, floating-point emulation, and protected mode.
  848.  
  849.    2.  Rename SLIBCEP.LIB as SLIBCE.LIB (the same name without P), the
  850.        default combined library name for the small memory model and
  851.        floating-point emulation library.
  852.  
  853.  
  854.  At this point you can use PWB or invoke the command-line compiler, CL,
  855.  without specifying the target operating environment for your application.
  856.  (In this example, you still need to supply the appropriate PWB or CL options
  857.  to select a memory model and floating point options.) If you don't specify a
  858.  memory-model option or floating-point option on the command line, the linker
  859.  links SLIBCE.LIB, creating an executable file that runs in OS/2 protected
  860.  mode.
  861.  
  862.  The same general procedure works for real mode, other memory models, and
  863.  floating-point libraries: Create the appropriate operating mode and combined
  864.  library, and give it the appropriate default combined-library name.
  865.  
  866.  
  867.  Selecting a Mode at Compile Time
  868.  
  869.  If you need the flexibility of programming for both operating modes, you
  870.  should use SETUP to create the combined libraries that you need for each
  871.  model. Once you have created the combined libraries, you can select a model
  872.  either by using the PWB options found in the C Compiler Options dialog box
  873.  or the CL options listed in Table 2.3.
  874.  
  875.  Table 2.3  Operating Environment Options
  876.  
  877. ╓┌───────┌───────────────────────────────────────────────────┌───────────────
  878.  Option  Environment                                         Library Selected
  879.  ─────────────────────────────────────────────────────────────────────────────
  880.  /Lp     OS/2 protected mode                                 mLIBCfP.LIB
  881.  
  882.  /Lr     DOS 3.x - OS/2 real mode                            mLIBCfR.LIB
  883.  
  884.  Option  Environment                                         Library Selected
  885.  ─────────────────────────────────────────────────────────────────────────────
  886. 
  887.  /Lc     DOS 3.x (synonym for /Lr)                           mLIBCfR.LIB
  888.  
  889.  ─────────────────────────────────────────────────────────────────────────────
  890.  
  891.  
  892.  
  893.  Using these options causes CL to substitute one of these library names for
  894.  the default combined-library name in the object module's library-search
  895.  record.
  896.  
  897.  These options automatically set the /NODEFAULTLIBRARYSEARCH linker option,
  898.  which overrides the default library (the syntax is /NOD:libraryname). For
  899.  example, if you are programming for the OS/2 protected mode with the small
  900.  memory model and floating-point emulation, and you supply the /Lp option for
  901.  CL, the compiler passes the following option to the linker:
  902.  
  903.    /NOD:slibce slibcep
  904.  
  905.  
  906.  Configuring Extended Memory for CodeView
  907.  
  908.  Extended memory refers to memory at physical addresses above 1 megabyte that
  909.  can be accessed by an 80x86 CPU in protected mode.
  910.  
  911.  As previously mentioned, in order to use the extended memory features of
  912.  CodeView under a DOS environment, you must set  DEVICE=HIMEM.SYS  (with
  913.  HIMEM's fully qualified path name) in the CONFIG.SYS file. A sample entry of
  914.  how to implement HIMEM is found in the NEW-CONF.SYS file that SETUP creates.
  915.  
  916.  
  917.  ────────────────────────────────────────────────────────────────────────────
  918.  NOTE
  919.  
  920.  HIMEM.SYS is an implementation of the XMS 2.x standard. The complete XMS
  921.  source and specification are available from the Microsoft Information
  922.  Center; call 1-800-426-9400.
  923.  ────────────────────────────────────────────────────────────────────────────
  924.  
  925.  In addition, there are several factors to consider when using CodeView under
  926.  DOS with extended memory:
  927.  
  928.  
  929.    ■   At least 384K of extended memory should be set aside for use with
  930.        HIMEM.SYS.
  931.  
  932.    ■   Other memory managers such as 386-Max(tm) or QEMM may not work in
  933.        conjunction with HIMEM.SYS. You should use only one memory manager.
  934.  
  935.    ■   Older versions of HIMEM.SYS may present problems. Use the most recent
  936.        version included on the distribution disks.
  937.  
  938.    ■   Many RAM disk (VDISK) and disk cache programs are incompatible with
  939.        HIMEM.SYS. The HIMEM.SYS compatible RAMDRIVE RAM disk and SMARTDRV
  940.        disk cache programs are provided on the distribution disks. If you are
  941.        operating under Microsoft Windows(tm) , the SMARTDRV application
  942.        shipped with the Professional Development System is incompatible with
  943.        Windows 2.11, and is compatible only with Windows 3.0.
  944.  
  945.    ■   Check the documentation of installed terminate-and-stay-resident (TSR)
  946.        programs to see if they are compatible with HIMEM/XMS 2.x. You can
  947.        incrementally install each TSR until you find a potential offender.
  948.  
  949.  
  950.  If you choose to install the HIMEM, RAMDRIVE, and SMARTDRV files, SETUP
  951.  places them in the C:\C600\BIN directory.
  952.  
  953.  ────────────────────────────────────────────────────────────────────────────
  954.  NOTE
  955.  
  956.  Extended memory should not be confused with expanded memory. Expanded memory
  957.  refers to bank-switched memory that overcomes the 640K RAM limitation found
  958.  in the 8088 processor.
  959.  ────────────────────────────────────────────────────────────────────────────
  960.  
  961.  
  962.  Customizing Microsoft C
  963.  
  964.  In addition to modifying the TOOLS.INI file, Microsoft C can be customized
  965.  in other ways. For example, a variety of editor functions and options can be
  966.  set within PWB by using the Editor Settings command on the Options menu.
  967.  
  968.  For more information about customizing PWB, refer to Chapter 3 or see
  969.  Chapter 8, "Customizing the Microsoft Programmer's WorkBench," in Advanced
  970.  Programming Techniques. More information about customizing NMAKE and other
  971.  utilities can also be found in Advanced Programming Techniques.
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  Chapter 3  Using the Programmer's WorkBench
  979.  ────────────────────────────────────────────────────────────────────────────
  980.  
  981.  This chapter introduces the Programmer's WorkBench (PWB)─a powerful
  982.  integrated tool designed to make writing and debugging programs easier. PWB
  983.  is a window-oriented programming environment that incorporates a text
  984.  editor, a compiler, a linker, a debugger, a Make utility, a source-code
  985.  browser, and an on-line help database. PWB provides an alternative to
  986.  switching between command-linebased programs: You can edit, compile, link
  987.  and debug from within an integrated environment. To demonstrate various
  988.  features of PWB, this chapter provides a sample program for you to compile,
  989.  link, and debug.
  990.  
  991.  This chapter explains how to start PWB and then introduces the following
  992.  elements of PWB:
  993.  
  994.  
  995.    ■   Windows and menus. You can quickly find the command you need with the
  996.        menu system. The section "Using Windows and Menus" explains how to
  997.        open and close windows and how to navigate through the menus.
  998.  
  999.    ■   Programmer's editor. Features such as "bookmarks," macros, customized
  1000.        key commands, and enhanced search capabilities decrease the amount of
  1001.        time you spend writing code.
  1002.  
  1003.    ■   Integrated compiler and linker. You can compile, link, and run a
  1004.        program without ever leaving the editor. PWB's integrated environment
  1005.        and project-management facilities save you hours of development time.
  1006.  
  1007.    ■   Integrated browser and debugger. With the Source Browser, you can
  1008.        quickly find a data declaration or function definition within your
  1009.        source code, and find references to all functions and variables in a
  1010.        multi-module program. With the CodeView debugger, you can set
  1011.        breakpoints, examine variables and machine registers, and step through
  1012.        execution of your program one line at a time.
  1013.  
  1014.  
  1015.  
  1016.  Starting PWB
  1017.  
  1018.  To run PWB for the first time, type
  1019.  
  1020.    PWB
  1021.  
  1022.  at the command line. (If errors occur, PWB displays error messages. See the
  1023.  README.DOC file for further information.)
  1024.  
  1025.  You can immediately begin writing source code in the new, untitled window
  1026.  that appears. PWB maintains a history of the files you have opened. The next
  1027.  time you run PWB, it opens the last file you worked on.
  1028.  
  1029.  
  1030.  Specifying a Source File
  1031.  
  1032.  You can open an existing source file by entering its name on the command
  1033.  line after the PWB command. If PWB can't find the specified file in the
  1034.  current directory, it asks if you want to create a new file. You can also
  1035.  open an existing source file with the Open command in the File menu.
  1036.  
  1037.  
  1038.  Command-Line Options
  1039.  
  1040.  PWB has several command-line options that you can issue when you start the
  1041.  program.
  1042.  
  1043.  Option                            Action
  1044.  ────────────────────────────────────────────────────────────────────────────
  1045.  /e string                         The string represents a series of PWB
  1046.                                    commands that will be executed at
  1047.                                    start-up.
  1048.  
  1049.  /t file                           Indicates the specified file is
  1050.                                    temporary, and should not be kept in the
  1051.                                    file history. You must precede the name
  1052.                                    of each temporary file with a /t.
  1053.  
  1054.  /D                                Prevents all PWB initialization and
  1055.                                    status files from being read at
  1056.                                    start-up.
  1057.  
  1058.  /DS                               Prevents the CURRENT.STS file from being
  1059.                                    read.
  1060.  
  1061.  /DT                               Prevents the TOOLS.INI file from being
  1062.                                    read at
  1063.                                    start-up.
  1064.  
  1065.  /r                                Turns on the global "no-edit mode,"
  1066.                                    which gives all files opened with PWB
  1067.                                    Read Only status.
  1068.  
  1069.  /m bookmark                       Positions the cursor at the file
  1070.                                    location designated by bookmark.
  1071.  
  1072.  /?                                Lists the command-line options for
  1073.                                    starting up PWB.
  1074.  
  1075.  
  1076.  Using Windows and Menus
  1077.  
  1078.  This section introduces the PWB environment and describes how to control
  1079.  windows and choose commands from the menus. Terms used to describe elements
  1080.  of the PWB environment are also presented.
  1081.  
  1082.  ────────────────────────────────────────────────────────────────────────────
  1083.  NOTE
  1084.  
  1085.  You can enter commands in PWB with the keyboard or a Microsoft (or fully
  1086.  compatible) Mouse. Unless the Right mouse button is specifically mentioned,
  1087.  "clicking" means that you press and release the Left mouse button once.
  1088.  
  1089.  ────────────────────────────────────────────────────────────────────────────
  1090.  
  1091.  
  1092.  Windows
  1093.  
  1094.  Figure 3.1 shows parts of a typical PWB screen. Some of the elements provide
  1095.  information only. For example, if CAPS LOCK is on, the letter  C  appears in
  1096.  the lower right corner of the screen; the letter  C  is informational. Other
  1097.  parts perform actions triggered by a specific keystroke or mouse action. For
  1098.  example, if you click the button in the upper left corner of a window, the
  1099.  window closes. The button is active rather than informational.
  1100.  
  1101.  (This figure may be found in the printed book).
  1102.  
  1103.  The parts of a PWB screen and their use are listed in Table 3.1 below.
  1104.  
  1105.  Table 3.1  Parts of a PWB Screen
  1106.  
  1107. ╓┌─────────────────────┌─────────────────────────────────────────────────────╖
  1108.  Name                  Use
  1109.  ────────────────────────────────────────────────────────────────────────────
  1110.  Menu bar              Lists names of available menus.
  1111.  
  1112.  Close button          Closes window (appears only if more than one window
  1113.                        is displayed).
  1114.  
  1115.  Name                  Use
  1116.  ────────────────────────────────────────────────────────────────────────────
  1117. 
  1118.  Title bar             Shows name of file currently being edited.
  1119.  
  1120.  Windows               Contain source code or display information
  1121.                        associated with on-line help.
  1122.  
  1123.  Maximize button       Enlarges or restores window to its original size.
  1124.  
  1125.  Screen number         Indicates number of help screen in the on-line help
  1126.                        database.
  1127.  
  1128.  Scroll bars           Indicate cursor position in the current file and
  1129.                        allow cursor movement.
  1130.  
  1131.  Reference bar         Lists shortcut keystrokes (keyboard users) and
  1132.                        directs PWB commands (mouse users); summar izes menu
  1133.                        contents and displays other information.
  1134.  
  1135.  File-type indicator   Indicates type of file. C: C source. text: any other
  1136.  Name                  Use
  1137.  ────────────────────────────────────────────────────────────────────────────
  1138. File-type indicator   Indicates type of file. C: C source. text: any other
  1139.                        user-created file. pseudo: file-like means of
  1140.                        displaying data.
  1141.  
  1142.  Line and column       Shows current line and column of text cursor.
  1143.  indicators
  1144.  
  1145.  Status indicators     A: Meta condition is on.
  1146.                        B: Background compile in OS/2.
  1147.                        C: CAPS LOCK is on.
  1148.                        L: A CR isn't used to terminate a line.
  1149.                        M: File has been modified.
  1150.                        N: NUM LOCK is on.
  1151.                        O: Overtype is on.
  1152.                        R: The file is set to Read Only status.
  1153.                        T: File is temporary.
  1154.                        X: A macro is recording.
  1155.  
  1156.  ────────────────────────────────────────────────────────────────────────────
  1157.  Name                  Use
  1158.  ────────────────────────────────────────────────────────────────────────────
  1159. ────────────────────────────────────────────────────────────────────────────
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  Menus
  1165.  
  1166.  The menu bar contains seven or more menus which can be accessed at any time.
  1167.  A brief description of the selected menu command is displayed in the
  1168.  reference bar. To get further information about what a menu does, invoke the
  1169.  on-line help system by using the ALT and ARROW keys to highlight a menu
  1170.  title or menu command, then press F1; or point the mouse cursor at the menu
  1171.  command and click the Right mouse button.
  1172.  
  1173.  PWB has the following menus:
  1174.  
  1175.  (Please refer to the printed      The File menu allows you to clear the
  1176.  book)                             Source window, load an existing source
  1177.                                    file, merge a file with the file in
  1178.                                    memory, display the next file in the
  1179.                                    file list specified at start-up, save
  1180.                                    the current file, save the current file
  1181.                                    under a different name, print the
  1182.                                    selection or current file contents,
  1183.                                    temporarily exit to DOS or OS/2, or
  1184.                                    permanently exit PWB. Additionally, a
  1185.                                    list of recently opened source files is
  1186.                                    displayed at the bottom of the menu.
  1187.  
  1188.  (Please refer to the printed      The Edit menu allows you to delete, cut,
  1189.  book)                             copy, and paste text. Anchors can be set
  1190.                                    in the text as reference points for
  1191.                                    selection. Box, stream, and line mode
  1192.                                    determine how text will be selected with
  1193.                                    the cursor. Read Only status protects
  1194.                                    source files. Commands to record, play,
  1195.                                    and edit recorded macros are also
  1196.                                    available in this menu. These items are
  1197.                                    discussed further in the section "Using
  1198.                                    the Editor."
  1199.  
  1200.  (Please refer to the printed      The View menu controls the active
  1201.  book)                             window. A window can be closed, sized,
  1202.                                    and split vertically or horizontally
  1203.                                    with the menu commands.
  1204.  
  1205.  (Please refer to the printed      The Search menu invokes commands that
  1206.  book)                             find or change text in source files.
  1207.                                    Commands to search the source file for
  1208.                                    compilation errors are also available.
  1209.                                    Commonly accessed text can be identified
  1210.                                    with "bookmarks." Once a bookmark is
  1211.                                    associated with a certain position in
  1212.                                    the source file, the Go To Mark command
  1213.                                    moves the cursor to that location.
  1214.  
  1215.  (Please refer to the printed      The Make menu is used for compiling or
  1216.  book)                             building (to "build" means to compile
  1217.                                    and link) programs. From this menu, you
  1218.                                    also create or edit program lists, which
  1219.                                    name the components of multi-module
  1220.                                    programs.
  1221.  
  1222.  (Please refer to the printed      The Run menu is used to execute your
  1223.  book)                             compiled program. Compiled programs can
  1224.                                    be debugged with CodeView using the
  1225.                                    Debug command. The Run menu also has
  1226.                                    options for issuing DOS or OS/2 commands
  1227.                                    and adding applications as PWB menu
  1228.                                    items (for example, the Customize Menu
  1229.                                    command).
  1230.  
  1231.  (Please refer to the printed      The items in the Options menu control
  1232.  book)                             the integrated environment. The
  1233.                                    Environment command temporarily changes
  1234.                                    path names for libraries, include files,
  1235.                                    and help files. Both Key Assignments and
  1236.                                    Editor Settings customize the operation
  1237.                                    of the PWB editor. The Build Options
  1238.                                    command saves current build options,
  1239.                                    determines what type of program will be
  1240.                                    built (OS/2, DOS) with the Initial Build
  1241.                                    option, and specifies whether the
  1242.                                    program is built as a debug or release
  1243.                                    version. The Browse, C Compiler,
  1244.                                    CodeView, LINK, and NMAKE commands
  1245.                                    configure their respective applications.
  1246.  
  1247.  (Please refer to the printed      The commands in the optional Browse menu
  1248.  book)                             are used to scan through data
  1249.                                    declarations and functions once a
  1250.                                    program has been compiled. Program call
  1251.                                    trees, references to variables, and
  1252.                                    symbol relationships can be shown in the
  1253.                                    Browser window. Menu items are disabled
  1254.                                    unless you have compiled your program
  1255.                                    with options that generate a Browser
  1256.                                    database.
  1257.  
  1258.  (Please refer to the printed      The optional Help menu accesses the
  1259.  book)                             on-line reference system. For more
  1260.                                    information, see Chapter 4, "Using the
  1261.                                    On-Line Reference."
  1262.  
  1263.  
  1264.  Choosing Menu Commands
  1265.  
  1266.  Choose a command from a menu by "pulling down" or "opening" the menu.
  1267.  
  1268.  To choose a command from the keyboard:
  1269.  
  1270.  
  1271.    1.  Press the ALT key to activate the menu bar.
  1272.  
  1273.    2.  Press the highlighted character in the menu name (such as F for File),
  1274.        or use the right and left ARROW keys to select a menu. The left and
  1275.        right ARROW keys only select the menu; they do not open it.
  1276.  
  1277.    3.  Press the highlighted character in the command name (such as S for
  1278.        Save in the File menu), or use the up and down ARROW keys to highlight
  1279.        the command and then press ENTER.
  1280.  
  1281.  
  1282.  To choose a command with the mouse:
  1283.  
  1284.  
  1285.    1.  Open the menu by clicking the menu name.
  1286.  
  1287.    2.  Click the command.
  1288.  
  1289.  
  1290.  
  1291.  Closing Menus
  1292.  
  1293.  If you open a menu and then decide you don't want to issue a command, you
  1294.  can close the menu in any of these ways:
  1295.  
  1296.  
  1297.    ■   Press the ESC key
  1298.  
  1299.    ■   Click the mouse somewhere outside of the menu
  1300.  
  1301.    ■   Press ALT twice
  1302.  
  1303.  
  1304.  
  1305.  Using Shortcut Keys
  1306.  
  1307.  Certain menu items are followed by the names of keys or key combinations.
  1308.  These are "shortcut keys" for commonly used commands. Instead of issuing a
  1309.  command by opening a menu, press the shortcut key to issue the command.
  1310.  
  1311.  ────────────────────────────────────────────────────────────────────────────
  1312.  NOTE
  1313.  
  1314.  The reference bar at the bottom of the screen displays common shortcut keys.
  1315.  You can click any of these buttons to execute the indicated command.
  1316.  ────────────────────────────────────────────────────────────────────────────
  1317.  
  1318.  
  1319.  Shaded Commands
  1320.  
  1321.  When a command within a menu is in grayed type, it is "disabled," or
  1322.  unavailable for use; some condition prevents the command from being used.
  1323.  For example, when PWB is first run, and no programs have been compiled or
  1324.  linked, the Next Error and Previous Error commands in the Search menu are
  1325.  both disabled.
  1326.  
  1327.  
  1328.  Ellipses
  1329.  
  1330.  If a command is followed by three periods (an ellipsis), it means more
  1331.  information must be provided before the command is executed. You provide
  1332.  this information in a dialog box that appears when you issue the command. If
  1333.  a command is not followed by an ellipsis, it is executed immediately.
  1334.  
  1335.  
  1336.  Dialog Boxes
  1337.  
  1338.  Some menu commands cause dialog boxes to appear. For example, Figure 3.2
  1339.  shows the dialog box opened by the Search menu's Find command.
  1340.  
  1341.  (This figure may be found in the printed book).
  1342.  
  1343.  ────────────────────────────────────────────────────────────────────────────
  1344.  NOTE
  1345.  
  1346.  Dialog boxes usually offer shortcut keys. Shortcut keys are identified by
  1347.  highlighted letters, and can be activated by pressing the corresponding key.
  1348.  ────────────────────────────────────────────────────────────────────────────
  1349.  
  1350.  Dialog boxes can contain one or more of the items in the following list.
  1351.  Press ALT and the item's highlighted letter or press the TAB or SHIFT+TAB
  1352.  keys to move among items in a dialog box. Dialog items can be set either
  1353.  with keyboard commands or with the mouse.
  1354.  
  1355.  Item                              Description
  1356.  ────────────────────────────────────────────────────────────────────────────
  1357.  Option buttons ()                 Offer a list of choices; only one option
  1358.                                    can be chosen. Use the ARROW keys to
  1359.                                    move between the choices. In Figure 3.2,
  1360.                                    three option buttons set the direction
  1361.                                    of the search (Forward, Backward, Find
  1362.                                    All).
  1363.  
  1364.  Check box [X]                     A yes/no switch. If the box is empty,
  1365.                                    the option is turned off. If it contains
  1366.                                    the letter X, the feature is on. Press
  1367.                                    the SPACEBAR or use the up and down
  1368.                                    ARROW keys to turn a check box on or
  1369.                                    off.
  1370.  
  1371.  Text box [. . . . .]              Accepts text that you enter. In Figure
  1372.                                    3.2, Find Text requires you to type in
  1373.                                    the text to search for.
  1374.  
  1375.  Command buttons                   Pass commands to the dialog box
  1376.  < OK >                            (enclosed in angle brackets). The OK
  1377.                                    button means to use the current
  1378.                                    settings. The Cancel button exits the
  1379.                                    dialog box and does not change the
  1380.                                    current settings. If one of the command
  1381.                                    buttons is highlighted, press ENTER to
  1382.                                    execute that command. Clicking a command
  1383.                                    button also executes it. If a button
  1384.                                    contains an ellipsis, it indicates that
  1385.                                    another dialog box will appear when the
  1386.                                    command is carried out.
  1387.  
  1388.  List boxes                        Display lists of information, such as
  1389.                                    the contents of the current disk
  1390.                                    directory, inside a list box. If the
  1391.                                    number of items exceeds the list box
  1392.                                    space, press the ARROW keys and
  1393.                                    PGUP/PGDN or click the scroll bar to
  1394.                                    move around the list.
  1395.  
  1396.  
  1397.  Getting Help
  1398.  
  1399.  PWB uses the Microsoft Advisor on-line help system to provide information
  1400.  about PWB, the compiler, the linker, the CodeView debugger, other utilities,
  1401.  and topics relating to the C language. Information can be displayed at any
  1402.  time and at any point you're using PWB or CodeView. For a complete
  1403.  discussion of the on-line reference, see Chapter 4.
  1404.  
  1405.  
  1406.  Menu Help
  1407.  
  1408.  To get information about a PWB menu command, choose the command with the
  1409.  ARROW key, then press F1; or point the mouse cursor at the menu command and
  1410.  click with the Right mouse button. A help window then appears with
  1411.  information about the command.
  1412.  
  1413.  
  1414.  Dialog-Box Help
  1415.  
  1416.  Many dialog boxes have a help button that provides additional information
  1417.  about the dialog box and its contents. To display the information, click the
  1418.  Help button with the mouse or press F1.
  1419.  
  1420.  
  1421.  The Help Menu
  1422.  
  1423.  You can also use the commands listed in the Help menu to display an index of
  1424.  all help topics, a table of contents, and information about using the
  1425.  on-line reference system itself.
  1426.  
  1427.  Choose the Contents command to display a global contents screen for the
  1428.  entire help system. The main contents lists information divided by topic,
  1429.  such as PWB, CodeView, or the C language. From the main contents, you can
  1430.  navigate to a selected topic's table of contents by clicking that topic.
  1431.  
  1432.  Choose the Index command to display a main index where you can move to other
  1433.  indexes for different components of the Microsoft C help database.
  1434.  
  1435.  
  1436.  Using the Editor
  1437.  
  1438.  The program editor is an important part of the PWB environment. This section
  1439.  provides a brief overview of its major functions, and assumes you are using
  1440.  the default key assignments.
  1441.  
  1442.  
  1443.  Moving Around in a Source File
  1444.  
  1445.  Many of the keys within the editor work as you would expect them to. For
  1446.  example:
  1447.  
  1448.  
  1449.    ■   The PGDN and PGUP keys advance forward or back within the file.
  1450.  
  1451.    ■   The HOME key moves the cursor to the beginning of the current line.
  1452.  
  1453.    ■   The END key moves the cursor to the end of the current line.
  1454.  
  1455.    ■   The ARROW keys move the cursor one character or one line at a time.
  1456.  
  1457.  ────────────────────────────────────────────────────────────────────────────
  1458.  NOTE
  1459.  
  1460.  For a complete list of editor commands, refer to the on-line help system's
  1461.  PWB Function Quick Reference section on the PWB global contents screen.
  1462.  ────────────────────────────────────────────────────────────────────────────
  1463.  
  1464.  
  1465.  
  1466.  
  1467.  If you click in the shaded area on either side of the scroll box (position
  1468.  marker) in the scroll bar, you move the cursor one full window at a time in
  1469.  that direction. If you click on the scroll-bar arrows, you move the cursor
  1470.  one row or column in the corresponding direction. If you click and drag the
  1471.  scroll box, you move the cursor to the corresponding position within the
  1472.  file.
  1473.  
  1474.  
  1475.  Defining a Block
  1476.  
  1477.  To define a block with the PWB editor using the keyboard:
  1478.  
  1479.  
  1480.    1.  Move the cursor to the beginning of the block.
  1481.  
  1482.    2.  Hold down the SHIFT key and move the cursor to the end of the block.
  1483.  
  1484.    3.  Use the other cursor keys (HOME, END, CTRL+RIGHT, and so on) while
  1485.        you're holding down SHIFT to extend the block.
  1486.  
  1487.  
  1488.  To define a block with the PWB editor using the mouse:
  1489.  
  1490.  
  1491.    1.  Move the cursor to the beginning of the block.
  1492.  
  1493.    2.  While holding down the left button, move to the end of the block.
  1494.  
  1495.  
  1496.  Once a block has been defined, it can be erased (press DEL), or placed into
  1497.  the Clipboard, a temporary buffer, by cutting (press SHIFT+DEL) or by
  1498.  copying (press CTRL+INS). Once in the Clipboard, the block can be inserted
  1499.  at a cursor location (press SHIFT+INS). While a block is defined, anything
  1500.  you type will delete the highlighted block and then insert the typed
  1501.  characters.
  1502.  
  1503.  Three text-selection modes are available in the Edit menu:
  1504.  
  1505.  
  1506.    1.  Box mode selects text in a rectangular area whose opposite corners are
  1507.        the starting and ending cursor positions.
  1508.  
  1509.    2.  Line mode selects entire lines of text from the starting cursor
  1510.        position to the ending cursor position.
  1511.  
  1512.    3.  Stream mode selects all text from the starting cursor position to the
  1513.        ending cursor location.
  1514.  
  1515.  
  1516.  Selecting a mode from the Edit menu changes the menu item to a new mode. The
  1517.  mode displayed in the menu is the next available text-selection mode.
  1518.  
  1519.  You can also toggle through the selection modes during text selection by
  1520.  clicking the Right mouse button while you hold down the Left mouse button.
  1521.  
  1522.  
  1523.  Setting Bookmarks
  1524.  
  1525.  You can set bookmarks anywhere in your source code with the Define Mark
  1526.  command in the Search menu. Move the cursor to the location you want to
  1527.  mark, then choose Define Mark.
  1528.  
  1529.  In the dialog box that appears, type the name you want to give the bookmark.
  1530.  The source file name and the row and column are already entered. Press ENTER
  1531.  to save the bookmark for the current session. To permanently save a
  1532.  bookmark, you must use the Add To Mark File option. Permanent bookmarks can
  1533.  be loaded with the Set Mark File command in the Search menu.
  1534.  
  1535.  To move the cursor to a bookmark, choose the Go To Mark command from the
  1536.  Search menu. A list of all bookmarks is displayed. Select the bookmark from
  1537.  the list using the ARROW keys or click the selected bookmark with the Left
  1538.  mouse button. Press ENTER to go to the bookmark.
  1539.  
  1540.  
  1541.  Setting Anchors
  1542.  
  1543.  An anchor is a temporary marker that identifies a cursor position somewhere
  1544.  in the text. Use anchors to select large blocks of text.
  1545.  
  1546.  To set an anchor, move the cursor to the desired location and use the Set
  1547.  Anchor command in the Edit menu. Use the Select To Anchor command in the
  1548.  Edit menu to select all text between the current cursor position and the
  1549.  anchor. Only one anchor may be set at a time.
  1550.  
  1551.  
  1552.  Searching for and Changing Text
  1553.  
  1554.  You can search for a string of text by using the Find command in the Search
  1555.  menu. Type the string you want to look for, then use the check boxes to set
  1556.  options such as wraparound search and case sensitivity. The Files button
  1557.  allows you to specify a list of files to be searched for the designated
  1558.  string.
  1559.  
  1560.  Once a string has been located, use the Repeat Last Find command in the
  1561.  Search menu (or press the shortcut key, F3) to move to the next occurrence
  1562.  of the string. If you specified several files to search, press SHIFT+F3 to
  1563.  move to the next occurrence of the string.
  1564.  
  1565.  To modify several instances of a string in the source file, use the Change
  1566.  command in the Search menu. Enter the target string, the replacement string,
  1567.  and the search options.
  1568.  
  1569.  PWB also supports the search and replace of text patterns using regular
  1570.  expressions. Both UNIX(R) and non-UNIX regular expression syntaxes are
  1571.  supported. For further information, see the on-line reference system.
  1572.  
  1573.  ────────────────────────────────────────────────────────────────────────────
  1574.  NOTE
  1575.  
  1576.  Multi-file searches run a built-in GREP facility, and text that is found may
  1577.  be scanned with the Next Error and Previous Error commands.
  1578.  ────────────────────────────────────────────────────────────────────────────
  1579.  
  1580.  
  1581.  Creating Macros
  1582.  
  1583.  Editing tasks that you perform frequently can be saved as macros. A macro is
  1584.  the record of a sequence of commands and/or literal text. Each macro has a
  1585.  key combination that is used to "play back" the recorded actions.
  1586.  
  1587.  For example, suppose several programmers are working on a file and need to
  1588.  keep track of who made what changes. A macro can be used to insert a comment
  1589.  with the programmer's name.
  1590.  
  1591.  To create such a macro, choose the Set Record command in the Edit menu and
  1592.  enter a macro name and associated key combination. For this example, call
  1593.  the macro  modname  and let the key combination be CTRL+J. (Any key
  1594.  combination can be used for a macro.) After you've named the macro, choose
  1595.  the Record On command from the Edit menu. A bullet will appear to the left
  1596.  of the menu command and an X in the status line, indicating all keystrokes
  1597.  and menu commands are being recorded. Then type the following:
  1598.  
  1599.    /* j. courtney coded this */
  1600.  
  1601.  To stop the recording, choose Record On once again, which causes the bullet
  1602.  to disappear. This action associates all the recorded actions with the
  1603.  previously selected macro. Now, each time you press the CTRL+J key
  1604.  combination for the macro, the comment you typed is instantly inserted at
  1605.  the cursor position.
  1606.  
  1607.  You save macros to the TOOLS.INI file when you save the <record> pseudofile
  1608.  which can be reached by the Edit Macro command in the Edit menu. They may be
  1609.  changed or deleted by modifying the file. See the section "Customizing PWB"
  1610.  in on-line help for additional information about macros.
  1611.  
  1612.  
  1613.  Customizing the Editor
  1614.  
  1615.  You can customize the PWB editor to meet your needs. Editor settings can be
  1616.  modified, keyboard commands can be assigned, and command sets from other
  1617.  editors can be emulated. In addition, customized extensions to the editor
  1618.  can be written in C. See the on-line reference system and Chapter 8,
  1619.  "Customizing PWB," in Advanced Programming Techniques, for complete details.
  1620.  
  1621.  
  1622.  
  1623.  Changing Editor Settings
  1624.  
  1625.  The PWB editor has a variety of settings you can customize, such as word
  1626.  wrap, color, and width of tab stops.
  1627.  
  1628.  View or modify the settings by choosing the Editor Settings command from the
  1629.  Options menu. A pseudofile named <assign> appears. (The title bar says
  1630.  "Current Assignments and Settings," but the name <assign> appears in the
  1631.  File menu's list of files.) This file displays numerous editor settings in
  1632.  the format setting:value, where setting is the name of the setting, and
  1633.  value is a Boolean, numeric, or text value. You can learn about a setting by
  1634.  positioning the cursor on it and pressing F1.
  1635.  
  1636.  To change the value of a setting, enter a new value. The change does not
  1637.  take effect until you move the cursor to a different line. To save the
  1638.  changed assignments, press SHIFT+F2 (if the default keyboard assignments are
  1639.  in effect) or choose the Save command in the File menu. If you do not save,
  1640.  the assignments will be temporary and will last only for the duration of the
  1641.  PWB session.
  1642.  
  1643.  To return to your source file, press F2.
  1644.  
  1645.  
  1646.  Modifying Keyboard Assignments
  1647.  
  1648.  You can easily change all PWB keyboard assignments. Functions such as
  1649.  delete, home, and copy can be reassigned by choosing the Key Assignments
  1650.  command from the Options menu.
  1651.  
  1652.  A pseudofile named <assign> appears. (The title bar says "Current
  1653.  Assignments and Settings," but the name <assign> appears in the File menu's
  1654.  list of files.) This file lists PWB functions and the keys to which they are
  1655.  assigned. These appear in the format function:keyname. You can learn about a
  1656.  PWB function by positioning the cursor on the function name and pressing F1.
  1657.  A list of unused keys follows the assignment list.
  1658.  
  1659.  To assign a new key to a function, replace keyname with the name of the new
  1660.  key. The change does not take effect until you move the cursor to a
  1661.  different line.
  1662.  
  1663.  When you move the cursor to a different line, the line with the new
  1664.  assignment is highlighted. To make the assignment permanent, save the file
  1665.  by pressing SHIFT+F2 or by choosing the Save command in the File menu. This
  1666.  updates the TOOLS.INI file, where changes to key assignments are stored.
  1667.  
  1668.  To remove a key from a given function, assign the unassigned function to the
  1669.  key.
  1670.  
  1671.  
  1672.  Using Advanced Editor Features
  1673.  
  1674.  Most of the standard editing features in PWB are intuitive and easy to use.
  1675.  However, there are also many advanced editing options that allow you to
  1676.  customize and control the editor beyond simple menu commands.
  1677.  
  1678.  The PWB editor incorporates all of the powerful features found in the
  1679.  Microsoft Editor. A variety of functions and switches can be set to further
  1680.  customize the PWB editor and enhance its performance. A complete list of
  1681.  editor functions and settings is available in the on-line reference system.
  1682.  
  1683.  
  1684.  New or altered functions and settings can be added to the TOOLS.INI file so
  1685.  they are immediately loaded when PWB starts up. Or, they can be
  1686.  interactively entered while you are working in the PWB environment.
  1687.  
  1688.  For example, to interactively assign a key command to the editor's curdate
  1689.  function, which enters the current date at the cursor, first press ALT+A,
  1690.  then type the following into the argument dialog box:
  1691.  
  1692.    Curdate:SHIFT+CTRL+T
  1693.  
  1694.  Press ALT+= to assign the key to the function.
  1695.  
  1696.  Now, whenever you press SHIFT+CTRL+T, the current date will instantly be
  1697.  inserted at the editor's cursor position.
  1698.  
  1699.  For detailed information about advanced PWB editor features, refer to the
  1700.  Microsoft C Reference and the on-line reference system.
  1701.  
  1702.  
  1703.  Reconfiguring the Editor
  1704.  
  1705.  If you wish to use another set of editing commands, PWB comes with an
  1706.  additional .INI file containing key assignments for the BRIEF editor. You
  1707.  can add the contents of the file to TOOLS.INI, or you can simulate other
  1708.  editors' command sets by using the customization techniques previously
  1709.  described.
  1710.  
  1711.  
  1712.  Using Another Editor
  1713.  
  1714.  If you prefer to use another word processor or text editor, choose the Run
  1715.  menu's Customize Menu command. This command is used to add other programs
  1716.  (including word processors) to the Run menu so that you can run them from
  1717.  within the PWB environment. Through the dialog box you can specify directory
  1718.  paths and arguments to pass, and assign a key-command equivalent to run the
  1719.  editor. When you exit the program, you return to PWB.
  1720.  
  1721.  
  1722.  Compiling and Linking
  1723.  
  1724.  PWB uses a project-oriented approach to compiling and linking programs.
  1725.  After a source file has been created and a program list associated with it,
  1726.  PWB produces a makefile. A "program list" is a list of all of the source
  1727.  files that make up the program; the "makefile" contains information about
  1728.  the source files that compose the project. Whenever a multi-module program
  1729.  is compiled or linked, the NMAKE utility examines the makefile and
  1730.  determines which part of the project will be affected.
  1731.  
  1732.  The process of creating an executable file by compiling and linking is known
  1733.  as "building." When you build an application, the source code is first
  1734.  compiled on a module-by-module basis into .OBJ files, and then linked with
  1735.  the appropriate libraries.
  1736.  
  1737.  Makefiles are especially useful with multi-module programs, because only
  1738.  those source files that have changed are recompiled. This results in faster
  1739.  build times, since existing source files that haven't been changed are not
  1740.  recompiled. After you set a program list, building is a one-step process in
  1741.  PWB.
  1742.  
  1743.  
  1744.  Building Programs in PWB
  1745.  
  1746.  This section illustrates how to build programs under the PWB environment. To
  1747.  start, type in this sample program:
  1748.  
  1749.    /* IO.C: String input and output */
  1750.  
  1751.    #include <stdio.h>
  1752.  
  1753.    main()
  1754.    {
  1755.       char date[30];
  1756.  
  1757.       printf( "Enter today's date: \n" );
  1758.       gets( date );
  1759.       printf( "Sample program run on %s\n", date );
  1760.    }
  1761.  
  1762.  This simple program uses the  printf  and  gets  library functions to prompt
  1763.  for, and then print, today's date.
  1764.  
  1765.  
  1766.  Saving the Program
  1767.  
  1768.  To save the source file, pull down the File menu and choose either Save or
  1769.  Save As. If the file is new or you choose Save As, a dialog box prompts you
  1770.  for a file name (see Figure 3.3). If you choose Save with an existing file,
  1771.  PWB automatically saves the file under the name listed in the title bar of
  1772.  the source window. To save a copy of a file under a different name, choose
  1773.  Save As.
  1774.  
  1775.  (This figure may be found in the printed book).
  1776.  
  1777.  Type in the new name of the source file, IO.C.
  1778.  
  1779.  
  1780.  Setting and Clearing the Program List
  1781.  
  1782.  The Set Program List command in the Make menu tells PWB which makefile to
  1783.  use in building a program. It clears the current makefile setting, instructs
  1784.  PWB to use the makefile you have specified, and specifies which Browser
  1785.  (.BSC) file is associated with the current project.
  1786.  
  1787.  After you have saved the source file IO.C, choose the Set Program List
  1788.  command in the Make menu. In the dialog box that appears, type the base file
  1789.  name (IO), then press ENTER (see Figure 3.4). PWB automatically provides a
  1790.  .MAK extension.
  1791.  
  1792.  (This figure may be found in the printed book).
  1793.  
  1794.  If the makefile does not exist, PWB asks if you want to create a new
  1795.  makefile; answer yes to this dialog box. Another dialog box titled Edit
  1796.  Program List appears, listing all files in the current directory. From the
  1797.  list, select the files you want to include in the project (in this example,
  1798.  just IO.C).
  1799.  
  1800.  Press TAB until the cursor is within the list box containing the directory
  1801.  of files (another box lists the directory names). Use the ARROW keys to move
  1802.  to the IO.C file. Press ENTER and the file name appears in the program list
  1803.  below. Once the file is selected, press TAB until the Save List command
  1804.  button is highlighted, and then press ENTER.
  1805.  
  1806.  If you have a mouse, click IO.C once and then click the Add/Delete button
  1807.  (or just double-click IO.C). Once the file appears in the program list,
  1808.  click the Save List command button to save the makefile.
  1809.  
  1810.  PWB automatically determines the contents of the makefile based on the files
  1811.  you selected. You can edit the .MAK text file to change or add additional
  1812.  commands.
  1813.  
  1814.  If you want to create a new program or instruct PWB to "forget" about the
  1815.  current program, use the Clear Program List command in the Make menu. This
  1816.  action clears the current program list setting. You can then specify a new
  1817.  program to build with Set Program List.
  1818.  
  1819.  
  1820.  Setting Build Options
  1821.  
  1822.  Before compiling the program, you must specify the type of program you will
  1823.  be building. This is done with the Build Options command in the Options
  1824.  menu. Build Options calls a dialog box, whose Set Initial Build Options
  1825.  button presents a series of predefined compiler settings for creating
  1826.  programs (such as bound EXE, DOS EXE, DOS COM) and OS/2 .DLL libraries. Once
  1827.  an initial build option has been chosen, its settings can be changed with
  1828.  the C Compiler Options command in the Options menu.
  1829.  
  1830.  To specify an existing build option:
  1831.  
  1832.  
  1833.    1.  Choose the Build Options command from the Options menu
  1834.  
  1835.    2.  Select the Set Initial Build Options button
  1836.  
  1837.    3.  Use the mouse or the ARROW keys to select a build option from the list
  1838.        and press ENTER
  1839.  
  1840.  
  1841.  To save your own group of build option settings:
  1842.  
  1843.  
  1844.    1.  Select the appropriate settings in the C Compiler Options dialog box
  1845.  
  1846.    2.  Choose the Build Options command from the Options menu
  1847.  
  1848.    3.  Select the Save Current Build Options button
  1849.  
  1850.    4.  Type a description of the options and press ENTER
  1851.  
  1852.  
  1853.  The settings are now available through the Set Initial Build Options dialog
  1854.  box.
  1855.  
  1856.  
  1857.  Compiling and Linking the Program
  1858.  
  1859.  You can set a variety of compiler directives in the Options menu. The C
  1860.  Compiler Options command provides options for memory model, processor type,
  1861.  and other global settings that affect overall compilation (see Figure 3.5).
  1862.  
  1863.  
  1864.  (This figure may be found in the printed book).
  1865.  
  1866.  From within the C Compiler Options dialog box, you can use the Set Debug
  1867.  Options and Set Release Options buttons to easily create debug and release
  1868.  versions of your program.
  1869.  
  1870.  When you select the Set Debug Options button, a dialog box appears in which
  1871.  you can set parameters such as stack checking, optimization, and debug
  1872.  information. These settings also apply to programs built with the Debug
  1873.  Build option, which you select from the dialog box displayed by the Build
  1874.  Options command. Use debug settings when you are in the development phase
  1875.  and actively debugging your program. When the Release Build option is
  1876.  checked in the Build Options dialog box, the parameters specified in the Set
  1877.  Release Options dialog box apply.
  1878.  
  1879.  Similar debug and release options are also available for the linker with the
  1880.  LINK Options command in the Options menu (see Figure 3.6). You can display
  1881.  the options in both the C Compiler Options and LINK Options dialog boxes
  1882.  with the Show Debug Options and Show Release Options buttons.
  1883.  
  1884.  (This figure may be found in the printed book).
  1885.  
  1886.  The Set Release Options button in the C Compiler Options dialog box offers
  1887.  the same choices as Set Debug Options, but Set Release applies them to a
  1888.  final version of the program. Use these settings when your program is
  1889.  completely debugged and ready for release.
  1890.  
  1891.  For this example, use the default settings in the C Compiler Options dialog
  1892.  box.
  1893.  
  1894.  Before building the sample program, make sure that its name appears after
  1895.  the Compile File and Build commands in the Make menu. If the name does not
  1896.  appear after the Build command, choose the Set Program List command in the
  1897.  Make menu to set the makefile as the current project.
  1898.  
  1899.  To build the program, choose the Build command in the Make menu. If a
  1900.  compile or link error occurs, the build terminates, and the error appears in
  1901.  the Compile Results window. Use the on-line reference system to explain
  1902.  unknown errors by selecting the error and pressing F1. If you are using OS/2
  1903.  and errors occur, you will be informed and asked if you want to see the
  1904.  compile log.
  1905.  
  1906.  
  1907.  Running the Program
  1908.  
  1909.  After the program has been built, the name of your executable file is
  1910.  appended to the Execute command in the Run menu. Choose Execute to run the
  1911.  program. When the program is finished running, press any key to return to
  1912.  PWB.
  1913.  
  1914.  
  1915.  Building from Multiple Source Files
  1916.  
  1917.  You can build most applications from more than one source file. This section
  1918.  demonstrates how to create a multi-module program.
  1919.  
  1920.  First, edit the IO.C program:
  1921.  
  1922.    /* IO.C: Illustrates external functions */
  1923.  
  1924.    #include <stdio.h>
  1925.  
  1926.    void outsider(void); /* Add this function. */
  1927.    void sample(void);   /* Add this function. */
  1928.  
  1929.    main()
  1930.    {
  1931.       char date[30];
  1932.  
  1933.       sample();   /* Call new function. */
  1934.       outsider(); /* Call new function. */
  1935.       printf( "Enter today's date: \n" );
  1936.       gets( date );
  1937.       printf( "Sample program run on %s\n", date );
  1938.    }
  1939.  
  1940.    /* Implement the new sample function. */
  1941.    void sample(void)
  1942.    {
  1943.       printf( "A sample function.\n" );
  1944.    }
  1945.  
  1946.  The  main  function calls two new functions defined within the program:
  1947.  sample  and  outsider.
  1948.  
  1949.  Save the changed file and then choose New from the File menu. Type in a
  1950.  second source file:
  1951.  
  1952.    /* IOB.C: Second module for IO.C */
  1953.  
  1954.    #include <stdio.h>
  1955.  
  1956.    void outsider(void);
  1957.  
  1958.    void outsider(void)
  1959.    {
  1960.       printf( "This line is from the file IOB.C.\n" );
  1961.    }
  1962.  
  1963.  Save it as IOB.C. The two source files are combined to produce a
  1964.  multi-module program.
  1965.  
  1966.  
  1967.  Multiple Modules and the Program List
  1968.  
  1969.  Since the example program now uses two source files, the makefile must be
  1970.  changed to tell PWB which files should be compiled. Choose the Edit Program
  1971.  List command from the Make menu, add the IOB.C file to the list, and save
  1972.  it. When you create multimodule programs, the order of the file names added
  1973.  is inconsequential.
  1974.  
  1975.  ────────────────────────────────────────────────────────────────────────────
  1976.  NOTE
  1977.  
  1978.  A program list can include source files (with the .C extension), assembler
  1979.  files (.ASM), object files (.OBJ), library files (.LIB), definition files
  1980.  (.DEF), and resource files (.RC). For example, if you didn't include the
  1981.  graphics libraries in the combined library when you ran the SETUP program,
  1982.  you can place GRAPHICS.LIB in the program list to gain access to graphics
  1983.  functions under DOS.
  1984.  ────────────────────────────────────────────────────────────────────────────
  1985.  
  1986.  At this point you can compile and link the program.
  1987.  
  1988.  When you choose the Rebuild All command from the Make menu, every .C file in
  1989.  the program list is compiled into a .OBJ file. Then all of the .OBJ files
  1990.  are linked with .LIB files to create one .EXE file.
  1991.  
  1992.  If you choose the Build command, the NMAKE utility checks the time and date
  1993.  stamps on the source and object files. If the source code has not changed
  1994.  since the last time a Build command was executed, unchanged files are not
  1995.  recompiled. Consequently, the Build command is often faster than Rebuild
  1996.  All.
  1997.  
  1998.  
  1999.  Compiling and Linking from the Command Line
  2000.  
  2001.  You are not restricted to using the PWB environment to create executable
  2002.  programs. Programs can be compiled and linked with Microsoft C at the DOS or
  2003.  OS/2 command line.
  2004.  
  2005.  The CL.EXE program may be used to compile and link programs. PWB
  2006.  automatically executes CL, or you can manually execute it at the command
  2007.  line. Simply enter CL followed by a space and the name of the source file to
  2008.  create a .EXE program.
  2009.  
  2010.  In addition, a variety of command-line options can be used. For example,
  2011.  
  2012.    CL /AM IO.C
  2013.  
  2014.  causes the program to be compiled using the medium memory model instead of
  2015.  the default small model. Any compiler options should appear before the names
  2016.  of the files to be compiled.
  2017.  
  2018.  You can find a complete list of compiler and linker options in the C
  2019.  Reference or by typing
  2020.  
  2021.    CL /HELP
  2022.  
  2023.  to invoke the on-line reference system.
  2024.  
  2025.  You can also use CL to build multi-module programs by specifying all source
  2026.  files to be compiled:
  2027.  
  2028.    CL IO.C IOB.C
  2029.  
  2030.  This command builds a program called IO.EXE, because IO.C is listed first.
  2031.  
  2032.  Another way to build a multi-module program is to compile the two files and
  2033.  then manually link them:
  2034.  
  2035.    CL /c IO.C
  2036.    CL /c IOB.C
  2037.    LINK IO.OBJ IOB.OBJ
  2038.  
  2039.  The /c option instructs CL to compile but not link. Once the .OBJ files have
  2040.  been created, use the linker to create the executable file.
  2041.  
  2042.  Since a makefile named IO.MAK has already been created using PWB, you can
  2043.  also use the NMAKE utility to build IO.EXE. Simply pass it the name of the
  2044.  makefile:
  2045.  
  2046.    NMAKE /F IO.MAK
  2047.  
  2048.  If you don't provide /F and a file name, NMAKE searches for a file named
  2049.  MAKEFILE.
  2050.  
  2051.  For a complete list of compiler, linker, and NMAKE options, see Advanced
  2052.  Programming Techniques, the C Reference, or the on-line reference system.
  2053.  
  2054.  
  2055.  Debugging Programs
  2056.  
  2057.  PWB has a variety of resources available for debugging programs. They range
  2058.  from simple compile- and link-error messages to sophisticated source
  2059.  browsing and source- or assembly-level debugging.
  2060.  
  2061.  When compile-time errors occur, the cursor moves to the line that caused the
  2062.  first error and a brief description of the error appears in the reference
  2063.  bar. Use the Next Error and Previous Error commands in the Search menu to
  2064.  move the cursor to the lines where other errors occurred.
  2065.  
  2066.  To view a complete list of errors, choose the Compile Results command from
  2067.  the View menu. Use the Set Error command in the Search menu to select the
  2068.  error under the cursor as the current error. This command synchronizes the
  2069.  source and error windows so that the source-code line that contains the
  2070.  error appears in the source window.
  2071.  
  2072.  The Microsoft Advisor can be used to display on-line help about the error.
  2073.  In the Compile Results window, move the cursor to the error number and press
  2074.  F1.
  2075.  
  2076.  PWB incorporates a source-code browser and interfaces with the CodeView
  2077.  debugger. The Browser displays information about function and data
  2078.  relationships. CodeView is a window-oriented symbolic debugger that lets you
  2079.  step through your code and examine variables and data as the program
  2080.  executes.
  2081.  
  2082.  Before a program can take advantage of the Browser or CodeView, the
  2083.  appropriate debug or browse switches must be set with the C Compiler Options
  2084.  and Browse Options commands in the Options menu. As an example, build one of
  2085.  the sample programs previously listed with the debug options to experiment
  2086.  with the Browser and CodeView.
  2087.  
  2088.  
  2089.  Using the Browser
  2090.  
  2091.  The commands on the Browse menu are referred to collectively as the PWB
  2092.  Source Browser. These commands allow you to search a database comprising
  2093.  selected files, to get a list of references and definitions, build a call
  2094.  tree and outline, or create a list of relationships among program symbols.
  2095.  Figure 3.7 shows the functions called by  main  in IO.C.
  2096.  
  2097.  (This figure may be found in the printed book).
  2098.  
  2099.  Before using these commands, you must define the database the Source Browser
  2100.  is going to search.
  2101.  
  2102.  To define a database:
  2103.  
  2104.  
  2105.    1.  Generate a program list using the Set Program List command in the Make
  2106.        menu. The files contained in the program list make up the database.
  2107.  
  2108.    2.  Choose Browse Options from the Options menu. You must select the
  2109.        Generate Browse Information field in the dialog box to create the
  2110.        Source Browser database. The rest of the fields on this dialog box
  2111.        offer you choices of how to build the database; they are optional.
  2112.  
  2113.    3.  Build your program using the commands in the Make Menu. When you build
  2114.        the program, a file with the same program-list root name and a .BSC
  2115.        (Browser Source Cache) extension is created. This file contains
  2116.        reference information that the Browser uses.
  2117.  
  2118.  
  2119.  Once you have completed these steps, Browse Menu commands are ready for you
  2120.  to use.
  2121.  
  2122.  
  2123.    ■   The Goto Definition command provides a list of symbols and variables
  2124.        that occur within include files and modules. You can immediately open
  2125.        the file at the line number where the definition occurred by selecting
  2126.        the <OK> button.
  2127.  
  2128.    ■   The Goto Reference command displays a list of files and line numbers
  2129.        where  symbols and variables have been referenced in include files and
  2130.        modules.
  2131.  
  2132.    ■   The View Relationships command provides detailed information about
  2133.        various portions of your program. You can examine functions, macros,
  2134.        types, and variables by their use, definition, or inclusion in include
  2135.        files and modules.
  2136.  
  2137.    ■   The List References command displays references to functions, macros,
  2138.        types, and variables. You can move the cursor to a reference, and then
  2139.        use the Goto Definition or Goto Reference commands to show occurrences
  2140.        of the reference.
  2141.  
  2142.    ■   The Call Tree command displays a tree structure of function calls
  2143.        within the program.
  2144.  
  2145.  
  2146.  For additional information about the Browser, refer to the on-line reference
  2147.  system.
  2148.  
  2149.  ────────────────────────────────────────────────────────────────────────────
  2150.  NOTE
  2151.  
  2152.  You can create a Browser information file with the CL (command-line)
  2153.  compiler by using the /FR or /Fr options. This creates a .SBR file which can
  2154.  be converted to a .BSC file with the PWBRMAKE.EXE utility.
  2155.  ────────────────────────────────────────────────────────────────────────────
  2156.  
  2157.  
  2158.  Debugging with CodeView
  2159.  
  2160.  PWB provides access to the Microsoft CodeView debugger. After a program has
  2161.  been built, CodeView can be used to step through the source code, displaying
  2162.  output, registers, and variables as each line is executed (see Figure 3.8).
  2163.  You can set breakpoints and watchpoints to further aid in debugging.
  2164.  CodeView uses the Microsoft Advisor to provide on-line help about its
  2165.  operation and options, in addition to information about any C keywords in
  2166.  the program you are debugging.
  2167.  
  2168.  (This figure may be found in the printed book).
  2169.  
  2170.  ────────────────────────────────────────────────────────────────────────────
  2171.  NOTES
  2172.  
  2173.  CodeView version 3.0 is compatible with releases of OS/2 later than version
  2174.  1.0. If you encounter problems exiting CodeView, you either have an older
  2175.  version of OS/2 or the wrong version of the DOSCALLS.DLL file.
  2176.  
  2177.  If you use CodeView from the OS/2 DOS compatibility box, be sure the /S
  2178.  (Swap Screen in Buffers) option is set in the CodeView Options dialog box.
  2179.  If the option is not set, the mouse cursor is not displayed while you are
  2180.  debugging.
  2181.  
  2182.  ────────────────────────────────────────────────────────────────────────────
  2183.  
  2184.  
  2185.  Preparing a Debug Build
  2186.  
  2187.  It's easy to create a debug version of a program so it can be examined with
  2188.  CodeView.
  2189.  
  2190.  First, choose C Compiler Options from the Options menu, then select the Set
  2191.  Debug Options button. This dialog box contains a variety of settings for a
  2192.  debug build. Although most of the dialog box options can be set to your
  2193.  preference, you must check the CodeView option under the Debug Information
  2194.  heading, which is on by default. In addition, code optimization options,
  2195.  which are off by default, should be unchecked so that code movement does not
  2196.  affect debugging.
  2197.  
  2198.  The CodeView Options command in PWB's Options menu provides a variety of
  2199.  choices for configuring CodeView. These include two-monitor debugging,
  2200.  memory allocation, and the number of lines on the screen. For now, use the
  2201.  default settings initially displayed.
  2202.  
  2203.  In order for the compiler to build a program that contains the necessary
  2204.  CodeView information, you must check the Debug option, set in the dialog box
  2205.  displayed by the Build Options command in the Options menu. In addition, the
  2206.  CodeView option, which is on by default, must be selected in the Set Debug
  2207.  Options dialog box.
  2208.  
  2209.  To demonstrate how CodeView works, set the debug options as listed above,
  2210.  then rebuild the IO.C program using the Rebuild All command in the Make
  2211.  menu.
  2212.  
  2213.  
  2214.  Examining the Program
  2215.  
  2216.  After your program has been built with the appropriate debug options, choose
  2217.  the Debug command from the Run menu. PWB immediately transfers control to
  2218.  the CodeView debugger, loading the current project as indicated in the
  2219.  program list.
  2220.  
  2221.  When you switch from PWB to CodeView, the program appears in the source
  2222.  window. Choose the Source command in the Options menu or type the  S+
  2223.  command in CodeView's command window to display the code in C, the  S-
  2224.  command for assembly language, or the  S&  command for a combination of the
  2225.  two. With C or mixed-source options, a line number appears to the left of
  2226.  each line of source code as a reference.
  2227.  
  2228.  In addition to the source code, commands in the View menu show windows
  2229.  displaying memory, registers, and local variables. CodeView windows are
  2230.  similar to PWB windows in that they can be scrolled, sized, and closed.
  2231.  Multiple windows can appear on the screen at once, displaying a variety of
  2232.  information. A list of shortcut keys and buttons appears at the bottom of
  2233.  the screen.
  2234.  
  2235.  
  2236.  Setting Watch Expressions and Breakpoints
  2237.  
  2238.  Watch expressions and breakpoints are optional CodeView settings that
  2239.  display variable values and interrupt execution of the program.
  2240.  
  2241.  A "watch expression" is a variable within the program that CodeView
  2242.  continually watches. Watch expressions are displayed with the Watch command
  2243.  in the View menu. As the value of a variable changes, the value changes in
  2244.  the watch window.
  2245.  
  2246.  To add a variable to the watch expression list, select the variable and
  2247.  choose the Add Watch command from the Watch menu or use the W command in the
  2248.  command window. You can optionally enter the variable name in the dialog
  2249.  box. Watch expressions are removed with the Delete Watch command in the
  2250.  watch menu or with the Y command in the command window.
  2251.  
  2252.  To set a watch variable in the IO.C file, use the cursor to highlight the
  2253.  date  variable in the CodeView source window. Then choose the Add Watch
  2254.  command from the Watch menu. The  date  variable appears in the Expression
  2255.  text box. Press ENTER or click the OK button to store the watch variable.
  2256.  
  2257.  CodeView also incorporates a temporary watch option called a QuickWatch.
  2258.  Highlight a variable in the source window with the mouse or cursor. Choose
  2259.  the QuickWatch command from the Watch menu. A dialog box appears with the
  2260.  current value of the variable. You can add any QuickWatch variable to the
  2261.  watch window with the Add Watch dialog option.
  2262.  
  2263.  You can expand any structures or arrays that are set as watch expressions
  2264.  (identified with a "+" in the watch window) to show individual elements.
  2265.  Position the cursor on the variable name and either double-click the Left
  2266.  mouse button or press ENTER (see Figure 3.9).
  2267.  
  2268.  (This figure may be found in the printed book).
  2269.  
  2270.  A "breakpoint" is an instruction that tells CodeView to interrupt execution
  2271.  at a certain location or when an expression becomes true.
  2272.  
  2273.  Use breakpoints to gain control of the program before an error occurs and to
  2274.  quickly move to a part of the program you want to trace. When CodeView stops
  2275.  at a breakpoint, you can then single-step or trace through instructions
  2276.  until you find the problem.
  2277.  
  2278.  Set a breakpoint by positioning the cursor on the line at which you want the
  2279.  program to stop and then pressing F9. Alternatively, you can choose the Set
  2280.  Breakpoint command from the Watch menu. A dialog box presents a series of
  2281.  options for setting types of breakpoints. Breakpoints are modified or
  2282.  deleted with the Edit Breakpoints command in the Watch menu.
  2283.  
  2284.  Set a breakpoint in the IO.C file by moving the cursor in the CodeView
  2285.  source window to the line that reads
  2286.  
  2287.    printf( "A sample function.\n" );
  2288.  
  2289.  From the Watch menu, choose the Set Breakpoint command. The number of the
  2290.  line the cursor appears on is displayed in the dialog box. Press ENTER or
  2291.  click the OK button with the mouse to store the breakpoint. After the
  2292.  breakpoint has been set, the line it occurs on is highlighted.
  2293.  
  2294.  
  2295.  Running the Program
  2296.  
  2297.  CodeView runs your program and displays each source line as it executes. If
  2298.  an error occurs, CodeView stops at the instruction that caused the error.
  2299.  CodeView also halts execution at breakpoints.
  2300.  
  2301.  If a program requires arguments to be passed from the command line, these
  2302.  arguments can be entered with the Set Runtime Arguments command in the Run
  2303.  menu.
  2304.  
  2305.  Table 3.2 lists several CodeView commands for running a program.
  2306.  
  2307.  Table 3.2  CodeView Run Commands
  2308.  
  2309. ╓┌─────┌───────┌─────────────────────────────────────────────────────────────
  2310.  Key   Name    Use
  2311.  ─────────────────────────────────────────────────────────────────────────────
  2312.  Key   Name    Use
  2313.  ─────────────────────────────────────────────────────────────────────────────
  2314.  F5    Go      Executes the program to the next breakpoint, error, or end of
  2315.                the program
  2316.  
  2317.  F8    Trace   Executes a single line
  2318.  
  2319.  F10   Step    Executes a single line, but doesn't trace into
  2320.                functions
  2321.  
  2322.  ─────────────────────────────────────────────────────────────────────────────
  2323.  
  2324.  
  2325.  
  2326.  Run commands can be entered by pressing the appropriate key or clicking the
  2327.  commands at the bottom of the screen. With the Trace and Step commands, each
  2328.  line is highlighted as it is executed. The Go command executes each line
  2329.  until it stops at an error, a breakpoint, or the end of the program. If you
  2330.  choose the Animate command, each line is highlighted as it executes. To
  2331.  force the run commands to start at the beginning of the program, use the
  2332.  Restart command in the Run menu.
  2333.  
  2334.  The Screen Swap setting in the Options menu controls display of the output.
  2335.  If the option is turned on, CodeView switches to the output screen after
  2336.  each line executes, and then switch back to the source window. You can turn
  2337.  the option off during portions of your program that don't access the screen
  2338.  to reduce the distracting flicker of switching screens. If you want to view
  2339.  the output screen longer, choose the Output command from the View menu.
  2340.  Press any key to exit the output screen and return to CodeView.
  2341.  
  2342.  In addition to single-stepping through a program, the Animate command in the
  2343.  Run menu automatically steps through the program, highlighting each line as
  2344.  it proceeds.
  2345.  
  2346.  
  2347.  Running IO.C
  2348.  
  2349.  To demonstrate some of these commands with the IO.C program, make the source
  2350.  window active by pressing F6 or by clicking its title bar, then choose the
  2351.  Restart command from the Run menu. This command clears memory and prepares
  2352.  the program to start execution at the first line of  main.
  2353.  
  2354.  Press F5 or select the Go button at the bottom of the screen to start the
  2355.  program. The program executes until it reaches the breakpoint set at the
  2356.  sample  function.
  2357.  
  2358.  Use F10 or the Step button to execute each statement until you come to the
  2359.  outsider  function. If you press F8 or the Trace button at the  outsider
  2360.  function, CodeView traces through each statement of the function. If you use
  2361.  the Step button or F10, CodeView executes the function without tracing
  2362.  through it and moves on to the next program statement.
  2363.  
  2364.  Continue stepping through the program until you reach the  gets ( date )
  2365.  statement. Press F10; CodeView switches to the output screen and prompts you
  2366.  to enter a date. Type today's date and press ENTER. CodeView regains control
  2367.  and moves to the next statement.
  2368.  
  2369.  Since  date  was set as a watch variable and now contains data, use the
  2370.  mouse or press F6 to make the watch window active. Move the cursor to  date
  2371.  and press ENTER. This expands the display of the array and shows all of the
  2372.  elements. Press ENTER again while the cursor is on  date  to contract the
  2373.  array.
  2374.  
  2375.  Because  date  is also a local variable, it is shown in the local window
  2376.  with all variables local to the current function. You can expand or contract
  2377.  data in the local and the watch windows .
  2378.  
  2379.  Another way to view the contents of  date  is to put the cursor on it in the
  2380.  CodeView source window and choose QuickWatch from the Watch menu. The  date
  2381.  variable is immediately displayed in its expanded form. Press ENTER or click
  2382.  the OK button to leave the dialog box.
  2383.  
  2384.  Press F10 to finish stepping through the program. A dialog box informs you
  2385.  that the program has completed execution normally. Press ENTER to clear the
  2386.  dialog box and complete your debugging session.
  2387.  
  2388.  
  2389.  Debugging IO.C
  2390.  
  2391.  To see how CodeView deals with a bug in a program, use the Exit command in
  2392.  the File menu to return to PWB, then add this function to the IO.C program,
  2393.  and call it from  main:
  2394.  
  2395.    void bounds_error(void)
  2396.    {
  2397.       int loop, the_num[10];
  2398.  
  2399.       for(loop = 0; loop < 15; loop++)
  2400.          the_num[loop] = loop; }
  2401.  
  2402.  Set the appropriate debug options, rebuild the program, and return to
  2403.  CodeView.
  2404.  
  2405.  Use the F8 Trace command to execute the program. The program runs until it
  2406.  reaches the  for  statement in the  bounds_error  function, where the array
  2407.  bounds are exceeded. The output window reports an error while a CodeView
  2408.  dialog box indicates the program has terminated. At this point you can
  2409.  return to PWB, locate the error, and correct it.
  2410.  
  2411.  
  2412.  Getting More Details
  2413.  
  2414.  PWB, the compiler, the linker, NMAKE, and CodeView all have other features
  2415.  and options that go beyond the scope of this introduction.
  2416.  
  2417.  Refer to Advanced Programming Techniques for information about PWB, NMAKE,
  2418.  CodeView, and other tools, and the C Reference for a comprehensive listing
  2419.  of all commands and options for the applications included with Microsoft C.
  2420.  
  2421.  
  2422.  In addition, information about any component of the Professional Development
  2423.  System can be accessed through the Microsoft Advisor reference system. For a
  2424.  complete discussion of the on-line reference, see Chapter 4.
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  Chapter 4  Using the On-Line Reference
  2432.  ────────────────────────────────────────────────────────────────────────────
  2433.  
  2434.  Microsoft C offers two types of on-line reference systems:
  2435.  
  2436.  
  2437.    ■   The Microsoft Advisor, found within the Programmer's WorkBench (PWB)
  2438.        and CodeView environments.
  2439.  
  2440.    ■   The QuickHelp program, accessed from the OS/2 or DOS command line.
  2441.  
  2442.  
  2443.  Both systems provide the same information on important C topics and
  2444.  utilities provided with the Professional Development System, which include
  2445.  the C language, run-time libraries, CodeView, and PWB.
  2446.  
  2447.  The first section of this chapter, "Structure of the Microsoft Advisor,"
  2448.  outlines the structure and contents of the on-line reference database. The
  2449.  second section, "Navigating Through the Microsoft Advisor," takes you on a
  2450.  quick tour of the system. The third section, "Using QuickHelp," explains how
  2451.  to use the QuickHelp program and how it differs from the Microsoft Advisor.
  2452.  
  2453.  
  2454.  
  2455.  Structure of the Microsoft Advisor
  2456.  
  2457.  The Microsoft Advisor can be compared to a librarian managing a collection
  2458.  of books. Each book, or help file, has its own table of contents, index, and
  2459.  pages of information. The Advisor organizes the help files with a global
  2460.  contents and index. All of the files are listed, and their specific tables
  2461.  of contents and indexes can be accessed through the global references. The
  2462.  global contents screen is shown in Figure 4.1.
  2463.  
  2464.  (This figure may be found in the printed book).
  2465.  
  2466.  You can access a variety of information from the on-line reference system.
  2467.  Information regarding the C language, run-time libraries, errors, and the
  2468.  reference system itself is available.
  2469.  
  2470.  
  2471.  Navigating Through the Microsoft Advisor
  2472.  
  2473.  You request information about a topic in a window by positioning the cursor
  2474.  over it and pressing F1 or clicking the Right mouse button once. The help
  2475.  system then searches through the help files for information about the topic.
  2476.  If it finds the topic, the help system displays information in the help
  2477.  window. If help cannot be found for a particular word or symbol, a message
  2478.  informs you that no information is associated with the topic. Sometimes, a
  2479.  topic with the same name occurs in several help files. In such cases, a
  2480.  dialog box is displayed in which you can select the context of the topic.
  2481.  
  2482.  
  2483.  Using the Help Menu
  2484.  
  2485.  The simplest method for accessing the on-line reference is by using the
  2486.  commands found in the Help menu. All of these commands present information
  2487.  in the Help window.
  2488.  
  2489.  Command                           Description
  2490.  ────────────────────────────────────────────────────────────────────────────
  2491.  Index                             Displays the global index of help-file
  2492.                                    categories (see Figure 4.2).
  2493.  
  2494.  Contents                          Displays the global contents screen for
  2495.                                    the categories found in the help files.
  2496.  
  2497.  Topic:                            Provides information about the topic
  2498.                                    that the cursor is currently positioned
  2499.                                    over. If information about the topic is
  2500.                                    available, the topic's name is appended
  2501.                                    to the Topic: command. Otherwise, this
  2502.                                    menu option is grayed.
  2503.  
  2504.  Help on Help                      Displays information about using the
  2505.                                    on-line reference itself.
  2506.  
  2507.  Next                              Is useful if a topic with the same name
  2508.                                    appears in more than one help file. This
  2509.                                    option locates the next occurrence of
  2510.                                    the topic name and displays the
  2511.                                    information associated with it.
  2512.  
  2513.  (This figure may be found in the printed book).
  2514.  
  2515.  
  2516.  Using the F1 Key
  2517.  
  2518.  You can use the F1 key to get information about any menu command or PWB
  2519.  dialog box, as well as information on C keywords, operators, and run-time
  2520.  library functions.
  2521.  
  2522.  
  2523.  Menu Help
  2524.  
  2525.  To view information about a menu item, first pull down the menu, then
  2526.  
  2527.  
  2528.    ■   Use the cursor keys to highlight the command, and press F1, or
  2529.  
  2530.    ■   Move the mouse cursor on the command and click the Right mouse button
  2531.  
  2532.  
  2533.  Figure 4.3 shows the help information for the Cut command in the Edit menu.
  2534.  
  2535.  
  2536.  (This figure may be found in the printed book).
  2537.  
  2538.  
  2539.  Keyword and Library-Function Help
  2540.  
  2541.  To view information about a C keyword, operator, or run-time library
  2542.  function,
  2543.  
  2544.  
  2545.    ■   Put the cursor on the keyword or function name, and press F1, or
  2546.  
  2547.    ■   Click the command with the Right mouse button
  2548.  
  2549.  
  2550.  
  2551.  Dialog-Box Help
  2552.  
  2553.  To view information about a PWB dialog box, simply press F1 while the dialog
  2554.  box is displayed, or click on the help button.
  2555.  
  2556.  
  2557.  Using Hyperlinks
  2558.  
  2559.  Hyperlinks are cross-references that connect related topic information.
  2560.  
  2561.  Hyperlinks enclosed by the < and > characters are called "buttons." Navigate
  2562.  through the on-line help system by using these buttons.
  2563.  
  2564.  You can press TAB to move to the next hyperlink button within the current
  2565.  help window. SHIFT+TAB moves back to the previous button. Typing any letter
  2566.  moves the cursor to the next button that begins with the letter; holding
  2567.  SHIFT down and typing a letter moves the cursor backward.
  2568.  
  2569.  The Microsoft Advisor also recognizes C keywords, library functions,
  2570.  constants defined by Microsoft C, and similar identifiers as hyperlinks, but
  2571.  they are unmarked hyperlinks. Unmarked hyperlinks are recognized by the
  2572.  Microsoft Advisor wherever they appear in the help-information text or in
  2573.  your source code. However, an unmarked hyperlink is not delimited with the <
  2574.  and > characters, and you can't move to it with the TAB key. An unmarked
  2575.  hyperlink can only be executed by placing the cursor on it and pressing F1,
  2576.  or pointing to it with the mouse cursor and clicking the Right mouse button.
  2577.  
  2578.  
  2579.  You can access a hyperlink in several ways. First move either the mouse or
  2580.  text cursor to a hyperlink, then either
  2581.  
  2582.  
  2583.    ■   Press F1
  2584.  
  2585.    ■   Click the Right mouse button
  2586.  
  2587.    ■   Click the Left mouse button twice (double-click)
  2588.  
  2589.  
  2590.  Highlighted button hyperlinks can also be executed by pressing ENTER or
  2591.  SPACEBAR.
  2592.  
  2593.  Any of these actions displays information about the topic the cursor is
  2594.  positioned on. If the topic isn't a hyperlink, a message informs you that no
  2595.  information on the topic could be found.
  2596.  
  2597.  ────────────────────────────────────────────────────────────────────────────
  2598.  NOTE
  2599.  
  2600.  CodeView uses the Right mouse button differently in the source window.
  2601.  Clicking the Right button in the source window executes the program to the
  2602.  line the mouse was clicked on. However, once the help window is displayed,
  2603.  the Right mouse button can be used to select hyperlinks.
  2604.  ────────────────────────────────────────────────────────────────────────────
  2605.  
  2606.  
  2607.  Using Help Windows and Dialog Boxes
  2608.  
  2609.  The Microsoft Advisor displays information in windows or dialog boxes. Help
  2610.  windows and dialog boxes function the same as other windows and dialog boxes
  2611.  found in PWB and CodeView. For a complete description of windows and dialog
  2612.  boxes, refer to Chapter 3, "Using the Programmer's WorkBench."
  2613.  
  2614.  
  2615.  Using the Help Window
  2616.  
  2617.  The help window displays various contents, indexes, and information about
  2618.  selected topics. Some screens of information are larger than the help
  2619.  window; information beyond the window borders can be viewed by using the
  2620.  scroll bars or the cursor-movement keys. The  - u -  symbol indicates the
  2621.  end of information in the help window.
  2622.  
  2623.  Navigating with Hyperlink Buttons - At the top of the help window is a row
  2624.  of buttons that are useful for moving through the reference system:
  2625.  
  2626.  Button                            Description
  2627.  ────────────────────────────────────────────────────────────────────────────
  2628.  < Up >                            Moves upward in the hierarchy of help
  2629.                                    screens. Since information is ordered in
  2630.                                    a logical way, moving from the general
  2631.                                    to the specific, this command is useful
  2632.                                    for moving up the information tree.
  2633.  
  2634.  < Contents >                      Displays the global contents screen.
  2635.                                    This command is useful because it always
  2636.                                    returns you to a known point in the
  2637.                                    on-line help system hierarchy.
  2638.  
  2639.  < Index >                         Displays the global index list.
  2640.                                    Selecting an item from the list displays
  2641.                                    the index for that category.
  2642.  
  2643.  < Back >                          Moves you to the last on-line help
  2644.                                    screen you saw.
  2645.  
  2646.  Screens on a particular topic frequently are physically grouped together in
  2647.  a help file. You can press CTRL+F1 to display information about the next
  2648.  physical topic in the help file.
  2649.  
  2650.  Viewing the Previous Help Screen - The Microsoft Advisor remembers the last
  2651.  20 help screens you've accessed. To return to a previous screen, use the <
  2652.  Back > button or hold down the ALT key and press F1 as many times as
  2653.  necessary to return to the screen you want to see. The help screen that
  2654.  appears is active; you can ask for help on any of its hyperlinks or topics.
  2655.  
  2656.  
  2657.  You can always return to the global contents screen by pressing SHIFT+F1.
  2658.  
  2659.  Copying and Pasting Help Information - Any text that appears in the help
  2660.  window can easily be copied to another window. For example, to test an
  2661.  example program from the help window, you only have to copy it to the source
  2662.  window and compile it.
  2663.  
  2664.  To copy and paste using the keyboard, follow these steps:
  2665.  
  2666.  
  2667.    1.  Move the cursor to the beginning or the end of the text you want to
  2668.        select. Hold down the SHIFT key and move the cursor to the other end
  2669.        of the text. The text is now highlighted.
  2670.  
  2671.    2.  Execute the Copy command: Press ALT to activate the menus, E for Edit,
  2672.        then C for Copy. Note that the menu lists the shortcut command
  2673.        (CTRL+INS), which can be substituted for ALT+E, then C.
  2674.  
  2675.    3.  Press F6 to switch to another window. Position the cursor where you
  2676.        want to insert the text, and execute the Paste command: ALT+E then P,
  2677.        or use the SHIFT+INS shortcut. The text from the help window is
  2678.        inserted at the current cursor position.
  2679.  
  2680.  
  2681.  To copy and paste using the mouse, follow these steps:
  2682.  
  2683.  
  2684.    1.  Click the Left mouse button and drag the cursor (hold down the button
  2685.        while moving the mouse) to select the text you want to copy.
  2686.  
  2687.    2.  Choose Copy from the Edit menu (or press CTRL+INS).
  2688.  
  2689.    3.  Move the mouse cursor to the location where you want to insert the
  2690.        text, and click once. Then choose Paste from the Edit menu. The text
  2691.        from the help window is inserted at the current cursor position.
  2692.  
  2693.  
  2694.  Closing the Help Window - Once you're through working with the reference
  2695.  system, you can close the active help window and return to the source window
  2696.  by
  2697.  
  2698.  
  2699.    ■   Pressing ESC
  2700.  
  2701.    ■   Clicking the Close button in the upper left corner of the window with
  2702.        the Left mouse button
  2703.  
  2704.  
  2705.  
  2706.  Using Help Dialog Boxes
  2707.  
  2708.  Help dialog boxes contain information about menu commands and their dialog
  2709.  boxes. A help dialog box differs from a help window in that it is displayed
  2710.  over the source window and any other windows that are displayed. Unlike the
  2711.  help window, a help dialog box must be closed before you can execute any
  2712.  menu commands. The Cancel button in the lower right portion of the dialog
  2713.  box closes the help dialog box.
  2714.  
  2715.  To view information about any PWB dialog box, you can
  2716.  
  2717.  
  2718.    ■   Press F1
  2719.  
  2720.    ■   Click the Help button in the dialog box with the Left mouse button
  2721.  
  2722.  
  2723.  Either of these commands causes a help dialog box to appear. To close a help
  2724.  dialog box,
  2725.  
  2726.  
  2727.    ■   Press ESC
  2728.  
  2729.    ■   Click the dialog box's Cancel button by using the Left mouse button
  2730.  
  2731.  
  2732.  
  2733.  Accessing Different Types of Information
  2734.  
  2735.  This section presents some strategies for accessing the different types of
  2736.  information available within the on-line reference system.
  2737.  
  2738.  
  2739.  Keyword Information
  2740.  
  2741.  To get information about any keyword, operator, symbolic constant, or
  2742.  library function, display the appropriate index for the keyword, select the
  2743.  keyword's first letter from the index, then scroll down the list of entries
  2744.  and select the topic's hyperlink. If you know the exact name of a keyword,
  2745.  it is often quicker to simply type it in the source window and press F1 to
  2746.  locate it through an index.
  2747.  
  2748.  Information about keywords can also be viewed by using the arg command and
  2749.  entering the keyword with F1 in the arg command dialog box. Assuming that
  2750.  you have the arg function assigned to  alt+a, the following series of
  2751.  keystrokes displays help on the printf function:
  2752.  
  2753.    alt+a printf F1
  2754.  
  2755.  Figure 4.4 shows the information screen that then appears.
  2756.  
  2757.  (This figure may be found in the printed book).
  2758.  
  2759.  When information about a function is shown in the help window, two
  2760.  additional hyperlink buttons are displayed.
  2761.  
  2762.  
  2763.    ■   < Description > provides a detailed explanation of the function. When
  2764.        the information is displayed, the button changes to < Summary >. Click
  2765.        this button to return to the summarized information about the
  2766.        function.
  2767.  
  2768.    ■   < Example > displays C source code that provides an example of how the
  2769.        function is used.
  2770.  
  2771.  
  2772.  
  2773.  Topical Information
  2774.  
  2775.  The on-line reference system is useful when you want an overview of the
  2776.  available reference topics, or when you only have a general idea of what
  2777.  information you need. Start with the global contents screen, then select any
  2778.  hyperlinks that relate to the topic. You can traverse the hyperlinks until
  2779.  you locate the necessary information.
  2780.  
  2781.  
  2782.  Menu and Dialog-Box Information
  2783.  
  2784.  You can get information about any menu command or dialog box by pressing F1
  2785.  when the menu command is highlighted or the dialog box is displayed. This is
  2786.  helpful when you are first learning to use the Professional Development
  2787.  System and are not completely familiar with all of the features.
  2788.  
  2789.  
  2790.  Error Information
  2791.  
  2792.  The Microsoft Advisor provides information about compiler and linker error
  2793.  messages.
  2794.  
  2795.  To find the meaning of an error message using the keyboard,
  2796.  
  2797.  
  2798.    1.  Press F6 to move the cursor to the error window
  2799.  
  2800.    2.  Position the cursor on the error number
  2801.  
  2802.    3.  Press F1
  2803.  
  2804.  
  2805.  or with the mouse,
  2806.  
  2807.  
  2808.    1.  Position the mouse cursor on the error number
  2809.  
  2810.    2.  Click the Right mouse button
  2811.  
  2812.  
  2813.  Help on error messages is also available directly from the PWB source window
  2814.  by entering the arg command with the error number and its alphabetic prefix,
  2815.  and then pressing F1.
  2816.  
  2817.  
  2818.  Specifying Temporary Help Files
  2819.  
  2820.  You can temporarily load other help files using the Environment command in
  2821.  the PWB Options menu. The Microsoft Advisor searches help files you specify
  2822.  in this text box before it searches the standard Development System help
  2823.  files as specified by the HELPFILES environment variable. Use the help files
  2824.  text box to override (for the current session only) the help-file path
  2825.  defined in the HELPFILES variable. When programming with mixed languages,
  2826.  you may want to temporarily load the help files for each of the languages
  2827.  you're using.
  2828.  
  2829.  
  2830.  Using QuickHelp
  2831.  
  2832.  QuickHelp is a separate application that provides access to any help file.
  2833.  It uses the same help files as the Microsoft Advisor, and presents
  2834.  information about topics in the same way. QuickHelp is designed for the
  2835.  developer who prefers using command-line utilities or another editor, and
  2836.  doesn't have access to the Microsoft Advisor through PWB.
  2837.  
  2838.  Major utilities and applications that come with the Microsoft C package
  2839.  invoke QuickHelp and display related information if you use the /HELP
  2840.  switch. You can also use QuickHelp from the command line, as explained in
  2841.  the following sections. Once you are in the QuickHelp program, select which
  2842.  help file you want to view.
  2843.  
  2844.  
  2845.  Using the /HELP Switch
  2846.  
  2847.  You can get immediate information on major components of Microsoft C by
  2848.  using the /HELP switch.
  2849.  
  2850.  For example, to learn about the LIB utility, enter
  2851.  
  2852.    LIB /HELP
  2853.  
  2854.  QuickHelp will run and immediately display information about LIB.
  2855.  
  2856.  
  2857.  Using the QH Command
  2858.  
  2859.  You can also run QuickHelp by typing QH at the DOS or OS/2 command line.
  2860.  Specify an application to get help about, such as
  2861.  
  2862.    QH LIB.EXE
  2863.  
  2864.  In addition to information about programs, QuickHelp can also display
  2865.  information about run-time errors. You can type the error number with its
  2866.  alphabetic prefix after the QH command at the DOS or OS/2 command line.
  2867.  
  2868.  
  2869.  Opening and Closing Help Files
  2870.  
  2871.  If no file name is specified when QuickHelp is run, it looks for the
  2872.  environment variable HELPFILES, and opens all listed .HLP files. If the
  2873.  HELPFILES variable isn't present, all .HLP files in directories specified by
  2874.  the PATH environment variable are loaded.
  2875.  
  2876.  Choose the List Database command on the File menu to view a list of all the
  2877.  currently open help files.
  2878.  
  2879.  To open additional help files,
  2880.  
  2881.  
  2882.    ■   Choose the Open Database command from the File menu.
  2883.  
  2884.    ■   Type the fully qualified path name of the help file to be opened in
  2885.        the dialog box that appears. You can specify all help files in a
  2886.        directory with *.HLP.
  2887.  
  2888.    ■   Press ENTER or click the OK button with the Left mouse button.
  2889.  
  2890.  
  2891.  To close an open help file,
  2892.  
  2893.  
  2894.    ■   Choose the Close Database command from the File menu.
  2895.  
  2896.    ■   Use the mouse or keyboard to select which help file you would like to
  2897.        close from the list of help files displayed in the menu
  2898.  
  2899.  
  2900.  
  2901.  Displaying a Topic
  2902.  
  2903.  You can view information about a topic by using the Search command in the
  2904.  View menu. When topic information is displayed, it is shown in the same
  2905.  format as information presented by the Microsoft Advisor.
  2906.  
  2907.  To display a topic from any of the open help files,
  2908.  
  2909.  
  2910.    ■   Choose the Search command from the View menu
  2911.  
  2912.    ■   Type the topic you want information about in the Search dialog box
  2913.        (the search is not case sensitive)
  2914.  
  2915.    ■   Press ENTER or click the OK button with the Left mouse button
  2916.  
  2917.  
  2918.  QuickHelp begins searching for the topic in the open help files. If the
  2919.  topic cannot be found, a dialog box informs you that the search failed. If
  2920.  the search is successful, information about the topic is displayed in the
  2921.  QuickHelp window.
  2922.  
  2923.  
  2924.  Navigating Through Topics
  2925.  
  2926.  A series of commands on the View menu allow you to selectively display
  2927.  topics. These commands include the following:
  2928.  
  2929.  Command                           Description
  2930.  ────────────────────────────────────────────────────────────────────────────
  2931.  View History                      Displays a list of all the topics that
  2932.                                    have recently been displayed. You can
  2933.                                    view a topic in the list by selecting it
  2934.                                    and clicking the Right mouse button or
  2935.                                    pressing ENTER.
  2936.  
  2937.  View Last                         Displays the last topic you looked at.
  2938.  
  2939.  View Back                         Moves backward one topic in the help
  2940.                                    file.
  2941.  
  2942.  View Next                         Displays the next topic in the help
  2943.                                    file.
  2944.  
  2945.  
  2946.  Using the QuickHelp Window
  2947.  
  2948.  The QuickHelp window (see Figure 4.5) is similar in function to the
  2949.  Microsoft Advisor help window, described earlier in this chapter.
  2950.  Information that doesn't fully fit in a window can be scrolled, and
  2951.  hyperlinks are used to display additional information.
  2952.  
  2953.  (This figure may be found in the printed book).
  2954.  
  2955.  The main differences between the two windows are
  2956.  
  2957.  
  2958.    ■   Information presented in QuickHelp cannot selectively be copied. See
  2959.        the section "Copying and Pasting in QuickHelp" that follows for more
  2960.        information.
  2961.  
  2962.    ■   The QuickHelp window cannot be closed.
  2963.  
  2964.    ■   Any information that appears on the screen can be sent to a printer by
  2965.        using the Print command in the File menu.
  2966.  
  2967.  
  2968.  
  2969.  Copying and Pasting in QuickHelp
  2970.  
  2971.  In order to transfer information, you must first specify a new file with the
  2972.  Rename Paste File command in the File menu. Once the file is specified,
  2973.  choose either the Current Window or the Current Topic command in the Paste
  2974.  menu to transfer the text to that file. Be sure to specify a new file when
  2975.  you paste, since QuickHelp overwrites text in an existing file.
  2976.  
  2977.  
  2978.  More About QuickHelp
  2979.  
  2980.  In addition to the features mentioned above, QuickHelp has a variety of
  2981.  other options such as changing the appearance of the help window, searching
  2982.  for text within topics, and controlling the function of the Right mouse
  2983.  button.
  2984.  
  2985.  To learn more about QuickHelp's features, make sure the QH.HLP file is
  2986.  loaded, then do one of the following:
  2987.  
  2988.  
  2989.    ■   Press F1 to view QuickHelp's on-line reference
  2990.  
  2991.    ■   Choose a menu command and press F1 or click the Right mouse button to
  2992.        get information about it
  2993.  
  2994.    ■   Refer to the C Reference guide for a list of QuickHelp options
  2995.  
  2996.