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

  1.  Microsoft(R) Pascal Compiler - Version 4.0 Update
  2.  
  3.  
  4.  
  5.  ───────────────────────────────────────────────────────────────────────────
  6.  
  7.  
  8.  
  9.  Microsoft(R) Pascal Compiler
  10.  
  11.  for MS(R) OS/2 and MS-DOS(R) Operating Systems
  12.  
  13.  Version 4.0 Update
  14.  
  15.  
  16.  
  17.  ───────────────────────────────────────────────────────────────────────────
  18.  
  19.  
  20.  
  21.  Information in this document is subject to change without notice and
  22.  does not represent a commitment on the part of Microsoft Corporation. The
  23.  software described in this document is furnished under a license agreement
  24.  or nondisclosure agreement. The software may be used or copied only in
  25.  accordance with the terms of the agreement. The purchaser may make one copy
  26.  of the software for backup purposes. No part of this manual may be
  27.  reproduced or transmitted in any form or by any means, electronic or
  28.  mechanical, including photocopying and recording, for any purpose other
  29.  than the purchaser's personal use without the written permission of
  30.  Microsoft Corporation.
  31.  
  32.  
  33.  
  34.  (C)Copyright Microsoft Corporation, 1987. All rights reserved.
  35.  Simultaneously published in the U.S. and Canada.
  36.  
  37.  
  38.  
  39.  If you have comments about the software, complete the Product Assistance
  40.  Request card at the back of this manual and return it to Microsoft
  41.  Corporation.
  42.  
  43.  If you have comments about the software documentation, complete the
  44.  Documentation Feedback card at the back of this manual and return it to
  45.  Microsoft Corporation.
  46.  
  47.  
  48.  
  49.  Microsoft(R), MS(R), MS-DOS(R), and CodeView(R) are registered trademarks
  50.  and QuickC(TM) is a trademark of Microsoft Corporation.
  51.  
  52.  IBM(R) is a registered trademark of International Business Machines
  53.  Corporation.
  54.  
  55.  Texas Instruments(R) is a registered trademark of Texas Instruments, Inc.
  56.  
  57.  Wang(R) is a registered trademark of Wang Laboratories, Inc.
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  Contents
  65.  
  66.  ───────────────────────────────────────────────────────────────────────────
  67.  
  68.  Section 1  Overview
  69.    1.1  Using This Update
  70.    1.2  Summary of New Features
  71.    1.3  Unimplemented Features
  72.    1.4  Disk Contents
  73.    1.5  Setting Up Microsoft(R) Pascal
  74.          1.5.1  Running the SETUP Program
  75.          1.5.2  Directories Created by the SETUP Program
  76.          1.5.3  Environment Variable and Configuration Files
  77.          1.5.4  Building Libraries
  78.          1.5.5  Operating System Choice and Library Names
  79.  
  80.  Section 2  Using the PL Driver
  81.    2.1  The PL Command Line
  82.    2.2  The PL Environment Variable
  83.    2.3  Specifying LIbraries
  84.    2.4  Overlays
  85.    2.5  Specifying .LIB and .DEF Files
  86.    2.6  PAS1 Options with the PL Driver
  87.    2.7  Other PL Options
  88.          2.7.1  Invoking the Compiler Only (/c)
  89.          2.7.2  Defining a Constant on the Command Line (/D)
  90.          2.7.3  Choosing a Floating-Point Library (/FPx)
  91.          2.7.4  Producing a Source-Listing File (/Fl)
  92.          2.7.5  Producing a Code-Listing File (/Fc)
  93.          2.7.6  Producing a Link-Map File (/Fm)
  94.          2.7.7  Naming the Executable File (/Fe)
  95.          2.7.8  Naming the Object File (/Fo)
  96.          2.7.9  Specifying Directories for Include Files (/I)
  97.          2.7.10 Passing Options and Libraries to LINK (/link)
  98.          2.7.11 Setting the Size of the Program Stack (/S)
  99.          2.7.12 Ignoring the INCLUDE Environment Variable (/X)
  100.          2.7.13 Producing Line-Numbering Information for the CodeView(R)
  101.                  Debugger (Zd)
  102.          2.7.14 Producing Full Information for the Codeview Debugger (Zi)
  103.          2.7.15 Producing Error Output for the Microsoft Editor (/Zz)
  104.  
  105.  
  106.  Section 3  OS/2 Systems Support
  107.    3.1  Compiling and Linking Under OS/2
  108.    3.2  Binding Programs To Run Under Both DOS and OS/2
  109.    3.3  OS/2 Protected-Mode Restrictions
  110.  
  111.  
  112.  Section 4  Other New Features
  113.    4.1  Symbol Table in Far Memory
  114.    4.2  Checking for a Math Coprocessor
  115.    4.3  INCLUDE Environment Variable
  116.    4.4  The $IFDECL Metacommand
  117.    4.5  CodeView Debugger Support
  118.          4.5.1  Overview of the CodeView Debugger
  119.          4.5.2  Pascal CodeView Support
  120.    4.6  New Versions of the Utilities
  121.    4.7  Mixed-Language Documentation
  122.  
  123.  
  124.  Section 5  Updating from Version 3.30 and Earlier
  125.    5.1  Increased Stack Size
  126.    5.2  The $INITCK Metacommand and FOR-Loop Variables
  127.    5.3  Determining Available Memory
  128.  
  129.  
  130.  Section 6  Updating from versions 3.20 and Earlier
  131.    6.1  Address Types
  132.          6.1.1  Using the ADS and ADR Operators with Expressions
  133.          6.1.2  Addressing Procedures and Functions (ADSPROC and ADSFUNC)
  134.    6.2  Using the SIZEOF Function
  135.    6.3  Mixed-Language Features
  136.          6.3.1  Using the C int Type (INTEGERC)
  137.          6.3.2  Using C Calling Conventions (C Attribute)
  138.          6.3.3  Using a Variable Number of Arguments (VARYING Attribute)
  139.    6.4  New Files Supplied with the Compiler
  140.          6.4.1  Using C System Functions with CEXEC.LIB
  141.          6.4.2  Customizing the 8087 Table with the EMOEM.ASM Program
  142.          6.4.3  Creating a Variable Stack with LVARSTK.OBJ
  143.    6.5  Using the ERR Device Name
  144.    6.6  File Sharing and Locking
  145.          6.6.1  File Sharing
  146.                  6.6.1.1  Sharemodes
  147.                  6.6.1.2  Accessmode
  148.          6.6.2  File Locking
  149.    6.7  Public Variables
  150.    6.8  The Pascal Memory Model
  151.    6.9  Compatibility with Version 3.20
  152.  
  153.  
  154.  Section 7  Writing Microsoft Windows Applications
  155.    7.1  Windows Interface
  156.    7.2  $WINDOWS Metacommand
  157.    7.3  Program Module
  158.    7.4  WinMain Function
  159.    7.5  Callback Functions
  160.          7.5.1  Windows and Pascal Libraries
  161.          7.5.2  Pascal Memory-Allocation Routines
  162.          7.5.3  Floating-Point Support
  163.                  7.5.3.1  Coprocessor/Emulator Math Option
  164.                  7.5.3.2  Alternate Math Option
  165.  
  166.  
  167.  Section 8     Error and Warning Messages
  168.    8.1  Error Messages
  169.    8.2  Warning Messages
  170.  
  171.  
  172.  Figures
  173.  
  174.    Figure 5.1  Allocation of Memory in DGROUP
  175.  
  176.  
  177.  Tables
  178.    Table 2.1  PAS1 Options in Pascal
  179.  
  180.  
  181.  
  182.  Section 1  Overview
  183.  
  184.  ───────────────────────────────────────────────────────────────────────────
  185.  
  186.  
  187.  
  188.  Welcome to the Microsoft(R) Pascal Compiler Version 4.0. With this latest
  189.  version of Pascal, you can develop programs for MS-DOS(R), Microsoft
  190.  Operating System/2 (MS(R) OS/2), or both operating systems.
  191.  
  192.  This version of Pascal also helps you develop programs faster and more
  193.  accurately by providing support for the Microsoft CodeView(R) debugger. The
  194.  CodeView debugger is a powerful yet easy-to-learn tool for analyzing logic
  195.  errors in OS/2 or DOS programs. Version 4.0 of Pascal comes complete with
  196.  the debugger, which now evaluates Pascal variables and expressions.
  197.  
  198.  Version 4.0 also improves the programming environment in several other
  199.  ways. During compilation, Version 4.0 is able to utilize all of available
  200.  memory. As a result, Pascal can compile larger modules than it could
  201.  before. This version also comes with the complete and current set of
  202.  Microsoft programming utilities and includes the new Pascal/Link (PL)
  203.  driver. The PL driver is briefly described in Section 1.2, "Summary of New
  204.  Features."
  205.  
  206.  This document describes each new feature of Pascal. Section 1 provides an
  207.  overview of the new version. The purpose of each division within Section 1
  208.  is described below:
  209.  
  210.    Section      Purpose
  211.    ─────────────────────────────────────────────────────────────────────────
  212.    Section 1.1  Explains how to use this update
  213.  
  214.    Section 1.2  Summarizes new features
  215.  
  216.    Section 1.3  Lists features mentioned in the reference manual that
  217.                  are not yet implemented
  218.  
  219.    Section 1.4  Discusses disk contents
  220.  
  221.    Section 1.5  Describes the new SETUP program that automatically
  222.                  installs Pascal
  223.  
  224.  ───────────────────────────────────────────────────────────────────────────
  225.  Note
  226.       Microsoft documentation uses the term "OS/2" to refer to OS/2
  227.       systems--MS OS/2 and IBM(R) OS/2. Similarly, the term "DOS" refers
  228.       to both the MS-DOS and PC DOS operating systems. The name of a
  229.       specific operating system is used when it is necessary to note
  230.       features that are unique to that system.
  231.  ───────────────────────────────────────────────────────────────────────────
  232.  
  233.  
  234.  1.1  Using This Update
  235.  
  236.  To get started with Version 4.0, first finish reading Section 1 of this
  237.  update. This section describes some features you may need to know about
  238.  before using the compiler.
  239.  
  240.  After reading this first section, you can read the rest of the
  241.  documentation in any order that seems most helpful. In particular, if
  242.  you are interested in debugging, program-library management, or the
  243.  details of linking, you may want to look at the Microsoft CodeView
  244.  and Utilities manual.
  245.  
  246.  This update describes features introduced since the last version, Version
  247.  3.32. It also consolidates all previous updates and README.DOC files since
  248.  Version 3.20. This update supersedes all previous documentation and on-line
  249.  information.
  250.  
  251.  ───────────────────────────────────────────────────────────────────────────
  252.  Note
  253.       If there is a README.DOC file on one of the Version 4.0 disks, it
  254.       contains even more recent information and therefore supersedes this
  255.       update in the case of conflict.
  256.  ───────────────────────────────────────────────────────────────────────────
  257.  
  258.  The remaining sections in this update describe new features or differences
  259.  between specific versions:
  260.  
  261.       ■  Section 2, "Using the PL Driver," explains the purpose of the PL
  262.          driver and how to use it to automate the process of compiling and
  263.          linking.
  264.  
  265.       ■  Section 3, "OS/2 Systems Support," describes how to compile and
  266.          link a program under OS/2. The section also describes how to bind a
  267.          program so it runs under either OS/2 or DOS. In addition, the
  268.          section includes information about limitations on using threads.
  269.  
  270.       ■  Section 4, "Other New Features," describes additional features
  271.          introduced with Pascal 4.0. This section also contains abstracts of
  272.          the other new manuals.
  273.  
  274.       ■  Section 5, "Updating from Version 3.30 and Earlier," is most
  275.          relevant to users updating from Version 3.30, Version 3.20, and
  276.          older versions, as well as to users who are new to Microsoft
  277.          Pascal.
  278.  
  279.       ■  Section 6, "Updating from Version 3.20 and Earlier," is most
  280.          relevant to users updating from Version 3.20 or older, as well as
  281.          to users who are new to Microsoft Pascal.
  282.  
  283.       ■  Section 7, "Writing Microsoft Windows Applications," explains how
  284.          to use Microsoft Pascal with the library routines provided in the
  285.          Microsoft Windows Software Development Kit. This section is of
  286.          interest to Windows developers who wish to write applications in
  287.          Pascal.
  288.  
  289.       ■  Section 8, "Error Messages," describes new error messages for the
  290.          PL driver.
  291.  
  292.  The list below summarizes which sections of this update you need to read,
  293.  depending on the version of Microsoft Pascal from which you are updating:
  294.  
  295.    If Updating from:           Read These Sections:
  296.    ─────────────────────────────────────────────────────────────────────────
  297.    3.31 or 3.32                1-4
  298.    3.30                        1-5
  299.    3.20 or older               1-6
  300.    New to MS Pascal            1-6
  301.  
  302.  
  303.  1.2  Summary of New Features
  304.  
  305.  The following features of Microsoft Pascal are introduced with Version 4.0:
  306.  OS/2 support, programming utilities, compiler enhancements, automatic
  307.  installation, and additional documentation.
  308.  
  309.  
  310.  ■  OS/2 Support
  311.  
  312.  You can use Pascal Version 4.0 to produce programs for DOS, or the new OS/2
  313.  operating system. With the OS/2 tools and the PL driver, you can create
  314.  OS/2 programs as easily as DOS programs.
  315.  
  316.  
  317.  ■  Programming Utilities
  318.  
  319.  Microsoft Pascal Version 4.0 has a programming environment with all the
  320.  support enjoyed by users of Microsoft C and FORTRAN: source-level
  321.  debugging, automated program development, and new copies of all the
  322.  utilities.
  323.  
  324.       ■  The CodeView debugger is now fully supported by Pascal.
  325.  
  326.          The debugger is a window-oriented, menu-driven tool for analyzing
  327.          programs. It is further described in Section 3.3, "Overview of the
  328.          CodeView Debugger." The debugger can be used effectively without
  329.          any knowledge of assembly language. Yet it also puts the full power
  330.          of the computer in the hands of an advanced programmer.
  331.  
  332.       ■  The new PL driver makes it easy to invoke the compiler.
  333.  
  334.          To use earlier versions of Pascal, you had to invoke each pass of
  335.          the compiler separately and then invoke the linker. This required a
  336.          minimum of three steps, and often four. The PL driver simplifies
  337.          this process by reducing the four steps to a single command line.
  338.          The PL driver accepts all the options that the compiler itself
  339.          accepts, plus a number of linker options and new options. In
  340.          addition, the PL driver accepts options specified in an environment
  341.          variable so you do not need to specify frequently used options and
  342.          files.
  343.  
  344.       ■  The 87.EXE program checks for the presence of a coprocessor.
  345.  
  346.          Version 4.0 includes the program 87.EXE, which tests for the
  347.          presence of a math coprocessor. If this program finds a coprocessor
  348.          present, it tells you whether the 8087, 80287, or 80387 chip is in
  349.          use.
  350.  
  351.       ■  Version 4.0 includes new versions of all the utilities.
  352.  
  353.          The LINK utility has been updated and includes a number of new
  354.          options. In addition to LINK and LIB, Version 4.0 includes MAKE, an
  355.          automated program-development utility; EXEPACK, a file-compression
  356.          utility; EXEMOD, a program for modifying executable files; SETENV,
  357.          a utility that adjusts the environment space; and ERROUT, a utility
  358.          that redirects output from standard error.
  359.  
  360.          Each utility mentioned in the above paragraph is documented in the
  361.          Microsoft CodeView and Utilities manual.
  362.  
  363.  
  364.  ■  Compiler Enhancements
  365.  
  366.  Although the language definition of Version 4.0 is essentially the same as
  367.  the language definition of Version 3.31, the new version does include a
  368.  couple of important enhancements that affect compiler operation:
  369.  
  370.       ■  The compiler uses far memory for the symbol table.
  371.  
  372.          As the compiler finds more and more symbols in your Pascal program,
  373.          it simply requests additional memory from the system. The compiler
  374.          no longer faces a 64K (kilobyte) limitation on the size of the
  375.          symbol table. As a result, you are less likely to run out of memory
  376.          when you have a large number of program symbols.
  377.  
  378.       ■  The $INCLUDE metacommand now uses the INCLUDE environment variable.
  379.  
  380.          This fact makes it easier to manage include files. If you move your
  381.          include files to a new directory, the only adjustment you need make
  382.          is to the environment variable INCLUDE. Whenever you compile a
  383.          program that uses the $INCLUDE metacommand, the Pascal compiler
  384.          automatically searches the proper directories.
  385.  
  386.  
  387.  ■  Automatic Installation
  388.  
  389.  Version 4.0 includes a SETUP program, which copies the files on the Pascal
  390.  master disks to the directories you specify. The SETUP program is described
  391.  in Section 1.5, "Setting Up Microsoft Pascal." Section 1.5 also gives
  392.  instructions for use.
  393.  
  394.  
  395.  ■  Additional Documentation
  396.  
  397.  As mentioned above, this version includes the Microsoft CodeView and
  398.  Utilities manual. Also in the same binder is the Microsoft Mixed-Language
  399.  Programming Guide. This guide supersedes the old documentation on calling
  400.  C, FORTRAN, and assembly language. It includes more examples than the old
  401.  documentation and gives special attention to topics such as passing
  402.  strings, arrays, and records.
  403.  
  404.  
  405.  1.3  Unimplemented Features
  406.  
  407.  The following list includes features mentioned in the reference manual
  408.  that are not yet implemented. (Because these features were not implemented
  409.  in earlier versions, Version 4.0 does not represent any loss of
  410.  functionality.)
  411.  
  412.  You should look over this list carefully. When using Pascal 4.0, you should
  413.  refer to this list if you find a language feature that does not appear to
  414.  work.
  415.  
  416.       1. The MARKAS and RELEAS procedures are not supported.
  417.  
  418.       2. The $INITCHK metacommand does not check for the presence of
  419.          uninitialized REAL variables.
  420.  
  421.       3. The OTHERWISE keyword is not accepted in RECORD declarations.
  422.  
  423.       4. Code is generated for PURE functions, but no checking is done.
  424.  
  425.       5. The extend-level operators SHL, SHR, and ISR are not available.
  426.  
  427.       6. No checking is done for invalid GOTO statements.
  428.  
  429.       7. READ, READLN, and DECODE cannot have M and N parameters.
  430.  
  431.       8. Enumerated I/O, permitting reading and writing of enumerated
  432.          constants in their character-string form, is not available.
  433.  
  434.       9. The metacommands $TAGCK, $STANDARD, $EXTEND, and $SYSTEM have no
  435.          effect.
  436.  
  437.      10. The $INCONST metacommand does not accept string constants.
  438.  
  439.  
  440.  1.4  Disk Contents
  441.  
  442.  We recommend that you take the following steps as soon as you unwrap your
  443.  Pascal 4.0 disks:
  444.  
  445.       1. First, make backups of the original disks. You can use either the
  446.          COPY or DISKCOPY commands supported by DOS. It is not necessary to
  447.          make backups in order to run the compiler, but this step helps
  448.          insure you against a loss of files.
  449.  
  450.       2. Then run the SETUP program described in the next section. Running
  451.          SETUP is completely optional, but it may save you time in
  452.          installing the files that run the Pascal compiler and utilities.
  453.  
  454.  To verify the disks in the package have all the correct files, consult the
  455.  PACKING.LST file on Disk 1 of the set. This file is an ordinary ASCII
  456.  (American Standard Code for Information Interchange) text file, which you
  457.  can send directly to the printer or view with the DOS TYPE command. The
  458.  PACKING.LST file specifies the files you can expect to find on the retail
  459.  distribution disks or backups you make. The PACKING.LST file also gives a
  460.  brief summary of the contents of each file.
  461.  
  462.  
  463.  1.5  Setting Up Microsoft(R) Pascal
  464.  
  465.  Version 4.0 includes a SETUP program that automatically copies files from
  466.  the Pascal master disks or backups, creates any necessary directories on
  467.  your fixed disk, and builds appropriate libraries.
  468.  
  469.  The SETUP program also creates files for changing your PATH variable and
  470.  creating additional environment variables. You can use these files as they
  471.  are, or add their contents to your AUTOEXEC.BAT file. In addition, the
  472.  SETUP program also creates a file containing entries that allocate the
  473.  buffers and files needed to run the compiler. You should add the contents
  474.  of this file to your CONFIG.SYS file. See Section 1.5.3 below for a
  475.  description of these files.
  476.  
  477.  The libraries that the SETUP program creates depend on the math option and
  478.  operating system choices you make during setup. See Section 1.5.5,
  479.  "Operating System Choice and Library Names," for more information about
  480.  the libraries the SETUP program creates.
  481.  
  482.  ───────────────────────────────────────────────────────────────────────────
  483.  Warning
  484.       It is possible to specify directories that have old Pascal or
  485.       utilities files in them. If you do, the SETUP program overwrites the
  486.       old files. In fact, the SETUP program overwrites any file that has the
  487.       same name as a file on the Pascal master disks or your backups.
  488.  ───────────────────────────────────────────────────────────────────────────
  489.  
  490.  
  491.  1.5.1  Running the SETUP Program
  492.  
  493.  To run the SETUP program, place the disk containing SETUP in drive A, make
  494.  A the default drive (type A: and press ENTER), and type one of these two
  495.  commands:
  496.  
  497.  SETUP
  498.  SETUP /N
  499.  
  500.  The /N option lets you run the SETUP program without actually installing
  501.  the software. You can use the option to see what the SETUP program would do
  502.  when you select certain options.
  503.  
  504.  The SETUP program includes another option, /L, that lets you create
  505.  libraries without going through the entire setup procedure. See Section
  506.  1.5.4, "Building Libraries," for more information.
  507.  
  508.  The SETUP program displays a series of screens asking you questions about
  509.  how you would like to set up Pascal. Each question is followed by a default
  510.  answer in brackets ([]). Press ENTER if the default answer is correct. If
  511.  the default answer is incorrect, you can enter your choice and then press
  512.  ENTER. Use the BACKSPACE key to make any corrections before you press
  513.  ENTER. The SETUP program beeps and displays an error message if your entry
  514.  is not a valid choice.
  515.  
  516.  When you have answered all of the questions, the SETUP program displays the
  517.  options you have selected and asks you if you would like to make any
  518.  changes. If you respond positively by pressing Y and ENTER, the SETUP
  519.  program takes you through the screens again, displaying your previous
  520.  answers to questions as the default values.
  521.  
  522.  When you press N and ENTER in response to the question about making changes
  523.  to your choices, the SETUP program begins the setup process. The SETUP
  524.  program asks you to change disks in the A drive as necessary.
  525.  
  526.  
  527.  1.5.2  Directories Created by the SETUP program
  528.  
  529.  Depending on which options you select when you set up Pascal, the SETUP
  530.  program may create one or more default directories. The names of the
  531.  default directories and their contents are as follows:
  532.  
  533.    Directory      Contents
  534.    ─────────────────────────────────────────────────────────────────────────
  535.    \BINB          Bound versions of the compiler, linker, and utilities.
  536.                   Bound versions run under DOS and real-mode OS/2, as well
  537.                   as protected-mode OS/2.
  538.  
  539.    \BINP          Utilities and run-time modules that run only under
  540.                   protected-mode OS/2.
  541.  
  542.    \BIN           Utilities and run-time modules that run only under DOS or
  543.                   real-mode OS/2.
  544.  
  545.    \LIB           Pascal libraries and object files.
  546.  
  547.    \INCLUDE       Pascal include files.
  548.  
  549.    \PWORK         Sample Pascal programs and include files.
  550.  
  551.  If you specify directory names other than the default names, the SETUP
  552.  program uses the default directories.
  553.  
  554.  
  555.  1.5.3  Environment Variable and Configuration Files
  556.  
  557.  When you run the SETUP program, it creates files you can add to your
  558.  CONFIG.SYS and AUTOEXEC.BAT files. Commands in these files set environment
  559.  variables and system configuration to make it easier to use Pascal. The
  560.  following list describes the files, when they are created, and their
  561.  contents:
  562.  
  563.    File            Contents
  564.    ────────────────────────────────────────────────────────────────────────
  565.    NEW-VARS.BAT    Commands to set environment variables for the locations
  566.                    of binary, library, and include files. This file is
  567.                    created when you choose to set up for DOS or real-mode
  568.                    OS/2. You may run this file as a batch file, or add its
  569.                    contents to your AUTOEXEC.BAT file so the commands are
  570.                    performed whenever you start your system.
  571.  
  572.    NEW-PATH.CMD    Commands to set environment variables for binary,
  573.                    library, and include files. This file is created when
  574.                    you set up for protected-mode OS/2. You may run this
  575.                    file as a batch file, or add its contents to the file
  576.                    automatically executed by the /K command in the PROTSHELL
  577.                    line of your CONFIG.SYS file. See the Microsoft Operating
  578.                    System/2 User's Guide for more information.
  579.  
  580.    NEWCONF.SYS     Commands to allocate the number of files and file buffers
  581.                    required by Pascal. This file is always created. Copy the
  582.                    commands in this file to your CONFIG.SYS file.
  583.  
  584.  The SETUP program places these files in the root directory of the
  585.  destination drive.
  586.  
  587.  The SETUP program creates all three files when you set up for both OS/2
  588.  protected mode, and DOS and OS/2 real mode.
  589.  
  590.  
  591.  1.5.4  Building Libraries
  592.  
  593.  You can run the SETUP program with the /L option when you want to create
  594.  additional libraries.
  595.  
  596.  When you use the /L option, the SETUP program only takes you through the
  597.  questions required to create a library and it copies only the files it
  598.  needs to build the libraries.
  599.  
  600.  
  601.  1.5.5  Operating System Choice and Library Names
  602.  
  603.  Setting up for DOS creates libraries that can be used only under DOS or
  604.  under real-mode OS/2. The libraries cannot be used in protected-mode OS/2
  605.  programs. Specifying OS/2 for the operating system makes libraries that can
  606.  be used only under OS/2 in protected mode. In either case, the libraries
  607.  are the default libraries selected by the PL driver when you compile your
  608.  program.
  609.  
  610.  Choosing to set up for both operating systems creates two sets of
  611.  libraries--one set for DOS and real-mode OS/2, the other for protected-mode
  612.  OS/2. When you compile your program, you must tell the PL driver which set
  613.  of libraries to use. See Section 2, "Using the PL Driver," for more
  614.  information.
  615.  
  616.  The SETUP program creates libraries with names having the following form
  617.  when you set up for a single operating system:
  618.  
  619.  LIBPASmath.LIB
  620.  
  621.  The math argument is a single character indicating the type of math:
  622.  
  623.    Argument       Math Option
  624.    ─────────────────────────────────────────────────────────────────────────
  625.    A              Alternate math
  626.  
  627.    D              Decimal math
  628.  
  629.    E              Coprocessor emulation
  630.  
  631.    7              Math coprocessor
  632.  
  633.  
  634.  For example, a default library using alternate math would be named
  635.  LIBPASA.LIB.
  636.  
  637.  Selecting dual mode creates libraries with names in the form below:
  638.  
  639.  LIBPAS<math><mode>.LIB
  640.  
  641.  The math argument is the same as for the default libraries. The mode
  642.  argument is a single character representing the mode that the libraries can
  643.  be used in--R for real-mode libraries that can be used under DOS or in
  644.  real-mode OS/2, or P for protected-mode libraries that can be used only in
  645.  OS/2 protected mode. For example, a library for OS/2 protected mode using
  646.  alternate math would have LIBPASAP.LIB as a name.
  647.  
  648.  The following table shows the libraries created for different operating
  649.  choices during set up(<math> is the letter representing the math option):
  650.  
  651.    Operating System Choice        Library
  652.    ─────────────────────────────────────────────────────────────────────────
  653.    MS-DOS or real-mode OS/2       LIBPAS<math>.LIB
  654.  
  655.    Protected-mode OS/2            LIBPAS<math>.LIB
  656.  
  657.    Dual mode (real- and           LIBPAS<math>P.LIB
  658.    protected-mode OS/2)
  659.  
  660.                                   LIBPAS<math>R.LIB
  661.  
  662.  ───────────────────────────────────────────────────────────────────────────
  663.  Note
  664.       You can use protected-mode libraries to create applications that run
  665.       in real mode by creating a protected-mode application and using the
  666.       BIND utility. See Section 3.2, "Binding Programs to Run Under Both DOS
  667.       and OS/2," for more information.
  668.  ───────────────────────────────────────────────────────────────────────────
  669.  
  670.  
  671.  
  672.  Section 2  Using the PL Driver
  673.  
  674.  ───────────────────────────────────────────────────────────────────────────
  675.  
  676.  
  677.  
  678.  The Pascal/Link (PL) driver program simplifies the use of the linker and
  679.  compiler. The Pascal compiler consists of three executable files--PAS1,
  680.  PAS2, and PAS3--each performing a different pass of the compiler. With the
  681.  PL driver, you need only enter one command to run each pass of the compiler
  682.  that you need to have executed. In addition, the PL driver will also run
  683.  the linker.
  684.  
  685.  The PL driver is flexible. You can use it to link object files, compile
  686.  source files without linking, or invoke both the compiler and linker with a
  687.  single command. The PL driver handles command-line options more effectively
  688.  than a batch file could; it accepts a wide variety of options and passes
  689.  each option to the compiler or the linker, as appropriate.
  690.  
  691.  This section presents directions for use of the PL driver and describes the
  692.  purpose of each option. Section 2.1 presents the PL command line; Section
  693.  2.2 describes the PL environment variable; Section 2.3 tells you about
  694.  options to select libraries when compiling for both the OS/2 and DOS
  695.  operating systems; Section 2.4 explains how to specify overlays on the PL
  696.  command line; Section 2.5 describes how the driver handles .LIB and .DEF
  697.  files; Section 2.6 lists options that correspond to PAS1 options; and
  698.  Section 2.7 lists other PL options.
  699.  
  700.  
  701.  2.1  The PL Command Line
  702.  
  703.  ■  Syntax
  704.  
  705.  PL [ option...] file...[/link linkoptions]
  706.  
  707.  In the syntax display above, the position of options on the command line is
  708.  not significant, except where noted in this section. The position of files
  709.  on the command line is generally not significant, but the main module must
  710.  be listed first if you are going to produce an executable file. You can use
  711.  any number of files and options, and you can place them in any order. The
  712.  only syntactic requirements are that PL must appear at the beginning of the
  713.  command line and there must be at least one file.
  714.  
  715.  In contrast to the PAS1 option, the PL driver has no separate fields and
  716.  does not accept commas and colons on the command line. To specify source-
  717.  list, object-list, and executable-file fields, use the options presented in
  718.  Section 2.3, "Specifying Libraries."
  719.  
  720.  Options must be preceded either by a dash (-) or a forward slash (/).
  721.  Otherwise, the PL driver interprets an option as a file name. For the sake
  722.  of simplicity, only the slash (/) is used in the lists and examples of
  723.  Section 2. However, with respect to the PL driver, these two kinds of
  724.  punctuation are interchangeable.
  725.  
  726.  Case is significant with options; for example, /FO cannot be used in place
  727.  of the /Fo option.
  728.  
  729.  The PL driver uses the following rules to determine what to do with each
  730.  file on the command line:
  731.  
  732.       1. If the file has a .PAS extension, the PL driver compiles it and
  733.          produces an object file. The PL driver then links this object file
  734.          unless you specify the /c option (described in Section 2.7.1,
  735.          "Invoking the Compiler Only (/c)").
  736.  
  737.       2. If the file has a .OBJ extension, the PL driver invokes the linker.
  738.          However, the PL driver finishes compiling all files with a .PAS
  739.          extension before it proceeds to linking. By default, the executable
  740.          file that the linker produces has the same base name as the first
  741.          module (see the examples below).
  742.  
  743.       3. If you give a file name with no extension, then the PL driver
  744.          assumes a .OBJ extension.
  745.  
  746.  
  747.  ■  Example
  748.  
  749.  PL /Pa MYPROG.PAS
  750.  
  751.  In the example above, the PL driver compiles MYPROG.PAS to produce the
  752.  object file MYPROG.OBJ. The PL driver then links the MYPROG.OBJ file,
  753.  together with any required language libraries, to produce the executable
  754.  file MYPROG.EXE. Note that the /Pa option (array-index checking, described
  755.  below in Section 2.6, "PAS1 Options with the PL Driver") is passed along to
  756.  the compiler.
  757.  
  758.  
  759.  ■  Example
  760.  
  761.  PL PROG2
  762.  
  763.  In the example above, the PL driver links the object file PROG2.OBJ with
  764.  any required libraries to produce the executable file PROG2.EXE. No
  765.  compiling is performed. If the PROG.OBJ file does not already exist, the PL
  766.  driver reports an error message.
  767.  
  768.  
  769.  ■  Example
  770.  
  771.  PL PROG.PAS MOD1.OBJ /Pa MOD2 MOD3.PAS
  772.  
  773.  In the example above, the PL driver first compiles the files PROG.PAS and
  774.  MOD3.PAS. It then invokes the linker to link the object files--PROG.OBJ,
  775.  MOD1.OBJ, MOD2.OBJ, and MOD3.OBJ--to produce the executable file PROG.EXE.
  776.  Note that the PL driver assumes a .OBJ extension for MOD2, and that the /Pa
  777.  option is passed along to the compiler.
  778.  
  779.  
  780.  2.2  The PL Environment Variable
  781.  
  782.  The PL environment variable provides a convenient way to specify frequently
  783.  used options and files without entering the options and files on the
  784.  command line. If the PL environment variable exists, the PL program adds
  785.  the options specified by the variable to the command line when you compile
  786.  your program. To set the variable, use the SET command. For example, the
  787.  following SET command sets the PL variable to compile and link programs for
  788.  use with the Microsoft CodeView debugger:
  789.  
  790.  SET PL = /Zi /Pd
  791.  
  792.  It is usually easiest to add the SET command to your AUTOEXEC file rather
  793.  than entering the command each time you start your machine.
  794.  
  795.  Information specified in the PL variable is processed before options
  796.  specified in the command line. The /LINK options are an exception. The
  797.  /LINK options specified in the PL variable are processed after other
  798.  options, but before the /LINK options specified on the command line. For
  799.  example, if the PL environment variable is set to /Zi /Od /LINK /I, then
  800.  the following two commands are equivalent:
  801.  
  802.  PL MAINPGM.PAS MODULE1.PAS /LINK /NOP
  803.  
  804.  PL /Zi /Pd MAINPGM.PAS MODULE1.PAS /LINK /I /NOP
  805.  
  806.  ───────────────────────────────────────────────────────────────────────────
  807.  Note
  808.       Because an equal sign (=) is interpreted as part of the SET command,
  809.       you cannot use an equal sign in the /D option in the PL variable.
  810.  ───────────────────────────────────────────────────────────────────────────
  811.  
  812.  
  813.  2.3  Specifying Libraries
  814.  
  815.  If you set up the compiler to use either the OS/2 or the DOS operating
  816.  system, but not both, you do not need to specify a run-time library on the
  817.  PL command line--the PL program automatically selects the appropriate
  818.  default library.
  819.  
  820.  If you choose to set up the compiler to create both OS/2 and DOS programs,
  821.  you must use one of the library options to tell the PL program whether to
  822.  use real-mode libraries for DOS or OS/2 real mode, or to use OS/2
  823.  protected-mode libraries. To compile an DOS or OS/2 real-mode application,
  824.  use the /Lr command-line option. To compile an OS/2 protected-mode program,
  825.  use the /Lp command-line option.  For example, the following command
  826.  compiles and links AVERAGES.PAS for use under DOS or real-mode OS/2:
  827.  
  828.  @PROG=PL/Lr AVERAGES.PAS
  829.  
  830.  To compile and link the same program to run in protected-mode OS/2, you
  831.  would use a command like the following:
  832.  
  833.  PL /Lp AVERAGES.PAS
  834.  
  835.  ───────────────────────────────────────────────────────────────────────────
  836.  Note
  837.       You can also use the /Lc option to specify real-mode libraries.
  838.  ───────────────────────────────────────────────────────────────────────────
  839.  
  840.  A .DEF file can only be specified for OS/2 protected-mode programs. Using a
  841.  .DEF file on a command line including the /Lr (real-mode libraries) option
  842.  produces the following warning message: .DEF files supported in protect
  843.  mode only. See the Microsoft CodeView and Utilities Manual Update for more
  844.  information about .DEF files.
  845.  
  846.  If you write most of your programs for one operating system, and only
  847.  occasionally write programs for the other, you can use the PL environment
  848.  variable to set the library option. For example, setting the PL environment
  849.  variable as follows lets you automatically compile and link using the real-
  850.  mode libraries:
  851.  
  852.  SET PL = /Lr
  853.  
  854.  With PL set as above, you could compile and link a protected-mode OS/2
  855.  program by specifying the protected-mode library option on the command line
  856.  (command line options override options specified by the PL environment
  857.  variable):
  858.  
  859.  PL /Lp AVERAGES.PAS
  860.  
  861.  You can also rename the libraries you use regularly so that they have the
  862.  corresponding default names. Then you can specify the other operating
  863.  system, when needed, by using the appropriate library option.
  864.  
  865.  
  866.  2.4  Overlays
  867.  
  868.  The PL driver included with Version 4.0 lets you specify program overlays
  869.  on the command line. Overlays let different modules use the same area of
  870.  memory. When modules are overlaid, only one module is in memory, although
  871.  copies of both are kept on the disk. When the program needs the other
  872.  module, the other module is read into memory from the disk. See Chapter 12,
  873.  "Linking Object Files with LINK," in the Microsoft CodeView and Utilities
  874.  manual for more information about overlays.
  875.  
  876.  You specify an overlay on the PL command line by enclosing the modules to
  877.  be overlaid in parentheses. For example, the following command line tells
  878.  the PL driver that the modules OVER1.PAS and OVER2.PAS are to be overlaid:
  879.  
  880.  PL MAIN.PAS (OVER1.PAS OVER2.PAS)
  881.  
  882.  
  883.  2.5  Specifying .LIB and .DEF Files
  884.  
  885.  You can mix .LIB and .DEF files on the PL command line with other options
  886.  and files. The PL driver sorts through the file names and sends them in the
  887.  correct order to the linker. For example, the following command compiles
  888.  the program and links it by using the indicated .LIB and .DEF files (the
  889.  MYDEF.DEF and MYLIB.LIB files are reversed from the LINK command order):
  890.  
  891.  PL MAIN.PAS MYDEF.DEF MYLIB.LIB
  892.  
  893.  The PL driver automatically changes the order of the .DEF and .LIB files
  894.  before invoking the linker.
  895.  
  896.  
  897.  2.6  PAS1 Options with the PL Driver
  898.  
  899.  When you use the PL driver instead of the PAS1 option, you do not lose any
  900.  functionality. You can specify any of the PAS1 options with the PL driver.
  901.  However, the PL driver accepts these options in a modified form, which is
  902.  presented below.
  903.  
  904.  You can use any number of the options listed here, along with any number of
  905.  the options described in Section 2.3, "Specifying Libraries." As far as the
  906.  PL driver is concerned, there is no essential difference between the two
  907.  groups of options. This grouping is for the sake of convenience.
  908.  
  909.  
  910.  ■  Syntax
  911.  
  912.  To specify a PAS1 option for use with the PL driver, use the following
  913.  syntax:
  914.  
  915.  /Px
  916.  
  917.  where x is the lowercase equivalent of a PAS1 option. For example, to use
  918.  the /A (array-index checking) option with the PL driver, enter it as /Pa.
  919.  
  920.  Table 2.1 below summarizes the correspondence between PL options, PAS1
  921.  options, and metacommands, and describes the functions of these features.
  922.  
  923.  On each row in the table, the PL option, PAS1 option, and metacommand all
  924.  perform the same function, but each is entered in a different way. You can
  925.  use a metacommand by entering it directly into the source file on its own
  926.  line. You can enter a PL option when you use the PL driver, and a PAS1
  927.  option when you invoke PAS1 directly.
  928.  
  929.  
  930.  Table 2.1
  931.  PAS1 Options in Pascal
  932.  
  933. ╓┌─────────────────┌─────────────────┌──────────────┌────────────────────────╖
  934.                                      Metacommand
  935.  PL                PAS1              Equivalent     Description
  936.  ──────────────────────────────────────────────────────────────────────────
  937.  /Dsymbol[=value]  /Xsymbol[=value]  None           Define a string or
  938.                                                     numeric constant
  939.  /Idirectory       /Odirectory       None           Specify directory to
  940.                                                     search for include files
  941.  /Pa               /A                $INDEXCK+      Check array indexing
  942.  /Pc               /C                $DECMATH+      Use decimal math
  943.  /Pd               /D                $DEBUG+        Enable debug options
  944.  /Pe               /E                $ENTRY+        Enable procedure
  945.                                                     entry/exit debugging
  946.  /Pf               /F                $FLOATCALLS-   Generate in-line
  947.                                      Metacommand
  948.  PL                PAS1              Equivalent     Description
  949. /Pf               /F                $FLOATCALLS-   Generate in-line
  950.                                                     floating-point
  951.                                                     instructions
  952.  /Pi               /I                $INITCK+       Check for uninitialized
  953.                                                     variables
  954.  /Pl               /L                $LINE+         Generate line-number
  955.                                                     information
  956.  /Pm               /M                $MATHCK+       Check for math errors
  957.  /Pn               /N                $NILCK+        Check for NIL pointer
  958.                                                     usage
  959.  /Pq               /Q                $DEBUG-        Disable debugging
  960.                                                     options
  961.  /Pr               /R                $RANGECK+      Check subranges
  962.  /Ps               /S                $STACKCK+      Check for stack
  963.                                                     overflows
  964.  /Pt               /T                $TAGCK+        Check tag fields
  965.  /Pw               /W                $WINDOWS+      Include WINDOWS
  966.                                                     prologue/epilogue
  967.  /X                /V                None           Ignore the INCLUDE
  968.                                      Metacommand
  969.  PL                PAS1              Equivalent     Description
  970. /X                /V                None           Ignore the INCLUDE
  971.                                                     environment variable
  972.  /Zd               /Y                               Produce line number
  973.                                                     information for the
  974.                                                     CodeView debugger
  975.  /Z:               /Z                None           Produce complete
  976.                                                     CodeView information
  977.  
  978.  
  979.  For more information on PAS1 options and metacommands, see Section 5.4,
  980.  "Pass One Compiler Switches," in the user's guide.
  981.  
  982.  
  983.  ■  Example
  984.  
  985.  PL /Pa /Pi /Pn PROGRAMX.PAS
  986.  
  987.  In the example above, the PL driver compiles and links the PROGRAMX.PAS
  988.  file and turns on checking for array indexes, uninitialized variables, and
  989.  NIL pointer usage. The PL command produces the same result as the following
  990.  series of commands:
  991.  
  992.  PAS1 /A /I /N PROGRAMX;
  993.  
  994.  PAS2 LINK PROGRAMX;
  995.  
  996.  The PL driver does not invoke the PAS3.EXE file because no listing file is
  997.  specified, making a third pass unnecessary.
  998.  
  999.  
  1000.  2.7  Other PL Options
  1001.  
  1002.  This section presents PL options that do not correspond to PAS1 or library
  1003.  options. Some of these options correspond to fields of the PAS1 option;
  1004.  these options can be useful because the PL driver does not have separate
  1005.  fields and will not prompt you for file names.
  1006.  
  1007.  Other options presented in this section represent input to the linker and
  1008.  some new options. To ensure that all PL options work, you should use only
  1009.  compiler files provided with Version 4.0.
  1010.  
  1011.  This section begins with a summary of the options and continues with a
  1012.  section on each option.
  1013.  
  1014. ╓┌─────────────────────┌─────────────────────────────────────────────────────╖
  1015.    Option              Description
  1016.    ────────────────────────────────────────────────────────────────────────
  1017.    /c                  Directs the PL driver to run only the compiler, not
  1018.                        the linker.
  1019.  
  1020.    /Dsymbol[=value]    Defines a string or numeric constant. This constant
  1021.                        can be one referred to in the Pascal source code.
  1022.  
  1023.    /FPx                Chooses a floating-point math package.
  1024.  
  1025.    /Fl[name]           Produces a listing file (PAS1 list-file field).
  1026.  
  1027.    /Fc[name]           Produces a code-listing file (PAS1 object-listing
  1028.                        field).
  1029.  
  1030.    /Fm[name]           Produces a link-map file (input to the linker).
  1031.    Option              Description
  1032.   /Fm[name]           Produces a link-map file (input to the linker).
  1033.  
  1034.    /Fename             Names the executable file (input to the linker).
  1035.  
  1036.    /Foname             Names the object file (PAS1 object-file field).
  1037.  
  1038.    /Idirectory         Specifies directory to be searched for include files.
  1039.  
  1040.    /link [opt] [lib]   Passes options and libraries directly to the linker.
  1041.  
  1042.    /Ssize              Sets the size of the program stack (2K default size
  1043.                        assumed if no argument is given).
  1044.  
  1045.    /X                  Directs Pascal to ignore the INCLUDE environment
  1046.                        variable.
  1047.  
  1048.    /Zd                 Produces line-number information for the CodeView
  1049.                        debugger. This option affects both compiler and
  1050.                        linker operation.
  1051.  
  1052.    Option              Description
  1053. 
  1054.    /Zi                 Produces complete CodeView information. This option
  1055.                        affects both compiler and linker operation.
  1056.  
  1057.    /Zz                 Produces Microsoft-Editor-style, error-message
  1058.                        output.
  1059.  
  1060.  Exact syntax for the use of each option is provided below. With the
  1061.  exception of the /link option, no space should be typed between an option
  1062.  and any argument that the option takes.
  1063.  
  1064.  
  1065.  2.7.1  Invoking the Compiler Only (/c)
  1066.  
  1067.  ■  Syntax
  1068.  
  1069.  /c
  1070.  
  1071.  When you use this option with the PL driver, only the compiler is invoked.
  1072.  However, you must still use the .PAS extension with all Pascal source files
  1073.  you wish to compile. When /c is specified, the PL driver simply ignores any
  1074.  object files you give on the command line.
  1075.  
  1076.  
  1077.  2.7.2  Defining a Constant on the Command Line (/D)
  1078.  
  1079.  ■  Syntax
  1080.  
  1081.  /Dsymbol[=value]
  1082.  
  1083.  In the syntax display above, symbol is the name of a constant that appears
  1084.  in a Pascal source file and value is a string or constant value. If value
  1085.  is a string, you need to enclose it in single quotation marks ('). No space
  1086.  should appear between /D and symbol; or between symbol, the equal sign (=),
  1087.  and value.
  1088.  
  1089.  The value argument is optional. Use the equal sign (=) if and only if you
  1090.  include value. If you omit this argument, then the PL driver considers
  1091.  symbol to be defined as an integer with a value of 1.
  1092.  
  1093.  In the following example, the PL driver sets the constant MONITOR equal to
  1094.  the string 'EGA'. The information is then used in compiling the program
  1095.  SCREEN.PAS, which may refer to the constant MONITOR.
  1096.  
  1097.  
  1098.  ■  Example
  1099.  
  1100.  PL /DMONITOR='EGA' SCREEN.PAS
  1101.  
  1102.  The /D option can be used in conjunction with the $IFDECL metacommand,
  1103.  described in Section 4.4 of this update. By using the /D option with the
  1104.  $IFDECL language feature, you can achieve more flexibility in how you
  1105.  compile your programs.
  1106.  
  1107.  
  1108.  2.7.3  Choosing a Floating-Point Library (/FPx)
  1109.  
  1110.  ■  Syntax
  1111.  
  1112.  /FPx
  1113.  
  1114.  By default, Pascal attempts to link in the library LIBPASE.LIB, which
  1115.  contains floating-point routines from the emulator math package (see
  1116.  Section 1.5, "Setting Up Microsoft Pascal," for more information). However,
  1117.  you can use the /FP option to direct the PL driver to link to another
  1118.  library. The list below shows the effect for each possible value for x:
  1119.  
  1120.    PL option      Links with:
  1121.    ─────────────────────────────────────────────────────────────────────────
  1122.    /FPa           LIBPASA.LIB  (altmath)
  1123.  
  1124.    /FPd           LIBPASD.LIB  (decmath; also sets the /Pc option)
  1125.  
  1126.    /FPe           LIBPASE.LIB  (emulator, the default)
  1127.  
  1128.    /FPi           LIBPAS7.LIB  (87math; also sets the /Pf option)
  1129.  
  1130.    /FP7           LIBPAS7.LIB  (87math)
  1131.  
  1132.  The /Pc option (/C for PAS1) directs Pascal to link to a library supporting
  1133.  decimal-math calculations. The /Pc option also affects compiler operation,
  1134.  causing Pascal to store floating-point constants in decimal rather than
  1135.  binary representation.
  1136.  
  1137.  The /Pf switch (/F for PAS1) is an option specifying that calls to the 87
  1138.  math coprocessor be made directly from the compiled Pascal code, rather
  1139.  than indirectly through a call to an intermediate library routine. If you
  1140.  have a coprocessor and your program calls floating-point math functions
  1141.  repeatedly, this option can improve performance.
  1142.  
  1143.  
  1144.  2.7.4  Producing a Source-Listing File (/Fl)
  1145.  
  1146.  ■  Syntax
  1147.  
  1148.  /Fl[name]
  1149.  
  1150.  When you want the compiler to produce a formatted source listing, use the
  1151.  /Fl option. Such a listing is particularly useful as a record of compile-
  1152.  time errors.
  1153.  
  1154.  The /Fl option applies to the first Pascal source file that follows the
  1155.  option (as positioned on the command line). Use this option once for each
  1156.  source file you want listed. For example, the command
  1157.  
  1158.  PL /FlONCE.LST ONE.PAS /FlTWICE.LST TWO.PAS THREE.PAS
  1159.  
  1160.  produces two source listings: ONCE.LST, the source listing for the source
  1161.  file ONE.PAS; and TWICE.LST, the source listing for the source file
  1162.  TWO.PAS. Because the source file THREE.PAS was not immediately preceded by
  1163.  the /Fl option, the PL driver produces no source listing for the source
  1164.  file THREE.PAS.
  1165.  
  1166.  If you omit name, then the PL driver  combines the base name of the
  1167.  relevant source file with a .LST extension. If you give only a base name,
  1168.  then the PL driver uses it and assumes a .LST extension.
  1169.  
  1170.  
  1171.  2.7.5  Producing a Code-Listing File (/Fc)
  1172.  
  1173.  ■  Syntax
  1174.  
  1175.  /Fc[name]
  1176.  
  1177.  When you want the compiler to produce an object-code-listing file, use the
  1178.  /Fc option. The object-code listing shows you the assembly code that the
  1179.  compiler produces, in a readable ASCII format.
  1180.  
  1181.  The /Fc option applies to the first Pascal source file that follows the
  1182.  option (as positioned on the command line). Use this option once for each
  1183.  source file for which you want an object-code listing. For example, the
  1184.  command
  1185.  
  1186.  PL /FcONCE.COD ONE.PAS /FcTWICE.COD TWO.PAS THREE.PAS
  1187.  
  1188.  produces two object listings: ONCE.COD, the object-code-listing file for
  1189.  the source file ONE.PAS; and TWICE.COD, the object-code-listing file for
  1190.  the source file TWO.PAS. Because the PL driver produces no object-code-
  1191.  listing file for the source file THREE.PAS, the source file THREE.PAS was
  1192.  not immediately preceded by the /Fc option.
  1193.  
  1194.  If you omit name, then the PL driver combines the base name of the relevant
  1195.  source file with a .COD extension. If you give only a base name, then the
  1196.  PL driver uses it and assumes a .COD extension.
  1197.  
  1198.  
  1199.  2.7.6  Producing a Link-Map File (/Fm)
  1200.  
  1201.  ■  Syntax
  1202.  
  1203.  /Fm[name]
  1204.  
  1205.  The /Fm option corresponds to the map-file field of the linker. If you use
  1206.  this option, the linker produces a map file containing a list of all
  1207.  segments in the executable file. If you omit name, then the linker combines
  1208.  a .MAP extension with the base name of the first module on the command
  1209.  line, giving name to the map file. If you include name, but only give a
  1210.  base name, then the linker assumes a .MAP extension. For example, the
  1211.  command
  1212.  
  1213.  PL /FmSTUFF MYPROG.PAS
  1214.  
  1215.  results in the creation of the map file STUFF.MAP.
  1216.  
  1217.  
  1218.  2.7.7  Naming the Executable File (/Fe)
  1219.  
  1220.  ■  Syntax
  1221.  
  1222.  /Fename
  1223.  
  1224.  The /Fe option corresponds to the executable-file field of the linker. The
  1225.  PL driver attempts to create an executable file whether or not you use this
  1226.  option (unless the /c option is in effect). Therefore, the /Fe option is
  1227.  meaningful only if you provide some argument for name. If you include only
  1228.  a base name, then the linker assumes a .EXE extension. For example, the
  1229.  command
  1230.  
  1231.  PL /FeRUNTHIS MYPROG.PAS
  1232.  
  1233.  results in the creation of the executable file RUNTHIS.EXE. If the /Fe
  1234.  option is not used in the above command, then the linker creates the file
  1235.  MYPROG.EXE.
  1236.  
  1237.  
  1238.  2.7.8  Naming the Object File (/Fo)
  1239.  
  1240.  ■  Syntax
  1241.  
  1242.  /Foname
  1243.  
  1244.  Use the /Fo option when you want to specify a particular name for an object
  1245.  file that the PL driver produces. (Note: this file is distinct from an
  1246.  object file you specify as input on the command line.) Normally, the
  1247.  compiler names an object file by using the base name of the source file and
  1248.  appending a .OBJ extension. For example, the compiler would produce
  1249.  NEATPROG.OBJ when it compiles the NEATPROG.PAS source file. By using the
  1250.  /Fo option, however, you can give the object file any name you want.
  1251.  
  1252.  The /Fo option applies to the first Pascal source file that follows the
  1253.  option (as positioned on the command line). Use this option once for each
  1254.  source file you want to specify the object-file name for. For example, the
  1255.  command
  1256.  
  1257.  PL /FoONCE.OBJ ONE.PAS /FoTWICE.OBJ TWO.PAS THREE.PAS
  1258.  
  1259.  produces three object files, two of which are specified directly by the
  1260.  user and one of which is named implicitly. The PL driver produces ONCE.OBJ
  1261.  from the source file ONE.PAS, TWICE.OBJ from the source file TWO.PAS, and
  1262.  THREE.OBJ from the source file THREE.PAS. Because the source file THREE.PAS
  1263.  was not preceded by the /Fo option, the PL driver assumes the base name
  1264.  THREE and the .OBJ extension.
  1265.  
  1266.  When the PL driver invokes the compiler, it always attempts to produce an
  1267.  object file. For this reason, the /Fo option has no meaning unless you
  1268.  supply a name. If you supply only a base name, then the PL driver assumes a
  1269.  .OBJ extension.
  1270.  
  1271.  
  1272.  2.7.9  Specifying Directories for Include Files (/I)
  1273.  
  1274.  ■  Syntax
  1275.  
  1276.  /Idirectory
  1277.  
  1278.  By using the /I option, you can add to the list of directories where the
  1279.  compiler searches for include files. This option causes the compiler to
  1280.  search the directory you specify before it searches the directories given
  1281.  by the INCLUDE environment variable. You can add more than one include
  1282.  directory by giving the /I command more than once in the PL command line.
  1283.  The compiler searches the directories in order of their appearance on the
  1284.  command line.
  1285.  
  1286.  Directories are searched until the specified include file is found. If the
  1287.  file is not found in the given directories, the current directory, or the
  1288.  directories that are specified in the INCLUDE environment variable, then
  1289.  the compiler prints an error message and stops compiling.
  1290.  
  1291.  
  1292.  ■  Example
  1293.  
  1294.  PL MYPROG.PAS /IA:\INCLUDE /IB:\PAS\INC
  1295.  
  1296.  In the example above, the compiler looks for the include files requested by
  1297.  the source file MYPROG.PAS in the following order: first in the directory
  1298.  A:\INCLUDE, then in the directory B:\PAS\INC, and finally in the directory
  1299.  or directories that are listed in the INCLUDE environment variable.
  1300.  
  1301.  
  1302.  2.7.10  Passing Options and Libraries to LINK (/link)
  1303.  
  1304.  ■  Syntax
  1305.  
  1306.  /link [options] [libraries]
  1307.  
  1308.  When you use this option, all options and libraries that follow the /link
  1309.  option on the command line are passed directly to the linker. The order of
  1310.  the options and the libraries is not significant.
  1311.  
  1312.  For example, with the command line
  1313.  
  1314.  PL foo.pas /link /E grafx.lib
  1315.  
  1316.  the PL driver compiles foo.pas, then invokes the linker, giving foo.pas and
  1317.  grafx.lib as input. The linker is also passed the /E option.
  1318.  
  1319.  
  1320.  2.7.11  Setting the Size of the Program Stack (/S)
  1321.  
  1322.  ■  Syntax
  1323.  
  1324.  /Ssize
  1325.  
  1326.  Use the /S option to set a specific size for your program stack (this will
  1327.  affect the executable file that the PL driver produces). If you do not use
  1328.  this option, a 2K stack is assumed. However, you can use this option to set
  1329.  the stack size in bytes. This number is entered in decimal. You must enter
  1330.  a number less than 65,535 decimal.
  1331.  
  1332.  For more information on the program stack, refer to the /STACK switch in
  1333.  the user's guide.
  1334.  
  1335.  
  1336.  2.7.12  Ignoring the INCLUDE Environment Variable (/X)
  1337.  
  1338.  ■  Syntax
  1339.  
  1340.  /X
  1341.  
  1342.  When you use the /X option, the compiler does not search directories listed
  1343.  in the INCLUDE environment variable in order to find include files.
  1344.  However, the compiler still searches directories specified with the /I
  1345.  option, as long as the /X option appears on the command line before the /I
  1346.  option.
  1347.  
  1348.  The /X option is often used, in conjunction with the /I option, to define
  1349.  the location of include files that have the same name as include files
  1350.  found in other directories, but that contain different definitions.
  1351.  
  1352.  
  1353.  2.7.13  Producing Line-Number Information for the CodeView(R) Debugger
  1354.          (/Zd)
  1355.  
  1356.  ■  Syntax
  1357.  
  1358.  /Zd
  1359.  
  1360.  Use this option to direct the PL driver to produce limited information for
  1361.  the CodeView debugger. This information enables the debugger to trace
  1362.  through your program at the source-line level. This option is similar to
  1363.  the /Zi option, but results in smaller executable files. See the Microsoft
  1364.  CodeView and Utilities manual for more information on the /Zi option.
  1365.  
  1366.  
  1367.  2.7.14  Producing Full Information for the CodeView Debugger (/Zi)
  1368.  
  1369.  ■  Syntax
  1370.  
  1371.  /Zi
  1372.  
  1373.  Use this option to direct the PL driver to produce full line-number and
  1374.  symbolic information for the CodeView debugger. This option enables the
  1375.  debugger to understand both the global and local variables in your program,
  1376.  and to evaluate these variables in expressions. See the Microsoft CodeView
  1377.  and Utilities manual for more information on the /Zi option.
  1378.  
  1379.  
  1380.  2.7.15  Producing Error Output for the Microsoft Editor (/Zz)
  1381.  
  1382.  ■  Syntax
  1383.  
  1384.  /Zz
  1385.  
  1386.  Use this option if you use the Microsoft Editor and want the PL driver to
  1387.  produce error-message output in the proper format for the editor.
  1388.  
  1389.  
  1390.  
  1391.  Section 3  OS/2 Systems Support
  1392.  
  1393.  ───────────────────────────────────────────────────────────────────────────
  1394.  
  1395.  
  1396.  
  1397.  This section briefly describes compiling and linking programs to run under
  1398.  OS/2 as well as binding programs so that they run under either OS/2 or DOS.
  1399.  The section also explains restrictions on using Pascal under OS/2. For
  1400.  detailed information about developing programs for OS/2, see the Microsoft
  1401.  Operating System/2 Programmer's Guide and the Microsoft CodeView and
  1402.  Utilities Update.
  1403.  
  1404.  
  1405.  3.1  Compiling and Linking Under OS/2
  1406.  
  1407.  If you have set up Pascal for programming only under OS/2, you do not need
  1408.  to use any additional options to compile and link with the PL command. Use
  1409.  the PL driver just as you would under the DOS operating system.
  1410.  
  1411.  When you set up Pascal to compile under both the OS/2 and DOS operating
  1412.  systems, you must use one of the library options when compiling and linking
  1413.  with the PL driver. Specifying the /Lr switch selects the real-mode
  1414.  libraries so your program runs under DOS or in real-mode OS/2. The /Lp
  1415.  switch selects the OS/2 protected-mode versions of the libraries and
  1416.  creates a program that runs only in protected mode under OS/2. For example,
  1417.  to compile the BESSEL.PAS source file for OS/2 protected mode, you would
  1418.  use the following command:
  1419.  
  1420.  PL /Lp BESSEL.PAS
  1421.  
  1422.  ───────────────────────────────────────────────────────────────────────────
  1423.  Note
  1424.       You must use the OS/2 (protected mode) version of the CodeView
  1425.       debugger, CVP.EXE, to debug OS/2 programs.
  1426.  ───────────────────────────────────────────────────────────────────────────
  1427.  
  1428.  
  1429.  3.2  Binding Programs To Run Under Both DOS and OS/2
  1430.  
  1431.  You can create programs that run under DOS or in real and protected modes
  1432.  under OS/2 by compiling and linking your program for protected mode and
  1433.  binding it.
  1434.  
  1435.  Binding resolves references to OS/2 dynamic-link libraries so the program
  1436.  runs in both modes and under either operating system.
  1437.  
  1438.  To bind a program, use the BIND command. For example, the following command
  1439.  binds the executable file BESSEL.EXE:
  1440.  
  1441.  BIND BESSEL APILMR.OBJ C:\LIB\DOSCALLS.LIB C:\LIB\API.LIB
  1442.  
  1443.  The APILMR.OBJ file is required. You must also include the full path to the
  1444.  DOSCALLS.LIB and API.LIB files in the command line.
  1445.  
  1446.  See the Microsoft CodeView and Utilities Update for complete information
  1447.  about the BIND utility.
  1448.  
  1449.  ───────────────────────────────────────────────────────────────────────────
  1450.  Note
  1451.       Bound programs cannot be debugged using the CodeView debugger.
  1452.       However, you can use the OS/2 version of CodeView, CVP.EXE, to debug a
  1453.       protected-mode version of the program.
  1454.  ───────────────────────────────────────────────────────────────────────────
  1455.  
  1456.  
  1457.  3.3  OS/2 Protected-Mode Restrictions
  1458.  
  1459.  Code generated by the Pascal compiler cannot be used to build dynamic-link
  1460.  libraries. Furthermore, functions and procedures in PASCAL.LIB--the
  1461.  standard Pascal language library--and in the Pascal floating-point math
  1462.  libraries are non-reentrant. Only one thread can call a non-reentrant
  1463.  routine at a time. To ensure that a thread does not enter a non-reentrant
  1464.  routine until the routine is free, use semaphores or other methods of
  1465.  communication.
  1466.  
  1467.  The INP and OUTP functions can be used with the OS/2 version of the Pascal
  1468.  library only if the following two conditions are met:
  1469.  
  1470.       1. The following statement is inserted into the CONFIG.SYS file for
  1471.          the machine being booted up:
  1472.  
  1473.          IOPL=YES
  1474.  
  1475.       2. The following statement is added to the .DEF file when linking the
  1476.          C library with the Pascal modules:
  1477.  
  1478.          Segments
  1479.  
  1480.          _IOSEG CLASS 'IOSEG_CODE' SHARED MOVABLE EXECUTEONLY IOPL
  1481.  
  1482.  
  1483.  
  1484.  Section 4  Other New Features
  1485.  
  1486.  ───────────────────────────────────────────────────────────────────────────
  1487.  
  1488.  
  1489.  
  1490.  Version 4.0 of Pascal introduces a number of new features. Sections 1 and
  1491.  2 above described the new SETUP and PL programs; Section 3 described OS/2
  1492.  support. This section describes the following other features:
  1493.  
  1494.       ■  Symbol table in far memory
  1495.  
  1496.       ■  Check for math coprocessor (87.EXE)
  1497.  
  1498.       ■  INCLUDE environment variable
  1499.  
  1500.       ■  $IFDECL metacommand
  1501.  
  1502.       ■  CodeView debugger support
  1503.  
  1504.       ■  New utilities
  1505.  
  1506.  All the features listed above have been introduced since the last version,
  1507.  Version 3.31. If you are updating from an earlier version of Microsoft
  1508.  Pascal or are using Microsoft Pascal for the first time, you should also
  1509.  see Sections 5 and 6.
  1510.  
  1511.  
  1512.  4.1  Symbol Table in Far Memory
  1513.  
  1514.  With Version 4.0, you may be able to compile larger modules than you could
  1515.  before. A major reason why previous versions of the compiler ran out of
  1516.  memory was the limited size of the symbol table. Version 4.0 solves this
  1517.  problem by placing the symbol table in far memory, which is limited only by
  1518.  the size of system memory.
  1519.  
  1520.  You do not need to understand the details of compiler operation to make use
  1521.  of this new feature. Nor do you need to use any special options or
  1522.  statements. The greater capacity of the symbol table automatically helps
  1523.  you compile larger source modules.
  1524.  
  1525.  The rest of this section explains symbol-table operation in more detail.
  1526.  
  1527.  
  1528.  ■  The Pascal Symbol Table
  1529.  
  1530.  Like other compiled languages, Microsoft Pascal uses a symbol table to keep
  1531.  track of each unique name in a source file. The table includes the names of
  1532.  all variables, symbolic constants, procedures, and functions. It also
  1533.  provides type information on each entry. This information is required for
  1534.  the compiler to analyze Pascal statements.
  1535.  
  1536.  The symbol table lists names in ASCII format. The more and the longer the
  1537.  names that appear in the table, the more memory is required.
  1538.  
  1539.  
  1540.  ■  Symbol Table in Previous Versions of Pascal
  1541.  
  1542.  Earlier versions of Pascal limited the symbol table to an area of 64K
  1543.  called the DGROUP area. This area also contains the compiler's stack and
  1544.  internal data. The compiler's stack needs to be as large as possible in
  1545.  order to handle deeply nested loops in a Pascal program. When compiling
  1546.  large modules in earlier versions, a user sometimes had to reduce stack
  1547.  size, use shorter names, or break up modules.
  1548.  
  1549.  
  1550.  ■  Version 4.0 Symbol Table
  1551.  
  1552.  Version 4.0 removes the symbol table from the DGROUP area. This leaves more
  1553.  room for the stack. Furthermore, the symbol table is located in far memory
  1554.  and consequently has no 64K limit. (Far memory is manipulated with 32-bit
  1555.  addresses rather than 16-bit addresses, which can address only a range of
  1556.  64K.) The size of the Version 4.0 symbol table is limited only by the
  1557.  amount of main memory you have in your system.
  1558.  
  1559.  ───────────────────────────────────────────────────────────────────────────
  1560.  Note
  1561.       Although the compiler's internal stack can now be larger, it is still
  1562.       limited in size. Therefore, it is still possible to run out of
  1563.       compiler memory when compiling exceptionally complicated modules.
  1564.  ───────────────────────────────────────────────────────────────────────────
  1565.  
  1566.  
  1567.  4.2  Checking for a Math Coprocessor
  1568.  
  1569.  If you work with floating-point libraries, it may be helpful to determine
  1570.  which math coprocessor is available. The 87.EXE program, provided with this
  1571.  version of Pascal, promptly reports coprocessor status.
  1572.  
  1573.  If your system has a coprocessor that has been properly installed and is
  1574.  available for use by programs, then the 87.EXE program reports one of the
  1575.  following messages:
  1576.  
  1577.  8087 is ON
  1578.  
  1579.  80287 is ON
  1580.  
  1581.  80387 is ON
  1582.  
  1583.  If there is no coprocessor or if the coprocessor is not installed, then the
  1584.  87.EXE program reports the following message:
  1585.  
  1586.  Math Coprocessor is OFF
  1587.  
  1588.  The 87.EXE program also checks the coprocessor-equipment flag, which is
  1589.  located in main memory at address 40:10h. If a coprocessor is installed and
  1590.  this switch is off, or if a coprocessor is not installed and the switch is
  1591.  on, then the flag has been incorrectly set and the 87.EXE program displays
  1592.  the message:
  1593.  
  1594.  - equipment switch is set incorrectly
  1595.  
  1596.  All of the messages above are written to standard output, and therefore may
  1597.  be redirected to a file or device with the DOS redirection operator (>).
  1598.  
  1599.  
  1600.  ■  87.EXE Return Codes
  1601.  
  1602.  Upon completion, 87.EXE returns one of the following values:
  1603.  
  1604.    Value          Meaning
  1605.    ─────────────────────────────────────────────────────────────────────────
  1606.    0              8087/80287/80387 is OFF (or not present).
  1607.  
  1608.    1              8087/80287/80387 is ON.
  1609.  
  1610.    2              Coprocessor-equipment switch set incorrectly.
  1611.  
  1612.  Return codes are useful when you invoke a program from a batch file.
  1613.  Consult your DOS documentation for information about return codes.
  1614.  
  1615.  
  1616.  4.3  INCLUDE Environment Variable
  1617.  
  1618.  By taking advantage of the INCLUDE environment variable, Version 4.0
  1619.  provides greater flexibility in the use of include files. You do not need
  1620.  to use include files with Version 4.0 of Pascal; but if you do, the INCLUDE
  1621.  environment variable helps you manage files more easily.
  1622.  
  1623.  The following discussion assumes that you are familiar with the $INCLUDE
  1624.  metacommand. This metacommand directs the compiler to read in an additional
  1625.  source file at compile time. The command is particularly useful if you have
  1626.  a section of source code (for example, a set of variable definitions) that
  1627.  you want to include in several modules or several programs. The $INCLUDE
  1628.  metacommand is described in Section 18.3, "Source File Control," of the
  1629.  reference manual.
  1630.  
  1631.  When you use the $INCLUDE metacommand, the compiler looks for the specified
  1632.  file in this order:
  1633.  
  1634.       1. The specified directory, if you give a complete path name
  1635.  
  1636.       2. The current working directory
  1637.  
  1638.       3. Each directory listed in the INCLUDE environment variable
  1639.  
  1640.  For example, suppose that your source file contains the following
  1641.  metacommand:
  1642.  
  1643.  $INCLUDE \PAS\IAS
  1644.  
  1645.  In addition, the INCLUDE environment variable is set as below:
  1646.  
  1647.  C:\INC;C:\PAS\INC
  1648.  
  1649.  In this case, the compiler attempts to find the file IAS by searching
  1650.  directories in this order:
  1651.  
  1652.       1. The \PAS option on the current drive
  1653.  
  1654.       2. The current working directory
  1655.  
  1656.       3. The \INC option on drive C
  1657.  
  1658.       4. The \PAS\INC option on drive C
  1659.  
  1660.  By using the DOS SET command, you can easily set or change the directories
  1661.  listed in the INCLUDE environment variable. For example, the following
  1662.  command sets INCLUDE to its value in the last example:
  1663.  
  1664.  SET INCLUDE=C:\INC;C:\PAS\INC
  1665.  
  1666.  When you use this command, no spaces should be typed on either side of the
  1667.  equal sign (=), and each directory should be separated by a semi-colon (;).
  1668.  
  1669.  
  1670.  4.4  The $IFDECL Metacommand
  1671.  
  1672.  Pascal 4.0 has a new metacommand, $IFDECL, which provides you additional
  1673.  flexibility in compiling your program.
  1674.  
  1675.  This command can be used in conjunction with the /D option described in
  1676.  Section 2, "Using the PL Driver," of this update. When you precede parts of
  1677.  your program with the $IFDECL metacommand, you can control which portions
  1678.  of your program will actually be compiled; using of the /D option then
  1679.  specifies whether or not these portions of code are recognized or ignored
  1680.  by the compiler.
  1681.  
  1682.  The $IFDECL metacommand uses the same syntax as the $IF metacommand
  1683.  described in Section 18.3, "Source File Control," of the reference manual.
  1684.  The $IFDEF metacommand must appear at the beginning of a comment statement,
  1685.  as in the following:
  1686.  
  1687.  {$IFDECL constant $THEN}
  1688.  
  1689.  When the Pascal compiler encounters the statement above, it checks whether
  1690.  constant is currently defined. If it is, then Pascal compiles all lines of
  1691.  code up to the next {$END} or {$ELSE} statement. If constant is not
  1692.  currently defined, then all code up to the next {$END} or {$ELSE} is
  1693.  skipped.
  1694.  
  1695.  ───────────────────────────────────────────────────────────────────────────
  1696.  Note
  1697.       Do not confuse the metacommands $END and $ELSE with the Pascal
  1698.       keywords END and ELSE. To be recognized as metacommands, $END and
  1699.       $ELSE must include the dollar sign ($) and they must appear within
  1700.       comment statements enclosed by braces ({}).
  1701.  ───────────────────────────────────────────────────────────────────────────
  1702.  
  1703.  ■  Example
  1704.  
  1705.  The following example demonstrates the use of the $IFDECL metacommand in a
  1706.  program that contains hardware-specific code. In this example, the program
  1707.  executes one set of statements when compiled for color-graphics monitors,
  1708.  and another set of statements when compiled for monochrome monitors.
  1709.  
  1710.  {$IFDECL CGA $THEN}
  1711.  .
  1712.  .
  1713.  .
  1714.  (color graphics initialization)
  1715.  .
  1716.  .
  1717.  .
  1718.  {$ELSE}
  1719.  .
  1720.  .
  1721.  .
  1722.  (monochrome initialization)
  1723.  .
  1724.  .
  1725.  .
  1726.  {$END}
  1727.  
  1728.  (rest of program)
  1729.  
  1730.  To compile the program above with CGA (color graphics adapter)
  1731.  initialization, you would type the following command line:
  1732.  
  1733.  PL /DCGA screen.pas
  1734.  
  1735.  To compile the program with monochrome initialization, you would type:
  1736.  
  1737.  PL screen.pas
  1738.  
  1739.  
  1740.  4.5  CodeView Debugger Support
  1741.  
  1742.  Support for the CodeView debugger is one of the major strengths of Version
  1743.  4.0 of Pascal. Using the CodeView debugger may save you hours of work in
  1744.  trying to track down the source of an elusive error.
  1745.  
  1746.  This section first gives an overview of the CodeView debugger with
  1747.  explanations on how to start using it and how it helps you in locating
  1748.  errors. This section then explains exactly how the CodeView debugger is
  1749.  supported by Version 4.0.
  1750.  
  1751.  ───────────────────────────────────────────────────────────────────────────
  1752.  Note
  1753.       The distribution disks include two versions of CodeView--CV.EXE and
  1754.       CVP.EXE. Use the protected-mode version, CVP.EXE, for debugging
  1755.       protected-mode OS/2 programs. See the Microsoft CodeView and Utilities
  1756.       Update for information about using the protected-mode CodeView
  1757.       debugger.
  1758.  ───────────────────────────────────────────────────────────────────────────
  1759.  
  1760.  
  1761.  4.5.1  Overview of the CodeView Debugger
  1762.  
  1763.  The CodeView debugger is a tool for analyzing the behavior of programs as
  1764.  they execute. Normally, you create a program and then let it run, giving
  1765.  control of the computer to the program until the program is finished. When
  1766.  you use the CodeView debugger, you have many ways of controlling a
  1767.  program's execution. You can execute a single Pascal statement at a time.
  1768.  Or you can let the program execute until it reaches a specified line, or
  1769.  even let the program run until a Boolean condition (which you specify in
  1770.  advance) becomes true.
  1771.  
  1772.  In and of itself, controlling execution is only moderately useful. What
  1773.  makes the debugger so powerful is that after having executed a certain
  1774.  portion of the program, you can examine the value of any variable,
  1775.  including local variables. Furthermore, you can examine the value of any
  1776.  expression that combines program variables and Pascal syntax. If you need
  1777.  to continually watch a variable or expression, you can place it in the
  1778.  debugger's watch window. As variables change, the watch window updates and
  1779.  displays current values.
  1780.  
  1781.  The CodeView debugger is designed to benefit both new and advanced users.
  1782.  The CodeView display consists of a series of windows and easy-to-use menus.
  1783.  The menus can be manipulated equally well with either a Microsoft mouse or
  1784.  the keyboard. For advanced users, the debugger provides the ability to
  1785.  examine any area of memory, communicate with hardware ports, assemble code,
  1786.  and view the machine instructions that correspond to each Pascal statement.
  1787.  
  1788.  All of the features above are described in the Microsoft CodeView and
  1789.  Utilities manual. To get a good feel for how to use the debugger, you may
  1790.  first want to try running the sample session on the CodeView disk. To do
  1791.  so, place this disk in drive A, make A the current drive, and type SAMPLE.
  1792.  
  1793.  
  1794.  4.5.2  Pascal CodeView Support
  1795.  
  1796.  The CodeView debugger helps you debug programs that are written in
  1797.  Microsoft C, FORTRAN, and the Macro Assembler. Version 4.0 of Pascal
  1798.  contains the first version of the CodeView debugger that works with Pascal.
  1799.  Pascal support consists of two enhancements:
  1800.  
  1801.       1. Version 4.0 can produce executable files for use with the CodeView
  1802.          debugger. (This requires a special executable file format that
  1803.          previous versions do not support.)
  1804.  
  1805.       2. The debugger itself has a built-in Pascal interpreter that
  1806.          evaluates Pascal expressions you specify in CodeView commands.
  1807.  
  1808.  In order to make best use of the CodeView debugger, make sure you use both
  1809.  the new Pascal compiler and the current version of the CodeView debugger,
  1810.  included with Version 4.0 of Pascal.
  1811.  
  1812.  When you run the compiler with the PL driver, type the /Zi option on the
  1813.  command line. (When you run the compiler with the PAS1 option, type the /Z
  1814.  option on the command line.) This option causes creation of symbolic
  1815.  information for the CodeView debugger. You can also use the /Zd option,
  1816.  which provides less debugging information and smaller executable files. If
  1817.  you link separately, use the current linker and specify the /CO option.
  1818.  
  1819.  These options are further explained, with examples, in the Microsoft
  1820.  CodeView and Utilities manual.
  1821.  
  1822.  ───────────────────────────────────────────────────────────────────────────
  1823.  Warning
  1824.       Programs with many procedures, functions, record fields, and symbols,
  1825.       may get an "Out of memory" error when compiled with the /Zi option
  1826.       because using the /Zi option requires twice as much symbol table
  1827.       space. Break the program up into smaller modules to solve the problem.
  1828.  ───────────────────────────────────────────────────────────────────────────
  1829.  
  1830.  
  1831.  4.6  New Versions of the Utilities
  1832.  
  1833.  The Version 4.0 package includes the current versions of the linker (LINK)
  1834.  and library manager (LIB). The linker includes several new options for code
  1835.  optimization, CodeView support, and the creation of libraries for use with
  1836.  Microsoft QuickBASIC and QuickC. See the Microsoft CodeView and Utilities
  1837.  manual for complete documentation on LINK and LIB.
  1838.  
  1839.  ───────────────────────────────────────────────────────────────────────────
  1840.  Note
  1841.       There are many versions of LINK in circulation, including an old
  1842.       version released with every DOS operating system. To take advantage of
  1843.       LINK's new features or to use the CodeView debugger, make sure you
  1844.       install the version included with this package.
  1845.  ───────────────────────────────────────────────────────────────────────────
  1846.  
  1847.  Several new utilities are included with Version 4.0 of Pascal:
  1848.  
  1849.       ■  MAKE, an automated program-development tool.
  1850.  
  1851.          This utility compares the time and date of files to see which files
  1852.          are out of date. It then runs the commands necessary to update
  1853.          those files. You write customized scripts that direct MAKE to
  1854.          execute the proper commands. Use MAKE to manage compiling and
  1855.          linking in a multiple-module software-development project.
  1856.  
  1857.       ■  EXEMOD, a utility that examines and modifies executable-file
  1858.          headers.
  1859.  
  1860.          You can use EXEMOD to adjust a program's minimum-memory request,
  1861.          maximum-memory request, or stack size. You can also use EXEMOD to
  1862.          view all the header information of an executable file.
  1863.  
  1864.       ■  EXEPACK, a file-packing utility.
  1865.  
  1866.          This utility packs an executable file into a special format, which
  1867.          is automatically decoded by DOS when you execute the file. The file
  1868.          is expanded back to its original size when you load it into memory,
  1869.          but the file can be stored in less space on disk.
  1870.  
  1871.       ■  SETENV, a utility to increase or decrease environment space under
  1872.          most versions of MS-DOS and IBM(R) PC-DOS versions 2.0 to 3.10.
  1873.  
  1874.       ■  ERROUT, a utility for redirecting standard-error output. Without
  1875.          this utility, standard output and standard-error output always go
  1876.          to the same file or device.
  1877.  
  1878.  The use of all the utilities above is explained in the Microsoft CodeView
  1879.  and Utilities manual.
  1880.  
  1881.  
  1882.  4.7  Mixed-Language Documentation
  1883.  
  1884.  The Microsoft Mixed-Language Programming Guide is included in the same
  1885.  binder as the Microsoft CodeView and Utilities manual. This new
  1886.  documentation on mixed-language programming includes chapters on linking to
  1887.  other high-level languages and to assembly language, and on special topics
  1888.  such as passing strings, arrays, and common blocks. The Microsoft Mixed-
  1889.  Language Programming Guide covers some of the same material as the old
  1890.  documentation, but provides more examples, step-by-step instructions, and
  1891.  diagrams. If you wish to write multiple-language programs, you should
  1892.  consult this manual rather than the old documentation.
  1893.  
  1894.  In addition, Chapter 6, "Assembly-to-High-Level Interface," in the
  1895.  Microsoft Mixed-Language Programming Guide is helpful for learning how to
  1896.  write standard procedure interfaces that can be understood by the CodeView
  1897.  debugger.
  1898.  
  1899.  
  1900.  
  1901.  Section 5  Updating from Version 3.30 and Earlier
  1902.  
  1903.  ───────────────────────────────────────────────────────────────────────────
  1904.  
  1905.  
  1906.  
  1907.  This section summarizes the differences between Versions 4.0 and 3.30 of
  1908.  Pascal. Depending on which version you are updating from, you may or may
  1909.  not need to read this section.
  1910.  
  1911.  If you are updating from Version 3.32 or Version 3.31, then the information
  1912.  in this section was included in a README.DOC file released with your last
  1913.  version of Pascal. Except for review, you do not need to read this section.
  1914.  
  1915.  If you are updating from Version 3.30, you should note the changes
  1916.  presented in this section.
  1917.  
  1918.  If you are updating from Version 3.20 or earlier, or if you are new to
  1919.  Microsoft Pascal, you should read both this section and Section 6.
  1920.  
  1921.  The differences between Version 4.0 and 3.30 include the following:
  1922.  
  1923.       ■  The stack size of the compiler has been increased to 40K.
  1924.  
  1925.       ■  The $INITCK metacommand (which checks for initialization) no longer
  1926.          affects FOR-loop control variables.
  1927.  
  1928.       ■  Two functions, MEMAVL and FREECT, can be used to determine the
  1929.          amount of available memory.
  1930.  
  1931.  
  1932.  5.1  Increased Stack Size
  1933.  
  1934.  The Version 4.0 compiler comes initially configured with a 40K stack.
  1935.  Version 3.30 had only a 20K stack.
  1936.  
  1937.  ───────────────────────────────────────────────────────────────────────────
  1938.  Note
  1939.       This section concerns the size of the compiler's internal stack, not
  1940.       the stack size of a program produced by the compiler. You can change
  1941.       the size of your program's stack without affecting the compiler
  1942.       itself.
  1943.  ───────────────────────────────────────────────────────────────────────────
  1944.  
  1945.  As noted in Section 4, the compiler's stack needs to be as large as
  1946.  possible, particularly if you compile programs that use deeply nested loops
  1947.  or IF-THEN structures. The large stack size of Version 4.0 may enable you
  1948.  to compile more complicated Pascal code.
  1949.  
  1950.  If the compiler fails with an "out of memory" error, the stack may be too
  1951.  small for the program you are attempting to compile. You can use EXEMOD to
  1952.  increase the stack size. (See the Microsoft CodeView and Utilities manual
  1953.  for information on the use of the EXEMOD utility.) However, the stack is
  1954.  restricted to the 64K area of memory called the DGROUP area. Because the
  1955.  DGROUP area must also include the compiler's internal data, the stack
  1956.  should always be substantially less than this 64K limit.
  1957.  
  1958.  You should not need to reduce the stack size. The symbol table, which used
  1959.  to compete with the stack for room in the DGROUP area, has now been removed
  1960.  to far memory.
  1961.  
  1962.  
  1963.  5.2  The $INITCK Metacommand and FOR-Loop Variables
  1964.  
  1965.  This section describes a modification to the function of the $INITCK
  1966.  metacommand. See Section 18.2, "Debugging and Error Handling," in the
  1967.  reference manual for a complete description of this metacommand.
  1968.  
  1969.  The $INITCK metacommand no longer sets FOR-loop control variables to the
  1970.  undefined value upon termination of a FOR loop. The $INITCK metacommand
  1971.  uses a different reserved value for each numerical data type to represent
  1972.  "undefined." These undefined values are then checked for at run time. The
  1973.  assignment of an undefined value generates an error message.
  1974.  
  1975.  The FOR-loop control variable is used to count the number of times a loop
  1976.  is executed. In the following code, the variable i, is the loop control
  1977.  variable:
  1978.  
  1979.  for i := 1 to 3
  1980.     begin
  1981.        sum := sum + i;
  1982.        product := product * i;
  1983.     end;
  1984.  
  1985.  In the example above, Pascal Versions 3.30 and earlier set the variable i
  1986.  equal to the undefined value upon completion of the loop. Version 4.0 sets
  1987.  i equal to 4 upon completion. Because i is not set to an undefined value,
  1988.  you may use the value of i later in your program without assigning it a new
  1989.  value.
  1990.  
  1991.  
  1992.  5.3  Determining Available Memory
  1993.  
  1994.  Two Microsoft Pascal library routines, MEMAVL and FREECT, can be used to
  1995.  determine the amount of memory in the DGROUP area available to your program
  1996.  at run time.
  1997.  
  1998.  The MEMAVL routine returns the number of bytes from the top of the near
  1999.  heap to the end of the DGROUP area. If the heap needs to grow, it uses this
  2000.  space. It should be noted that the space allocated for the heap can only
  2001.  grow; it can never shrink. Therefore, during the course of a program, the
  2002.  value returned by the MEMAVL routine can only decrease (as the heap grows)
  2003.  and never increase. Figure 5.1 below illustrates this concept:
  2004.  
  2005.  
  2006.          ┌───────────────────────────────────────┐   DGROUP:MAX
  2007.          │ Free space not in heap                │
  2008.          ├───────────────────────────────────────┤
  2009.          │ HEAP                                  │
  2010.          ├───────────────────────────────────────┤
  2011.          │ Stack                                 │
  2012.          ├───────────────────────────────────────┤
  2013.          │ Statically allocated part of DGROUP   │
  2014.          └───────────────────────────────────────┘   DGROUP:0
  2015.  
  2016.          Figure 5.1  Allocation of Memory in DGROUP
  2017.  
  2018.  
  2019.  FREECT(0)*2 returns the number of free bytes in the heap plus the value
  2020.  returned by MEMAVL. [The expression FREECT(0) returns the number of
  2021.  available words; multiply the result by 2 to determine the number of free
  2022.  bytes.]
  2023.  
  2024.  FREECT(0)*2-MEMAVL returns the number of free bytes in the heap itself.
  2025.  
  2026.  In Version 3.20, a Pascal program allocates all of free memory to itself.
  2027.  In Version 3.30 and later, a Pascal program returns space to DOS that it
  2028.  doesn't need. DGROUP:MAX is at the top of the allocated space, and offset 2
  2029.  in the DOS data area returns the segment paragraph for the top of the
  2030.  DGROUP area. See also Appendix B, Section B.1, "Implementation Additions,"
  2031.  in the user's guide for further discussion of the upper memory limit.
  2032.  
  2033.  
  2034.  
  2035.  Section 6  Updating from Versions 3.20 and Earlier
  2036.  
  2037.  ───────────────────────────────────────────────────────────────────────────
  2038.  
  2039.  
  2040.  
  2041.  This section presents the differences between Version 4.0 and Version 3.20
  2042.  of Pascal. Read this section if you are updating from Version 3.20 or
  2043.  earlier, or if you have purchased Microsoft Pascal for the first time.
  2044.  
  2045.  The following differences represent extensions to the Pascal language:
  2046.  
  2047.       ■  Address types
  2048.  
  2049.       ■  Enhanced SIZEOF function
  2050.  
  2051.       ■  Mixed-language features
  2052.  
  2053.  The rest of the differences, listed below, concern details of this latest
  2054.  Pascal implementation:
  2055.  
  2056.       ■  New files provided with compiler
  2057.  
  2058.       ■  Using ERR device name
  2059.  
  2060.       ■  File sharing and locking
  2061.  
  2062.       ■  Public variables
  2063.  
  2064.       ■  Memory model
  2065.  
  2066.  Section 6 discusses each of these differences in the order above. The
  2067.  section ends with a discussion of compatibility issues that concern
  2068.  conversion to Version 4.0.
  2069.  
  2070.  
  2071.  6.1  Address Types
  2072.  
  2073.  The address operators work differently in Version 4.0 from the way they
  2074.  work in Version 3.20. Furthermore, you can now take the address of a
  2075.  function or procedure as well as a variable.
  2076.  
  2077.  Using address operators is similar to using pointers in standard Pascal.
  2078.  Address types and operators are more flexible, however, because they are
  2079.  not limited to dynamic memory allocation. One of the principal uses of the
  2080.  address operators is in mixed-language programming.
  2081.  
  2082.  
  2083.  6.1.1  Using the ADS and ADR Operators with Expressions
  2084.  
  2085.  The ADS operator gives the full address (segment and offset) of the
  2086.  object to which it is applied. The ADR operator gives the offset only.
  2087.  Version 3.20 used an incorrect interpretation of precedence when these
  2088.  operators were applied to address expressions. Version 4.0 uses the correct
  2089.  interpretation, which is described in the reference manual.
  2090.  
  2091.  The ADS and ADR operators are of the same precedence as the NOT operator,
  2092.  and are of higher precedence than the other Pascal operators.
  2093.  
  2094.  If you have existing programs that use the incorrect precedence, as in
  2095.  Version 3.20, you must correct those programs if you want to compile them
  2096.  with Version 4.0. For example, in Version 4.0,
  2097.  
  2098.  ADS a + b
  2099.  
  2100.  is interpreted as
  2101.  
  2102.  (ADS a) + b
  2103.  
  2104.  because the ADS operator is of higher precedence than the addition (+)
  2105.  operator. This interpretation will not compile. You cannot add b to the
  2106.  address of a.
  2107.  
  2108.  Version 3.20 incorrectly interpreted
  2109.  
  2110.  ADS a + b
  2111.  
  2112.  as
  2113.  
  2114.  ADS (a + b)
  2115.  
  2116.  giving the + operator higher precedence. This interpretation does compile.
  2117.  You can take the address of (a + b).
  2118.  
  2119.  If you have existing programs that take the address of an expression with
  2120.  either the ADS or ADR operator, your program may not compile with
  2121.  Version 4.0. If that is the case, put parentheses around those expressions.
  2122.  
  2123.  The expressions
  2124.  
  2125.  ADS func(a)
  2126.  
  2127.  and
  2128.  
  2129.  ADS (func(a))
  2130.  
  2131.  where func(a) is a function call, represent different values. The first
  2132.  expression evaluates to the address of the function (see the new
  2133.  predefined-type ADSFUNC in the next section), and the second expression
  2134.  valuates to the address of the result of the expression--the address of the
  2135.  temporary value returned when func is called.
  2136.  
  2137.  
  2138.  6.1.2  Addressing Procedures and Functions (ADSPROC and ADSFUNC)
  2139.  
  2140.  The ADS operator can now be applied to procedures and functions, as well as
  2141.  to variables. When the ADS operator is applied to a procedure, it produces
  2142.  a value of the predefined-type ADSPROC. When it is applied to a function,
  2143.  it produces a value of the predefined-type ADSFUNC. The ADSPROC and ADSFUNC
  2144.  keywords are similar in concept to the ADSMEM type.
  2145.  
  2146.  The ADSPROC and ADSFUNC keywords can be used to declare variables or formal
  2147.  parameters. To call a procedure or function with these variables or
  2148.  parameters, you must pass their value to an external, non-Pascal routine
  2149.  and then call that routine. Note that ADSPROC and ADSFUNC parameters are
  2150.  compatible with C function pointers; Pascal procedure parameters are not.
  2151.  
  2152.  As with other address types, there is no type checking on assignments to
  2153.  ADSPROC or ADSFUNC parameters or variables. The compiler does not make sure
  2154.  that a function or procedure is being assigned or that the formal
  2155.  parameters are appropriate. You can also freely assign to and from other
  2156.  address types.
  2157.  
  2158.  
  2159.  ■  Example
  2160.  
  2161.  program p(output);
  2162.  procedure cproc (ap: adsproc; af: adsfunc) [c]; extern;
  2163.  procedure pproc (i: integer);
  2164.  begin
  2165.      writeln('C integer =', i);
  2166.  end;
  2167.  function pfunc: integer;
  2168.  var
  2169.      i: integer;
  2170.  begin
  2171.      readln(i);
  2172.      pfunc := i;
  2173.  end;
  2174.  
  2175.  begin
  2176.      cproc (ADS pproc, ADS pfunc);
  2177.  end.
  2178.  
  2179.  This example could be used to communicate with a C routine that calls the
  2180.  routine af, then calls the routine ap with the result.
  2181.  
  2182.  
  2183.  6.2  Using the SIZEOF Function
  2184.  
  2185.  The SIZEOF function has been enhanced. You are now permitted to omit the
  2186.  second parameter if the variable is a pointer to a super array. Thus, the
  2187.  function SIZEOF(P^), where P is a pointer to a super array, is now a valid
  2188.  expression. Note, however, that if P^ has not been allocated with the
  2189.  function NEW, the SIZEOF(P^) function is undefined. It is the programmer's
  2190.  responsibility to check that P^ has actually been allocated before using
  2191.  this form of the SIZEOF function.
  2192.  
  2193.  
  2194.  6.3  Mixed-Language Features
  2195.  
  2196.  Version 4.0 includes three enhancements to the Pascal language, which are
  2197.  useful in calling Microsoft C:
  2198.  
  2199.       ■  The INTEGERC type
  2200.  
  2201.       ■  The C attribute
  2202.  
  2203.       ■  The VARYING attribute
  2204.  
  2205.  Each of these features is described briefly below, and they are used
  2206.  extensively in examples in the Microsoft Mixed-Language Programming Guide.
  2207.  
  2208.  
  2209.  6.3.1  Using the C int Type (INTEGERC)
  2210.  
  2211.  For a given processor and operating system, variables that have the type
  2212.  INTEGERC are equivalent to variables with the C "int" type as defined by
  2213.  the Microsoft C Optimizing Compiler for the same system. For the 8086
  2214.  family of microprocessors, the INTEGERC type is equivalent to INTEGER2.
  2215.  
  2216.  
  2217.  6.3.2  Using C Calling Conventions (C Attribute)
  2218.  
  2219.  You can use Microsoft C calling and external naming conventions for a
  2220.  particular procedure by specifying the C attribute in the procedure
  2221.  declaration. The C attribute has the same syntax as the PUBLIC attribute.
  2222.  For example, in the statement
  2223.  
  2224.  PROCEDURE myproc [PUBLIC, C]
  2225.  
  2226.  myproc is a public procedure that uses C calling conventions. Calling
  2227.  conventions are discussed in Chapter 1 of the Microsoft Mixed-Language
  2228.  Programming Guide.
  2229.  
  2230.  
  2231.  6.3.3  Using a Variable Number of Arguments (VARYING Attribute)
  2232.  
  2233.  When using the C attribute, you can also use the VARYING attribute. The C
  2234.  attribute is a prerequisite to using the VARYING attribute because Pascal,
  2235.  FORTRAN, and BASIC calling conventions cannot support a variable number of
  2236.  parameters.
  2237.  
  2238.  The VARYING attribute enables you to call a function or procedure with a
  2239.  number of actual arguments that differs from the number of formal
  2240.  arguments. For example, you may declare two arguments, but pass five when
  2241.  you make the call. Actual arguments for which a formal argument is defined
  2242.  must follow the type rules. Actual arguments for which there are no formal
  2243.  arguments defined are assumed to be passed by value, with no type
  2244.  coercions. Note that a subprogram written in Pascal can only access
  2245.  formally defined arguments, so the later case does not apply.
  2246.  
  2247.  For more information on the VARYING attribute, see Chapter 9, "Special Data
  2248.  Types," in the Microsoft Mixed-Language Programming Guide.
  2249.  
  2250.  
  2251.  6.4  New Files Supplied with the Compiler
  2252.  
  2253.  The following files are provided with Version 4.0, but are not completely
  2254.  documented in the user's guide. All the information required to use these
  2255.  files is provided in this document.
  2256.  
  2257.    File           Description
  2258.    ─────────────────────────────────────────────────────────────────────────
  2259.    CEXEC.LIB      Part of the Microsoft C library, providing routines to
  2260.                   support the use of the DOS exec function
  2261.  
  2262.    PASEXEC.INC    Interface declarations and documentation for routines in
  2263.                   CEXEC.LIB
  2264.  
  2265.    DEMOEXEC.PAS   An example program demonstrating how to use the routines
  2266.                   provided in CEXEC.LIB
  2267.  
  2268.    EMOEM.ASM      Customization for the 8087 processor
  2269.  
  2270.    LVARSTK.OBJ    An object file that provides a variable stack
  2271.  
  2272.  
  2273.  6.4.1  Using C System Functions with CEXEC.LIB
  2274.  
  2275.  The library file CEXEC.LIB contains the following routines extracted from
  2276.  the Microsoft C run-time library (Version 5.0):
  2277.  
  2278.    Function       Description
  2279.    ─────────────────────────────────────────────────────────────────────────
  2280.    system         Invokes COMMAND.COM with a user-specified command
  2281.                   line
  2282.  
  2283.    spawn          Loads and executes a specified .COM or .EXE file (i.e.,
  2284.                   executes a child process)
  2285.  
  2286.  The file PASEXEC.INC contains INTERFACE declarations allowing these
  2287.  routines to be called from Pascal, and also contains extensive comments
  2288.  explaining how to use them.
  2289.  
  2290.  The file DEMOEXEC.PAS contains an example program demonstrating the use of
  2291.  these routines.
  2292.  
  2293.  
  2294.  6.4.2  Customizing the 8087 Table with the EMOEM.ASM Program
  2295.  
  2296.  If your machine has an 8087, 80287, or 80387 processor, you should read
  2297.  this section to see if it pertains to your hardware configuration. All
  2298.  Microsoft languages that support the 8087 need to intercept 8087 exceptions
  2299.  in order to properly detect error conditions and provide reliable and
  2300.  accurate results. The math libraries that contain the 8087 exception
  2301.  handler and emulator (MATH.LIB and 8087.LIB) are designed to work without
  2302.  modification with the following machines:
  2303.  
  2304.       1. IBM PC family and compatibles, Wang(R) PC (any machine that uses
  2305.          nonmaskable interrupt for 8087 exceptions), and Texas
  2306.          Instruments(R) Professional Computer.
  2307.  
  2308.       2. Any machine that sends the 8087 exception to an 8259 Priority
  2309.          Interrupt Controller (master or master/slave) should be easily
  2310.          supported by a simple table change to the EMOEM.ASM module. In the
  2311.          file there are further instructions on how to modify the file and
  2312.          patch libraries and executables.
  2313.  
  2314.  If your computer is not listed and you need to modify the EMOEM.ASM
  2315.  program, please contact your hardware manufacturer for the specific
  2316.  information on the 8087 and modification specifics. If your hardware
  2317.  manufacturer is not aware of the changes that need to be made, they should
  2318.  contact the Microsoft OEM Group.
  2319.  
  2320.  The Microsoft Retail Product Support Group is not equipped to help you out
  2321.  in the customization of the EMOEM.ASM program.
  2322.  
  2323.  
  2324.  6.4.3  Creating a Variable Stack with LVARSTK.OBJ
  2325.  
  2326.  By default, a program you create with Version 4.0 has a fixed stack area
  2327.  and a fixed heap area. The program uses the heap whenever you allocate
  2328.  dynamic memory, and when you open files. Because the size of each of these
  2329.  areas is fixed, your program does not give unused stack space to the heap.
  2330.  This may cause your program to run out of memory sooner.
  2331.  
  2332.  If you want your program to use unused stack space for excess heap items,
  2333.  link with the object module LVARSTK.OBJ. If you later use EXEMOD to change
  2334.  the default stack size, your program will behave as if the stack and heap
  2335.  sizes were fixed.
  2336.  
  2337.  When you link with the module LVARSTK.OBJ, you should compile with the
  2338.  stack-checking enabled, since unprotected collisions between the stack and
  2339.  the heap can lead to unpredictable behavior.
  2340.  
  2341.  
  2342.  6.5  Using the ERR Device Name
  2343.  
  2344.  Both the Pascal compiler and the run-time library associate the name "ERR"
  2345.  with the DOS standard-error-device handle (abbreviated in C as stderr). The
  2346.  stderr file handle is mapped to the physical console and--unlike stdin and
  2347.  stdout--is not redirectable. Thus the command syntax
  2348.  
  2349.  PAS1 ERR;
  2350.  
  2351.  causes the Pascal compiler to expect source code from the keyboard rather
  2352.  than a file named ERR.PAS. Similarly, the command syntax
  2353.  
  2354.  PAS1 TEST,,ERR;
  2355.  
  2356.  causes the source-listing output to be written to the console screen rather
  2357.  than a file named ERR.LST. Finally, a file variable may be explicitly
  2358.  attached to ERR with the ASSIGN procedure and thereby attached to stderr.
  2359.  
  2360.  
  2361.  6.6  File Sharing and Locking
  2362.  
  2363.  File sharing and locking are features of MS-DOS 3.0 and later. Version 4.0
  2364.  has features that facilitate the use of file sharing and locking from
  2365.  within Pascal programs.
  2366.  
  2367.  
  2368.  6.6.1  File Sharing
  2369.  
  2370.  In systems that use networking, more than one program can attempt to access
  2371.  the same file at the same time. Two new fields in the file control block,
  2372.  share and access, allow you to control access to files. These fields have
  2373.  the new predefined enumerated types, sharemodes and accessmodes.
  2374.  
  2375.  The value of access determines how the first process to open a file can use
  2376.  that file. You can choose to gain permission to read the file, write to the
  2377.  file, or do both. The value of share determines how subsequent processes
  2378.  are allowed to access the file while the file is still open. You can choose
  2379.  to allow subsequent processes to read the file, write to the file, do both,
  2380.  or do neither. You can also choose not to allow any processes, including
  2381.  the process that originally opened the file, to open the file again while
  2382.  the file is still open.
  2383.  
  2384.  
  2385.  6.6.1.1  Sharemodes
  2386.  
  2387.  To control how other processes may access a file that you are opening, set
  2388.  the share field in the file control block. This field has the new
  2389.  predefined enumerated type, sharemodes, as shown below:
  2390.  
  2391.  .
  2392.  .
  2393.  .
  2394.  share:sharemodes
  2395.  .
  2396.  .
  2397.  .
  2398.  
  2399.  The sharemodes type is defined as follows:
  2400.  
  2401.  TYPE
  2402.     sharemodes=(sm_COMPAT, {compatibility mode}
  2403.                 sm_DENYRW, {deny read/write mode}
  2404.                 sm_DENYWR, {deny write mode}
  2405.                 sm_DENYRD, {deny read mode}
  2406.                 sm_DENYNONE, {deny none mode}
  2407.                );
  2408.  
  2409.  The sharemode values are described in the list below:
  2410.  
  2411. ╓┌────────────────┌──────────────────────────────────────────────────────────╖
  2412.    Mode           Description
  2413.    ────────────────────────────────────────────────────────────────────────
  2414.    sm_COMPAT      Compatibility mode (the default).
  2415.  
  2416.                   When a file is open in compatibility mode, the original
  2417.    Mode           Description
  2418.                  When a file is open in compatibility mode, the original
  2419.                   user (the process that opened the file) may open the file
  2420.                   in compatibility mode any number of times. No other user
  2421.                   may open the file.
  2422.  
  2423.                   A file already opened in another mode cannot be opened in
  2424.                   compatibility mode.
  2425.  
  2426.    sm_DENYRW      Deny-read/write mode.
  2427.  
  2428.                   While a file is open in deny-read/write mode, no process
  2429.                   may open the file.
  2430.  
  2431.    sm_DENYWR      Deny-write mode.
  2432.  
  2433.                   While a file is open in deny-write mode, no process may
  2434.                   open the file with write access. Other processes can open
  2435.                   the file with read access.
  2436.  
  2437.    sm_DENYRD      Deny-read mode.
  2438.    Mode           Description
  2439.   sm_DENYRD      Deny-read mode.
  2440.  
  2441.                   While a file is open in deny-read mode, no process may
  2442.                   open the file with read access. Other processes can open
  2443.                   the file with write access.
  2444.  
  2445.    sm_DENYNONE    Deny-none mode.
  2446.  
  2447.                   While a file is open in deny-none mode, any process may
  2448.                   open the file in any mode (except compatibility mode).
  2449.  
  2450.  As with filename assignments, the share value must be set before the file
  2451.  is opened with reset or rewrite, as shown below:
  2452.  
  2453.  var
  2454.  f:text;
  2455.  .
  2456.  .
  2457.  .
  2458.  f.share := sm_COMPAT;
  2459.  assign(f...);
  2460.  reset(f);
  2461.  
  2462.  If you change share, you must reset or rewrite the file before accessing
  2463.  the file again.
  2464.  
  2465.  
  2466.  6.6.1.2  Accessmode
  2467.  
  2468.  The predefined-type accessmode specifies the type of access the original
  2469.  process (the process that initially opened the file) makes to a file. You
  2470.  specify accessmode by setting the value of the access field in the file
  2471.  variable.
  2472.  
  2473.  Accessmode is defined below:
  2474.  
  2475.  TYPE
  2476.     accessmode=(am_read, am_write, am_readwrite)
  2477.  
  2478.  The accessmode values are as follows:
  2479.  
  2480.    Accessmode     Description
  2481.    ─────────────────────────────────────────────────────────────────────────
  2482.    am_read        The process can read the file.
  2483.  
  2484.    am_write       The process can write to the file.
  2485.  
  2486.    am_readwrite   The process can read and write to the file.
  2487.  
  2488.  The example below opens a file with share equal to sm_DENYRW and access
  2489.  equal to am_readwrite:
  2490.  
  2491.  
  2492.  ■  Example
  2493.  
  2494.  .
  2495.  .
  2496.  .
  2497.  var f: test;
  2498.  f.share := sm_DENYRW;
  2499.  f.access := am_readwrite;
  2500.  assign(f...);
  2501.  rewrite(f);
  2502.  .
  2503.  .
  2504.  .
  2505.  
  2506.  If you open a file without assigning an access, the Pascal run-time system
  2507.  always attempts to open with an access value am_readwrite. If the open
  2508.  fails, the run-time system tries to open the file again, first using
  2509.  am_write, then using the am_read value. This is not the same as specifying
  2510.  access=am_readwrite. If you specify the access=am_readwrite value, and the
  2511.  file cannot be opened with both read and write access, the opening fails.
  2512.  The default behavior is more flexible.
  2513.  
  2514.  While the am_readwrite value is an appropriate default for single-program
  2515.  environments, it is not always the best choice when a file is shared. For
  2516.  example, several processes may want to read a file and ensure that no
  2517.  process updates the file while they are reading it. If the first process
  2518.  opens the file with the share=denywr and access=am_read values, then any
  2519.  number of other processes may also open the file with share=sm_denywr and
  2520.  access=am_read values.
  2521.  
  2522.  
  2523.  6.6.2  File Locking
  2524.  
  2525.  The previous two sections dealt with file sharing, a method for restricting
  2526.  access to a file considered as a whole. This section describes file
  2527.  locking, a method for restricting the access to specified records within a
  2528.  file.
  2529.  
  2530.  A new procedure and ordinal type have been defined that allow you to lock a
  2531.  specific range of records in a DIRECT-mode file. The locked records cannot
  2532.  be accessed by other processes within a networked system. The procedure is
  2533.  defined as follows:
  2534.  
  2535.  PROCEDURE locking (VAR f: FCBFQQ; MODE: lockmodes; M,N: INTEGER4);
  2536.  
  2537.  The parameters are described below:
  2538.  
  2539.    Parameter      Function
  2540.    ─────────────────────────────────────────────────────────────────────────
  2541.    M              An integer expression that is the number of the first
  2542.                   record to be locked. If M is zero (0), the next record
  2543.                   (the one that a sequential read, such as GET, would read)
  2544.                   is locked.
  2545.  
  2546.    N              An integer expression that is the number of records to be
  2547.                   locked. If N is zero (0), one record is locked.
  2548.  
  2549.  The type "lockmodes" is defined as follows:
  2550.  
  2551.  TYPE
  2552.     lockmodes=(lm_unlck, lm_lock, lm_nblck, lm_rlck, lm_nbrlck);
  2553.  
  2554.  The values of lockmodes are described below:
  2555.  
  2556. ╓┌────────────────┌──────────────────────────────────────────────────────────╖
  2557.    Lockmode       Description
  2558.    ─────────────────────────────────────────────────────────────────────────
  2559.    lm_unlck       Unlocks the specified region (N records, starting at
  2560.                   record M).
  2561.  
  2562.    lm_lock        Locks the specified region (N records, starting at record
  2563.                   M). Waits for any part of the region locked by a different
  2564.    Lockmode       Description
  2565.                  M). Waits for any part of the region locked by a different
  2566.                   process to become available.
  2567.  
  2568.    lm_nblck       Nonblocking lock. Locks the specified region (N records,
  2569.                   starting at record M). If any is already locked by a
  2570.                   different process, gives an error. This is the default.
  2571.  
  2572.    lm_rlck        Reads lock. This is the same as lm_lock, except locks for
  2573.                   write access only.
  2574.  
  2575.    lm_nbrlck      Nonblocking read lock. This is the same as lm_nblck,
  2576.                   except locks for write access only.
  2577.  
  2578.  
  2579.  ■  Example
  2580.  
  2581.  The following example opens a DIRECT-access file with share equal to
  2582.  sm_DENYNONE, locks two records, starting at record 1, and then unlocks the
  2583.  records:
  2584.  
  2585.  type info=record...end;
  2586.  var f: file of info;
  2587.  f.mode := DIRECT;
  2588.  f.share := sm_DENYNONE;
  2589.  assign(f...);
  2590.  reset(f);
  2591.  locking(f, lm_lock, 1, 2);
  2592.  get(f);
  2593.  locking(f, lm_unlck, 1, 2);
  2594.  
  2595.  
  2596.  6.7  Public Variables
  2597.  
  2598.  The following public variables, defined in the ENTX61.ASM program in
  2599.  earlier versions of Microsoft Pascal, no longer exist in Version 4.0:
  2600.  
  2601.  BEGHQQ
  2602.  BEGMQQ
  2603.  CURHQQ
  2604.  ENDHQQ
  2605.  ENDMQQ
  2606.  MAXMQQ
  2607.  
  2608.  The following public variables, defined in the ENTX61.ASM program in
  2609.  earlier versions of Microsoft Pascal, still exist in Version 4.0. Note,
  2610.  however, that only the CESXQQ, CRBXQQ, CRCXQQ, CRDXQQ, CRDSQQ, and DOSEQQ
  2611.  public variables are intended for direct access by the user:
  2612.  
  2613. ╓┌────────────────┌──────────────────────────────────────────────────────────╖
  2614.    Variable       Description
  2615.    ────────────────────────────────────────────────────────────────────────
  2616.    CESXQQ         DOS-saved ES value (for command line)
  2617.    CLNEQQ         Last line number encountered
  2618.    CRBXQQ         Value of BX for DOS call
  2619.    CRCXQQ         Value of CX for DOS call
  2620.    CRDXQQ         Value of DX for DOS call
  2621.    CRDSQQ         Value of DS for DOS call
  2622.    CSXEQQ         Pointer to source of context list
  2623.    DGRMQQ         Segment of DGROUP
  2624.    DOSEQQ         DOS return code
  2625.    HDRFQQ         Unit F open-file-list header
  2626.    HDRVQQ         Unit V open-file-list header
  2627.    Variable       Description
  2628.   HDRVQQ         Unit V open-file-list header
  2629.    CRUXQQ         Pointer to unit-initialization list
  2630.    RECEQQ         Machine error context, program segment
  2631.    REFEQQ         Machine error context, frame pointer
  2632.    REPEQQ         Machine error context, program offset
  2633.    RESEQQ         Machine error context, stack pointer
  2634.    STKBQQ         Stack start, to fix long GOTO
  2635.    STKHQQ         Stack limit, to check overflow
  2636.    UPCX87         Offset address of 8087 error context
  2637.  
  2638.  ───────────────────────────────────────────────────────────────────────────
  2639.  Note
  2640.       These variables are available only in DOS and real-mode OS/2 programs.
  2641.       The variables are not used in OS/2 protected-mode programs.
  2642.  ───────────────────────────────────────────────────────────────────────────
  2643.  
  2644.  
  2645.  6.8  The Pascal Memory Model
  2646.  
  2647.  This section describes the memory layout for a Pascal program, not the
  2648.  Pascal compiler itself. The segment contents for a Pascal program in memory
  2649.  are listed below, from the highest memory location to the lowest.
  2650.  
  2651. ╓┌───────────────────┌───────────────────────────────────────────────────────╖
  2652.    Area              Description
  2653.    ────────────────────────────────────────────────────────────────────────
  2654.    Heap              The heap is the area of the default data segment
  2655.                      (DGROUP) that is available for dynamic memory
  2656.                      allocation at run time via the NEW procedure. It does
  2657.                      not belong to a named segment and will not show up on a
  2658.                      link map.
  2659.  
  2660.    STACK             The STACK segment contains the user's stack, which is
  2661.                      used for all local-data items.
  2662.  
  2663.    _BSS              The _BSS segment contains all unitialized static data.
  2664.  
  2665.    EEND, EDATA       These segments are defined and used by the run-time
  2666.                      library.
  2667.  
  2668.    CONST             The CONST segment contains all constants.
  2669.    Area              Description
  2670.   CONST             The CONST segment contains all constants.
  2671.  
  2672.    P3CE, P3C, P3CB, These segments are defined and used by the run-time
  2673.    P2CE, P2C, P2CB, library.
  2674.    P1CE, P1C, P1CB,
  2675.    P31E, P3I, P3IB,
  2676.    P2IE, P1IE, P1I,
  2677.    P1IB, XCE, XC,
  2678.    XCB, XIE, XI, XIB
  2679.  
  2680.    COMADS            The COMADS segment is not used; it is part of FORTRAN
  2681.                      run-time support.
  2682.  
  2683.    _DATA             The _DATA segment is the default data segment. All
  2684.                      initialized global and static data reside in this
  2685.                      segment.
  2686.  
  2687.  
  2688.  6.9  Compatibility with Version 3.20
  2689.  
  2690.  This section addresses users who, converting from Version 3.20 and earlier,
  2691.  may be interested in using their old source files and object files with
  2692.  Version 4.0 of Pascal.
  2693.  
  2694.  Apart from the changes identified in the previous sections, programs that
  2695.  compiled correctly with Version 3.20 should compile correctly with
  2696.  Version 4.0 of Pascal.
  2697.  
  2698.  Object modules compiled with Versions 3.20 and 4.0 can be linked together.
  2699.  However, your main program should be compiled with Version 4.0 of Pascal.
  2700.  If you have existing assembly-language source files that rearrange memory
  2701.  from the default, they may have to be modified because the memory model has
  2702.  been changed.
  2703.  
  2704.  The intermediate files produced by the first two passes of the compiler
  2705.  (PASIBF.BIN, PASIBF.SYM, PASIBF.TMP, and PASIBF.OID) are about one-third
  2706.  the size of those produced by Version 3.20.
  2707.  
  2708.  
  2709.  
  2710.  Section 7  Writing Microsoft Windows Applications
  2711.  
  2712.  ───────────────────────────────────────────────────────────────────────────
  2713.  
  2714.  
  2715.  
  2716.  7.1  Windows Interface
  2717.  
  2718.  All Pascal Windows applications must include the Windows interface in their
  2719.  source files. The Windows interface contains definitions for the Windows
  2720.  functions, data types, and constants. You can include the interface by
  2721.  using the INTERFACE statement and the WINDOWS.INC file.
  2722.  
  2723.  Each application should have its own .INC file that lists the names of the
  2724.  Windows functions, data types, and constants it uses.
  2725.  
  2726.  
  2727.  7.2  $WINDOWS Metacommand
  2728.  
  2729.  Pascal applications must be compiled by using the $WINDOWS metacomand.
  2730.  
  2731.  
  2732.  7.3  Program Module
  2733.  
  2734.  Pascal applications must be defined as Pascal modules, not programs. A
  2735.  program module can contain any number of Pascal procedure or function
  2736.  definitions. At least one function, the WinMain function, is required for
  2737.  any Windows application.
  2738.  
  2739.  
  2740.  7.4  WinMain Function
  2741.  
  2742.  The WinMain function is the entry point (starting point) of the
  2743.  application. This function contains statements and Windows function calls
  2744.  that create windows, and read and dispatch input intended for the
  2745.  application. The WinMain function, which must be declared with the PUBLIC
  2746.  attribute, has the following form:
  2747.  
  2748.  function WinMain( hInstance    : HANDLE;
  2749.                    hPrevInstance: HANDLE;
  2750.                    lpCmdLine  : LPSTR;
  2751.                    nCmdShow      : INT ) : BOOL [ PUBLIC ];
  2752.  
  2753.  
  2754.  7.5  Callback Functions
  2755.  
  2756.  "Callback functions" are functions in an application that Windows calls to
  2757.  carry out specific tasks. An example is a window function that processes
  2758.  messages for an application's windows.
  2759.  
  2760.  Windows expects callback functions to be public and to have the Windows
  2761.  prologue and epilogue; therefore, you must declare the functions with both
  2762.  the WINDOWS and PUBLIC attributes. The WINDOWS attribute ensures that the
  2763.  Windows prologue and epilogue code is included and that the correct data
  2764.  segment is used by the function when it executes. The following example
  2765.  shows the correct definition for a callback function:
  2766.  
  2767.  function About ( hDlg   : HWND;
  2768.                   message: UNSIGNED;
  2769.                   wParam : WORD;
  2770.                   lParam : LONG ) : BOOL [ PUBLIC, Windows ];
  2771.  
  2772.  All callback functions must be listed in the EXPORTS statement of the
  2773.  application's module definition file (see Chapter 4, "Windows Development
  2774.  Tools," in the Microsoft Windows Programmer's Learning Guide for an
  2775.  explanation of the module-definition file). This identifies the function as
  2776.  a callback and permits Windows to insert the proper data-segment address in
  2777.  the function's prologue when it loads the application.
  2778.  
  2779.  Local functions (functions used exclusively by the application and not
  2780.  called by Windows) do not require the Windows prologue and epilogue and
  2781.  can use the ordinary Pascal calling conventions.
  2782.  
  2783.  
  2784.  7.5.1  Windows and Pascal Libraries
  2785.  
  2786.  If you write Windows applications in the Pascal language, you can link your
  2787.  applications with the following libraries:
  2788.  
  2789.  PASLIBW.LIB
  2790.  LIBPASx.LIB
  2791.  
  2792.  The PASLIBW.LIB library contains Windows entry points for Windows
  2793.  applications. This library should be linked with all Pascal Windows
  2794.  applications. In most cases, it should appear as the first library in the
  2795.  LINK command line. The LIBPASx.LIB library is the standard run-time library
  2796.  for Pascal. This library should be linked with all Pascal Windows
  2797.  applications. It contains code for the procedures and functions implemented
  2798.  by the Pascal language.
  2799.  
  2800.  
  2801.  7.5.2  Pascal Memory-Allocation Routines
  2802.  
  2803.  The Pascal memory-allocation routines ALLHQQ and ALLMQQ, used in standard
  2804.  Pascal applications, should not be used in Windows applications developed
  2805.  in Pascal. In the current Pascal library LIBPASx.LIB, the ALLHQQ function
  2806.  calls _nmalloc, which in turn calls the Windows LocalAlloc function to
  2807.  create a fixed memory block in the application's local heap. Similarly,
  2808.  ALLMQQ calls fmalloc, which calls the GlobalAlloc function to create a
  2809.  fixed global-memory block.
  2810.  
  2811.  Since the LocalAlloc and GlobalAlloc functions do not operate identically
  2812.  to the ALLHQQ and ALLMQQ functions in standard Pascal applications, using
  2813.  LocalAlloc and GlobalAlloc is not recommended. Use Windows memory-manager
  2814.  functions for managing memory for Windows applications written in Pascal.
  2815.  
  2816.  
  2817.  7.5.3  Floating-Point Support
  2818.  
  2819.  Applications written in Pascal have floating-point options similar to those
  2820.  written in the C language (see the Microsoft Windows Programmer's Utility
  2821.  Guide).
  2822.  
  2823.  The following paragraphs contain a summary of the Pascal floating-point
  2824.  options.
  2825.  
  2826.  
  2827.  7.5.3.1  Coprocessor/Emulator Math Option
  2828.  
  2829.  You can choose the coprocessor/emulator math option by linking the Pascal
  2830.  program with the WIN87EM.LIB and MATH.LIB libraries on the LINK command
  2831.  line (along with the PASLIBW.LIB and PASCAL.LIB libraries).
  2832.  
  2833.  
  2834.  ■  Example
  2835.  
  2836.  Running a Windows application linked with the WIN87EM.LIB library is
  2837.  possible with or without a coprocessor. The coprocessor is used if present;
  2838.  otherwise, floating-point emulator software simulates the operation of the
  2839.  coprocessor chip. The emulator math option does require the dynamic-link
  2840.  library WIN87EM.EXE to be located in the current directory or in a
  2841.  directory listed in the PATH environment variable at the time the
  2842.  application is loaded. This option is flexible and fast if the coprocessor
  2843.  is available. Developers of Windows applications using this floating-point
  2844.  option should distribute the WIN87EM.EXE library along with their
  2845.  application.
  2846.  
  2847.  
  2848.  7.5.3.2  Alternate Math Option
  2849.  
  2850.  The alternate math option can be chosen by linking the Pascal program with
  2851.  the library LIBPASA.LIB on the LINK command line.
  2852.  
  2853.  
  2854.  ■  Example
  2855.  
  2856.  PL /Pw /c SAMPLE.PAS
  2857.  LINK SAMPLE,/ALIGN:16,/MAP,PASLIBW LIBPASA /NOE /NOD,SAMPLE.DEF;
  2858.  
  2859.  This option does not use the coprocessor to perform floating-point
  2860.  operations. It is faster than the emulator when no coprocessor is present,
  2861.  but it is slower than the coprocesor/emulator math option when the
  2862.  coprocessor is present.
  2863.  
  2864.  You could also use the PL driver to compile and link the program:
  2865.  
  2866.  PL /Pw /FPa /Fm /Lp SAMPLE.PAS /link /ALIGN:16 PASLIBW.LIB
  2867.  
  2868.  
  2869.  
  2870.  Section 8  Error and Warning Messages
  2871.  
  2872.  ───────────────────────────────────────────────────────────────────────────
  2873.  
  2874.  
  2875.  
  2876.  This section describes additional error and warning messages not included
  2877.  in Appendix F, "Error Messages," of the user's guide. Section 8.1 describes
  2878.  error messages; Section 8.2 describes warning messages.
  2879.  
  2880.  
  2881.  8.1  Error Messages
  2882.  
  2883.  The following list describes the new error messages:
  2884.  
  2885.  Number           Error Message
  2886.  ───────────────────────────────────────────────────────────────────────────
  2887.  PL1001           could not execute filename
  2888.  
  2889.                   The PL driver did not have enough memory to run the
  2890.                   indicated program. The PL driver halts.
  2891.  
  2892.  
  2893.  PL2003           missing source file name
  2894.  
  2895.                   You used the compile option (/c) on the PL command line,
  2896.                   but did not provide a source-file name. The PL driver
  2897.                   stops execution.
  2898.  
  2899.  
  2900.  PL2009           unknown option op in switch sw
  2901.  
  2902.                   You specified an unknown option, op, for the switch sw on
  2903.                   the PL command line. For example, x is an invalid option
  2904.                   for the /Z switch, so entering /Zx on the command line
  2905.                   would generate this error message. The PL driver
  2906.                   terminates.
  2907.  
  2908.  
  2909.  8.2  Warning Messages
  2910.  
  2911.  The following list describes the new warning messages:
  2912.  
  2913.  Number           Warning Message
  2914.  ───────────────────────────────────────────────────────────────────────────
  2915.  PL4001           ignoring unknown switch sw
  2916.  
  2917.                   The PL driver did not recognize an option in a compile
  2918.                   directive switch (/P switch). For example, x is an invalid
  2919.                   option, so /Px would generate this error. The PL driver
  2920.                   ignores the switch and continues.
  2921.  
  2922.  
  2923.  PL4002           name.DEF ignored for real mode
  2924.  
  2925.                   You specified a linker definition file (.DEF) on the
  2926.                   command line, but you are linking a real-mode application.
  2927.                   The .DEF file is ignored and linking continues.
  2928.  
  2929.  
  2930.