home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / turbo55 / tp55 / doc / helpme!.doc < prev    next >
Encoding:
Text File  |  1989-05-02  |  18.3 KB  |  454 lines

  1.  
  2.     TURBO PASCAL 5.5: ANSWERS TO COMMON QUESTIONS
  3.     ---------------------------------------------
  4.  
  5.     1. Can I build programs bigger than 64K?
  6.  
  7.        The total size of a program's code is only limited by the
  8.        memory you have available; but each unit (module) can be
  9.        no larger than 64K, since it has to have its own code
  10.        segment.
  11.  
  12.        The data segment is still no more than 64K, but the heap
  13.        is unlimited just as in 3.0. In fact, we've rewritten the
  14.        heap manager to make it much more efficient. There's no
  15.        waste when allocating memory (in 3.0, all blocks were
  16.        rounded up to a factor of 8), and you can install a heap
  17.        error routine that gets called if an allocation request
  18.        fails. All in all, 5.5's heap manager is much faster than
  19.        version 3.0.
  20.  
  21.     2. Can Turbo Pascal run on generic MS-DOS machines?
  22.  
  23.        TPC.EXE will run on generic machines when you use the /Q
  24.        option. The System, Overlay, Dos, and Printer standard
  25.        units will operate correctly on MS-DOS generic machines.
  26.        Generated .EXE's are MS-DOS compatible as long as you
  27.        don't use the special PC units (such as Crt, Graph, and
  28.        Graph3).
  29.  
  30.     3. Does Turbo Pascal 5.5 support large integers?
  31.  
  32.        Yes, TP 5.5 has virtually every incarnation of 8-, 16-, and
  33.        32-bit integers: shortint, integer, longint, byte, and
  34.        word.
  35.  
  36.     4. Will the toolboxes for 4.0 work with 5.5?
  37.  
  38.        Yes, all 4.0 versions of the toolboxes will work with
  39.        Turbo Pascal 5.5. In a few cases, minor changes to
  40.        compiler directives are recommended. Refer to the Turbo
  41.        Pascal README file for more information.
  42.  
  43.     5. Does Turbo Pascal version 5.5 support conditional
  44.        compilation?
  45.  
  46.        Yes, Turbo 5.5 includes conditional compilation support.
  47.        You use {$DEFINE ...} and {$UNDEF ...} for symbols and
  48.        {$IFDEF ...}. Using the {$IFOPT ...} conditional
  49.        directive, you can even test the settings of compiler
  50.        directives like R-, N+, and others. For the command-line
  51.        compiler, you can define symbols with the /D directive. In
  52.        the integrated compiler, you can also define symbols via
  53.        the Options/Compiler/Conditional Defines menu command.
  54.  
  55.     6. How much of the 64K in the data segment is actually
  56.        available to my program?
  57.  
  58.        The amount of data segment used by the run-time library
  59.        depends on which standard units you use in your program.
  60.        Here is the data segment usage (in bytes) for each unit:
  61.  
  62.              UNIT         Data Size
  63.              ----         ---------
  64.              System          664
  65.              Overlay          24
  66.              Crt              20
  67.              Dos               6
  68.              Printer         256
  69.              Graph          1070
  70.              Turbo3          256
  71.              Graph3            0
  72.                           =========
  73.                             2282
  74.  
  75.        The total size of the data segment is 65,520 bytes. If you
  76.        used only the System unit, the amount of data segment
  77.        space left over would be
  78.  
  79.              65520 - 664 = 64856 bytes
  80.  
  81.     7. What is the largest global data structure you can
  82.        allocate?
  83.  
  84.        The maximum size of a single variable that can be
  85.        allocated on the heap is 65,521 bytes.
  86.  
  87.     8. How do I find out how much code and data were generated by
  88.        the compiler for a program or unit?
  89.  
  90.        If you are using the integrated environment, build your
  91.        program or unit and then use the Get Info command in the
  92.        Compile menu. This will bring up a window of information
  93.        that includes the size of code and data.
  94.  
  95.        If you are using the command-line compiler, the size of
  96.        generated code and data is displayed on the screen at the
  97.        end of compilation.
  98.  
  99.     9. Are the .OBJ files generated by Turbo C and Turbo
  100.        Assembler compatible with 5.5?
  101.  
  102.        You can write Turbo C or Turbo Assembler routines and link
  103.        the .OBJ files into your Turbo Pascal programs by using
  104.        {$L} compiler directives. Turbo Pascal 5.5 generates .TPU
  105.        (Turbo Pascal Unit) files, not .OBJ files. We've made that
  106.        decision for many reasons:
  107.  
  108.          A. TP 5.5's .TPU files are smaller than .OBJ's, and they
  109.             contain symbolic information important to the support
  110.             of Pascal's strict type conventions (types, constants,
  111.             etc.).
  112.  
  113.          B. .TPU files allow "smart linking" - elimination of
  114.             unused code and data on a procedure-by-procedure
  115.             basis.
  116.  
  117.          C. .TPU's allow built-in project management through
  118.             version 5.5's Make and Build commands.
  119.  
  120.          D. .TPU's allow faster compilation speeds (34,000 lines
  121.             per minute on a PS/2 Model 60).
  122.  
  123.    10. Will the $L compiler directive work for compiler object files
  124.        other than assembler?
  125.  
  126.        That depends on the language. TURBO requires all the code
  127.        in the .OBJ to be in *one* CODE segment, and all the data
  128.        to be in *one* DATA segment. With assembly language that's
  129.        easy, but it may not work with some high-level language
  130.        compilers. You can use Turbo C to generate .OBJ files for
  131.        use by Turbo Pascal programs. An example, CPASDEMO.PAS is
  132.        included on the distribution disks.
  133.  
  134.    11. Does the built-in linker eliminate unused data?
  135.  
  136.        Yes. Unused code AND data are stripped when you compile to
  137.        disk.
  138.  
  139.    12. If two units use a third unit, does the third unit get
  140.        included twice in my program?
  141.  
  142.        No. All your units are "linked" together when you compile
  143.        your program. Only one copy of each procedure and function
  144.        used is generated.  There is NO duplication of run-time
  145.        code. In fact, Turbo Pascal 5.5 has "smart linking," which
  146.        eliminates any unused code and data from the final .EXE.
  147.  
  148.    13. What happens if you attempt to link another unit in which the
  149.        compiler directives are set differently?
  150.  
  151.        Compiler directives are local to the unit they are
  152.        declared in. Thus, the compiler directives in one unit, or
  153.        in the main program, have no effect on the directives set
  154.        in another unit.
  155.  
  156.    14. Can I create my own .TPL file?
  157.  
  158.        Yes, but Turbo Pascal will only use the TURBO.TPL library
  159.        file. If you want to add your own units to the TURBO.TPL
  160.        file, you can use the unit mover program (TPUMOVER.EXE).
  161.        For example, you might want a customized version of
  162.        TURBO.TPL for each of the programs you're developing. A
  163.        corresponding configuration file for Turbo Pascal would
  164.        specify a different Turbo directory and thus fetch the
  165.        appropriate .TPL file for each of your projects.
  166.  
  167.    15. What rules should I follow when writing an interrupt
  168.        handler?
  169.  
  170.        The following is a list of rules to keep in mind when
  171.        writing an interrupt handler:
  172.  
  173.          A. Use GetIntVec and SetIntVec to install/uninstall
  174.             interrupt handlers
  175.  
  176.          B. Use the interrupt directive
  177.  
  178.          C. Be careful about reentrancy. Don't use any calls to
  179.             DOS or to Turbo Pascal's overlay or heap management
  180.             routines in your interrupt handler
  181.  
  182.          D. Interrupt procedures and functions must use the far
  183.             call model (use the {$F+} option)
  184.  
  185.          E. Be proficient with the BIOS and assembly language
  186.             before attempting to write an interrupt handler
  187.  
  188.          F. Make sure your interrupt handler is not in an
  189.             overlaid unit.
  190.  
  191.          G. Neither static nor virtual methods can be used as
  192.             interrupt handlers.
  193.  
  194.    16. Does a procedure or function in a program have to be of a
  195.        near or far call model?
  196.  
  197.        If you are using overlays or procedural variables, you
  198.        should probably turn {$F+} on for all units and the main
  199.        program (the extra overhead of always using far calls is
  200.        usually quite small).
  201.  
  202.        Otherwise, Turbo Pascal automatically selects the correct
  203.        call model. A routine is always a near call model unless
  204.  
  205.         1) It is declared in the interface section of a unit
  206.  
  207.         2) You override the default call model by using the {$F+}
  208.            compiler option
  209.  
  210.         3) It is an object method. Methods are always far calls.
  211.  
  212.        You should also use the {$F+} option to override the
  213.        default call model if you are writing interrupt handlers,
  214.        error handlers, exit procedures, or procedures or
  215.        functions that will be called via a procedural variable.
  216.  
  217.    17. How do I write reentrant code in Turbo Pascal?
  218.  
  219.        If a routine follows these rules, it is reentrant:
  220.  
  221.          A. All data is allocated on the stack.
  222.  
  223.          B. The routine doesn't use any global variables.
  224.  
  225.          C. The routine can be interrupted at any time without
  226.             affecting the execution of the routine.
  227.  
  228.          D. The routine doesn't call any other routines that are
  229.             not reentrant (e.g., DOS I/O).
  230.  
  231.    18. What is the best approach to taking advantage of the new IEEE
  232.        floating-point types?
  233.  
  234.        The new IEEE floating-point types are available when you
  235.        compile your program with {$N+} and you have a math
  236.        coprocessor; they are also available if you don't have a
  237.        coprocessor, but specify {N+,E+}. The 8087 emulator has
  238.        greater precision, but is significantly slower than the
  239.        fast, 6-byte, software-only reals. When developing
  240.        programs that will be compiled and run on machines without
  241.        the 8087 coprocessor, consider the trade-offs of speed
  242.        (built-in reals) vs. precision (8087 hardware/emulation)
  243.        and make the appropriate choice.
  244.  
  245.    19. What type is Comp? What is it useful for?
  246.  
  247.        The Comp type is a cross between an integer and a real
  248.        type and is available when 8087 code is generated {$N+}.
  249.        If no math coprocessor is available, specify {$N+,E+} and
  250.        the emulator will support the Comp type.
  251.  
  252.        The compiler treats it as a real type without an exponent.
  253.        Thus Comp is useful when you need to store extremely large
  254.        numbers but don't need a decimal point. For example, you
  255.        might use variables of type Comp to store amounts in cents
  256.        and divide the value of the variable by 100 to determine
  257.        what the value in dollars and cents would be.
  258.  
  259.    20. How many significant digits do the 8087 floating-point types
  260.        provide?
  261.  
  262.        Type           Digits of precision
  263.        --------       -------------------
  264.        single               7-8
  265.        double              15-16
  266.        extended            19-20
  267.        comp                19-20
  268.  
  269.    21. Are the intermediate results of real number expressions
  270.        stored in the 8087 registers?
  271.  
  272.        No. The user (8086) stack is used to store intermediate
  273.        results of real number expressions.
  274.  
  275.    22. How does rounding work with IEEE floating point?
  276.  
  277.        The 8087 math coprocessor uses a different method for
  278.        rounding numbers than what you may be used to. In order to
  279.        achieve a more even distribution of values, the 8087 uses
  280.        a method sometimes called "Banker's Rounding." This method
  281.        dictates that a number will always be rounded to the
  282.        nearest EVEN number. Note that this is quite different
  283.        than always rounding UP. Here are a couple of examples:
  284.  
  285.           Round(0.5) = 0
  286.           Round(1.5) = 2
  287.  
  288.    23. How do you do I/O redirection?
  289.  
  290.        If you want to do DOS I/O redirection when running an .EXE
  291.        file generated by Turbo Pascal, DON'T use the Crt unit. If
  292.        you do, make sure you assign a null file name to the
  293.        standard Output file handle:
  294.  
  295.          Assign(Output, '');   { Assign a null file name Output }
  296.          ReWrite(Output);      { Open the file for output }
  297.  
  298.        Any Write statement that does not specify a file variable
  299.        will be redirected to the DOS standard output file.
  300.  
  301.    24. How do you go about upgrading version 3.0 programs with
  302.        lots of chain files?
  303.  
  304.        Chaining is not possible with .EXE files.  Control can be
  305.        passed to another program by use of the EXEC procedure in
  306.        the DOS unit. You can also use 5.5's overlay manager to
  307.        build very large programs.
  308.  
  309.    25. Are overlays supported in 5.5?
  310.  
  311.        Yes! See the example program OVRDEMO.PAS and refer to the
  312.        Turbo Pascal manual for information on overlays.
  313.  
  314.    26. Is there any support in Turbo Pascal 5.5 for file and record
  315.        locking?
  316.  
  317.        There's a standard variable in the System unit called
  318.        FileMode, which you can use to assign an open mode for use
  319.        in all subsequent Resets. There are no record-locking
  320.        routines implemented in the standard version, but they are
  321.        easily implemented through MsDos calls.
  322.  
  323.    27. Does Turbo 5.5 support procedural parameters?
  324.  
  325.        Yes. See PROCVAR.PAS, DIRDEMO.PAS, and refer to the
  326.        Reference Guide for a complete description.
  327.  
  328.    28. Can you use identifiers other than scalar in the case statement?
  329.  
  330.        Case statements allow the following ordinal types:
  331.  
  332.          Char, Boolean, ShortInt, Byte, Integer, Word, and
  333.          user-defined enumeration.
  334.  
  335.    29. Is the run-time license policy the same as in version 3.0?
  336.  
  337.        YES, there are no royalties!
  338.  
  339.    30. C has static variables, is there anything similar in 5.5?
  340.  
  341.        You can declare private global variables in the
  342.        implementation part of a unit. Such variables are only
  343.        visible within that unit. Like other globals, they retain
  344.        their values across calls.
  345.  
  346.        Typed constant declarations declared within a procedure or
  347.        function also behave exactly like C's static variables.
  348.        They are local in scope but since they are allocated in
  349.        the data segment, they retain their values from call to
  350.        call.
  351.  
  352.    31. What Turbo Pascal 3.0 code will cause the most problems
  353.        converting to version 5.5?
  354.  
  355.        With our UPGRADE program (see appropriate Appendix in your
  356.        manual), it's not very difficult to port your code to 5.5.
  357.        It depends a lot on the type of programs you write.
  358.  
  359.        The passing of parameters on the stack is done much more
  360.        efficiently now, so changes will have to be made to inline
  361.        machine code and assembly language. Most of the changes
  362.        are optional: using new types, breaking your program into
  363.        modules to take advantage of separate compilation. (The
  364.        UPGRADE program has a special option to help you "unitize"
  365.        your program too. It does all the "typing" for you.)
  366.  
  367.        Some stricter type-checking is performed in version 5.5.
  368.        For example, the Dos unit now defines the often-seen
  369.        registers record type (AX, BX...); MsDos and Intr now take
  370.        this type. In this case, you can type-cast or change the
  371.        type identifier and recompile.
  372.  
  373.    32. What books can I read that will help me with Turbo Pascal
  374.        5.5?
  375.  
  376.        The Turbo Pascal Tutor is an excellent reference to Turbo
  377.        Pascal. Also, Osborne/McGraw Hill has a line of books
  378.        about Borland's products.
  379.  
  380.    33. How do I use .BIN files provided by third-party vendors with
  381.        5.5?
  382.  
  383.        We've included a utility on your distribution disk called
  384.        BINOBJ.EXE, which converts binary files into .OBJ files
  385.        that are linkable to your Turbo Pascal 5.5 programs. In
  386.        general this will only work if the binary files contain
  387.        data, not code. Contact your third-party vendor to see if
  388.        they also provide .OBJ versions of their programs.
  389.  
  390.    34. Why does TURBO sometimes try to read from another drive
  391.        when I run it?
  392.  
  393.        When you leave Turbo Pascal, it saves the name and path of
  394.        the file you were last editing in a pick list. The next
  395.        time you load Turbo, it checks this pick list and tries to
  396.        load the file you were last editing. If the file you were
  397.        last editing was in another drive, Turbo will try to read
  398.        from that drive.  This also occurs if you have installed
  399.        another drive as your Turbo Directory.
  400.  
  401.    35. Does Turbo Pascal 5.5 support EMS?
  402.  
  403.        Yes, Turbo Pascal 5.5 will use up to 64K of EMS for
  404.        storing the edit buffer. In addition, you can instruct the
  405.        Overlay unit to place your overlaid units in EMS. Finally,
  406.        EMS.PAS on the distribution disk shows you how to access
  407.        EMS memory from a Turbo Pascal program.
  408.  
  409.    36. How can I allocate my own I/O buffer for a text file?
  410.  
  411.        You can use the procedure SetTextBuf to allocate your own
  412.        text file buffer either in the data segment or on the
  413.        heap.
  414.  
  415.    37. Why aren't the new settings used after I install TURBO.EXE
  416.        using the TINST.EXE program?
  417.  
  418.        You probably have a .TP file in the current or Turbo
  419.        directory being loaded and the settings in the .TP file
  420.        override the settings installed by TINST. Delete the .TP
  421.        file.
  422.  
  423.    38. What is the largest string supported?
  424.  
  425.        A string can be 255 characters long. You can write your
  426.        own routines to handle strings with lengths greater than
  427.        255 characters.
  428.  
  429.    39. Can I still write to file 'Con' without changes?
  430.  
  431.        The 'Con' file is no longer supported, but you can still
  432.        write to the screen with a simple Write with no file
  433.        variable. The file system has been completely redesigned
  434.        to allow you to write your own text file device drivers.
  435.        With these, you can implement a Pascal-like text-file
  436.        interface to any device, such as serial ports, windowing
  437.        systems, memory, etc.
  438.  
  439.    40. What is constant merging?
  440.  
  441.        For example, when you use the same string constant more
  442.        than once in a program block, the compiler only saves one
  443.        copy of this string. In the generated program, a pointer
  444.        is created that references the one copy of this string in
  445.        the generated .EXE file.
  446.  
  447.    41. Have Turbo Pascal 3.0 run-time error codes changed in
  448.        Turbo Pascal 5.5?
  449.  
  450.        Yes, error codes have changed; refer to Appendix I in the
  451.        Reference Guide.  The Turbo3 unit contains a version 3.0
  452.        compatible IOResult function.
  453.  
  454.