home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l044 / 4.ddi / ONLINE.ZIP / HELPME!.DOC < prev    next >
Encoding:
Text File  |  1990-10-23  |  12.2 KB  |  341 lines

  1.                         Turbo Pascal 6.0
  2.                         ----------------
  3.  
  4. This file contains answers to commonly asked questions. See the README
  5. file for suggestions on where to get more help. If you're programming
  6. with Turbo Vision, make sure you look at TVISION.DOC for additional
  7. information.
  8.  
  9.  
  10. Floppy use
  11. ----------
  12. Turbo Pascal 6.0 requires a dual-floppy system (a hard disk is
  13. recommended). If you're using 720 kbyte floppies (or more), you can
  14. put TURBO.EXE and TURBO.TPL on the same disk. If you're using 360
  15. kbyte floppies, you'll need to put TURBO.EXE on Drive B: and TURBO.TPL
  16. on your boot disk. Boot and then type B:TURBO. You can store your
  17. source files on the same disk with TURBO.TPL. You can use TPUMOVER to
  18. make TURBO.TPL smaller by removing units you don't use.
  19.  
  20. If you use the INSTALL program, make sure your floppies are completely
  21. empty (no system files or COMMAND.COM) before installing. After
  22. running INSTALL, you can copy TURBO.TPL onto a boot disk.
  23.  
  24. Turbo Pascal's online help system (TURBO.HLP) requires about 700
  25. kbytes of disk storage and cannot be used on a system equipped
  26. only with 360 kbyte floppy drives.
  27.  
  28. Once you have used INSTALL to build your working diskettes, you
  29. can manually UNZIP other Turbo Pascal components (e.g. BGI, Turbo
  30. Vision or the demo programs) onto other floppy diskettes.
  31.  
  32.  
  33. FreePtr and FreeMin
  34. -------------------
  35. These Turbo Pascal 5.x identifiers are no longer needed by the new
  36. heap manager. Simply delete references to FreeMin from your code. If
  37. you're using routines that use FreePtr to compress the heap or perform
  38. other implementation-dependent operations on the heap, you'll need to
  39. update these routines for use with the new heap manager. (If you just
  40. need to lower the top of memory in order to do an Exec, you can call
  41. the SetMemTop procedure from the Turbo Vision Memory unit.) See
  42. Chapter 16 in the Programmer's Guide for more information about how
  43. the new heap manager works.
  44.  
  45.  
  46. HeapError
  47. ---------
  48. If you are using a HeapError function, make sure it returns
  49. as quickly as possible when passed a Size value of 0:
  50.  
  51.   function HeapError(Size: Word): Integer; far;
  52.   begin
  53.     if Size > 0 then
  54.     begin
  55.       { ... perform HeapError processing here ... }
  56.     end;
  57.   end;
  58.  
  59. In version 6.0, HeapError is called with a value of 0 whenever an
  60. allocation moves the HeapPtr upwards.
  61.  
  62.  
  63. Mouse Support
  64. -------------
  65. Turbo Pascal's IDE and Turbo Vision require a mouse driver compatible
  66. with Microsoft driver 6.x or later.
  67.  
  68.  
  69. 286 Code Generation Notes
  70. -------------------------
  71. Programs compiled with {$G+} do not check the processor at runtime to
  72. determine whether it is 286-compatible. Trying to execute 80286
  73. instructions on an 8086 or an 8088 will lock up the computer.
  74. Refer to TEST286.PAS in \TP\DEMOS for an example of how to check
  75. for the presence of a 286-compatible chip at runtime.
  76.  
  77.  
  78. $X+ Is Global
  79. -------------
  80. The {$X+} compiler directive is global, so it must appear in the
  81. source code before any declarations or program statements. A $X
  82. directive elsewhere will cause an "Invalid Compiler Directive" error.
  83.  
  84.  
  85. Non-static Constuctor Calls
  86. ---------------------------
  87. When making inherited constructor calls from inside a method, always
  88. use the TypeName.ConstructorName syntax. This allows the compiler to
  89. statically call the inherited constructor and will not change the
  90. "identity" of the calling object:
  91.  
  92.   Correct:
  93.     ...
  94.     TObject.Init;         { always specify type name }
  95.     ...
  96.  
  97.   WRONG:
  98.     ...
  99.     Init;                 { may change calling object's "identity" }
  100.     ...
  101.  
  102.  
  103. DOS Critical Error Handling
  104. ---------------------------
  105. The IDE and Turbo Vision both provide critical error handling. Due to
  106. problems with some versions of DOS, however, you may need to press ESC
  107. several types to successfully cancel an operation after a critical
  108. error has occurred (e.g. DRIVE NOT READY).
  109.  
  110.  
  111. Iterator Methods
  112. ----------------
  113. The ForEach, FirstThat and LastThat all take a local (nested), far
  114. procedure or function as a parameter. Refer to Chapter 7 in the Turbo
  115. Vision Guide for details.
  116.  
  117. Note: never use ForEach to delete items from a collection. The act of
  118. deleting an item moves subsequent items forward and will result in
  119. items being skipped.
  120.  
  121.  
  122. Editor Swap File
  123. ----------------
  124. The IDE creates a swap file for its virtual editor with the naming
  125. convention of TPxxxx.$$$. Never delete this file while the IDE is
  126. running (e.g. while in a DOS shell). However, if you reboot your
  127. system while the IDE is running, it is safe to delete the swap file
  128. before re-loading the IDE.
  129.  
  130. Note that the swap file grows but never shrinks while the IDE is
  131. running. If you're editing a large file on a drive without much disk
  132. space available, place the swap file on another drive (ideally a RAM
  133. disk; use the /S command-line option at startup). If there is no other
  134. drive available, and you've done an unusual amount of editing of large
  135. files, you can exit and re-load the IDE and thus reduce the swap file
  136. down to a normal size.
  137.  
  138.  
  139. Inline Assembler Notes
  140. ----------------------
  141.  The built-in assembler works differently than Turbo Assembler in the
  142.  following case. In TASM, there is no distinction between an array of
  143.  some types and a single variable of this type:
  144.  
  145.     MyVar       DW      ?
  146.     MyArray     DW      10 DUP(?)
  147.                 .
  148.                 .
  149.                 MOV     AX,MyVar
  150.                 MOV     AX,MyArray[BX]
  151.  
  152.   Using TASM on the above example, the type of both "MyVar" and
  153.   "MyArray" is WORD, and either can be loaded into a word-sized
  154.   register without a type cast.
  155.  
  156.   This is not the case with Turbo Pascal's built-in assembler. In
  157.   Pascal, an array is not the same as a single variable, and a type
  158.   cast is required when accessing an element of an array, as
  159.   illustrated below:
  160.  
  161.     var
  162.       MyVar: Word;
  163.       MyArray: array[0..9] of Word;
  164.       .
  165.       .
  166.     asm
  167.       MOV     AX,MyVar
  168.       MOV     AX,MyArray[BX].Word
  169.       MOV     AX,WORD PTR MyArray[BX]
  170.     end;
  171.  
  172.  
  173. Turbo Pascal 6.0 and the Toolboxes
  174. ----------------------------------
  175. With the exception of the Turbo Editor Toolbox, the 4.0 toolboxes
  176. will compile with Turbo Pascal 6.0. The Turbo Editor Toolbox
  177. needs the minor source code changes described below in order to
  178. work with the new heap manager:
  179.  
  180.   MicroStar
  181.   ---------
  182.     In MSVARS.PAS:
  183.       1) On line 219 after "var"
  184.             Add  "FreePtr: Pointer;"
  185.       2) On line 295 after "begin"
  186.             Add  "FreePtr := Ptr(Seg(HeapEnd^) - $1000, 0);"
  187.     In INVOKE.PAS:
  188.       1) On line 18 after "Dos"
  189.             Add   ", MsVars"
  190.  
  191.   FirstEd
  192.   -------
  193.     In EDVARS.PAS:
  194.       1) On line 139
  195.             Add "FreePtr: Pointer;"
  196.          On line 207
  197.             Add "FreePtr := Ptr(Seg(HeapEnd^) - $1000, 0);"
  198.  
  199. In addition, an updated version of BINED.OBJ is required for use
  200. with version 6.0 and is available on CompuServe.
  201.  
  202.  
  203. ************************************************
  204. Tech Support's Ten Most Commonly Asked Questions
  205. ************************************************
  206.  
  207.   1. How do you read and write a file inside a Turbo Pascal
  208.      program?
  209.  
  210.      Here's a program that creates a text file and then reads it
  211.      back:
  212.  
  213.        program FileDemo;
  214.        var
  215.          FileVar: Text;
  216.          InString, OutString: String;
  217.        begin
  218.          OutString := 'Write this to a text file';
  219.          Assign(FileVar, 'TEST.TXT');
  220.          Rewrite(FileVar);           { Creates new text file }
  221.          Writeln(FileVar, OutString);
  222.          Close(FileVar);
  223.          Assign(FileVar, 'TEST.TXT');
  224.          Reset(FileVar);             { Opens existing text file }
  225.          Readln(FileVar, InString);
  226.          Close(FileVar);
  227.        end.
  228.  
  229.   2. What is the GRAPH.TPU file?
  230.  
  231.      GRAPH.TPU is the BGI unit found in BGI.ZIP on your distribution
  232.      diskettes. The INSTALL program puts it in \TP\BGI by default.
  233.  
  234.   3. How do you send a program's output to the printer?
  235.  
  236.        program Print;
  237.        uses Printer;
  238.        begin
  239.          Writeln(Lst, 'Hello Printer');
  240.        end.
  241.  
  242.   4. Why am I getting a "Unit file format error" when I compile my
  243.      program with the new Turbo Pascal compiler?
  244.  
  245.      You are using a unit that has been compiled with an earlier
  246.      version of Turbo Pascal. Re-build all your programs with Turbo
  247.      Pascal 6.0 using the command-line compiler's /B switch or using
  248.      the IDE's Compile|Build command.
  249.  
  250.      Contact third-party vendors for updated TPU's if you don't
  251.      have the source code.
  252.  
  253.   5. How do you calculate X to the power of Y?
  254.  
  255.        function Power(X, Y: Real): Real;
  256.        begin
  257.          Power := Exp(Y * Ln(X));
  258.        end.
  259.  
  260.   6. How come my program runs fine in the IDE and locks when run
  261.      from the DOS prompt?
  262.  
  263.      This usually happens when you have uninitialized variables (for
  264.      another possible reason, refer to the next question).
  265.  
  266.   7. I think my program is trashing memory. Which statements are the
  267.      likely culprits?
  268.  
  269.      Here are some of the most common causes for out-of-bounds memory
  270.      writes:
  271.  
  272.      Problem                        Suggestion
  273.      -------                        ----------
  274.      Array index out of range       Turn on range checking {$R+}.
  275.  
  276.      Uninitialized variable         Initialize it, of course.
  277.  
  278.      Pointers out of bounds         Make sure you're not using
  279.                                     unallocated pointers or pointers
  280.                                     to blocks that have been
  281.                                     disposed.
  282.  
  283.      Move, FillChar, BlockRead      These routines all write to
  284.                                     memory without regard for
  285.                                     Pascal's normal size- and
  286.                                     type-checking. Make sure you're
  287.                                     specifying the correct amount of
  288.                                     data to be moved, filled or
  289.                                     read.
  290.  
  291.      Indexing beyond the size       If you're using relaxed var string
  292.      of a string                    checking {$V-}, make sure you're
  293.                                     not writing past the end of a
  294.                                     string (and onto neighboring
  295.                                     data).
  296.  
  297.   8. Why doesn't the Exec procedure run the program I specify?
  298.  
  299.      Make sure you define a maximum heap size using a $M compiler
  300.      directive at the beginning of your program. Refer to EXECDEMO.PAS
  301.      in \TP\DEMOS.
  302.  
  303.      In addition to omitting a $M compiler directive, two other common
  304.      are common errors can be diagnosed easily by looking at the
  305.      value of DosError after a call to Exec:
  306.  
  307.      DosError     Explanation
  308.      --------     -----------
  309.         2         File not found. Specify the full path and program
  310.                   name. If you're trying to execute an internal DOS
  311.                   command (like DIR), you need to Exec COMMAND.COM
  312.                   (see the Exec example in online help and the Library
  313.                   Reference).
  314.  
  315.         8         Not enough memory available to Exec the specified
  316.                   program. Lower the amount of heap your program is
  317.                   using (see \TP\DEMOS\EXECDEMO.PAS).
  318.  
  319.  
  320.   9. What do I do if Turbo Pascal gives an "out of memory" error?
  321.  
  322.      If you're running out of memory using the IDE, you have many
  323.      configuration options available. Refer to P-146 in the User's
  324.      Guide for a comprehensive checklist.
  325.  
  326.      If you're using the command-line compiler and running out of
  327.      memory during a compilation, first try the appropriate
  328.      suggestions on P-146 in the User's Guide. If you're still running
  329.      out of memory during compilation, you should probably TPCX.EXE,
  330.      the extended memory compiler available with Turbo Pascal 6.0
  331.      Professional.
  332.  
  333.  10. How come I don't get the results that I expect when I
  334.      compare and print real numbers?
  335.  
  336.      Floating point, or real numbers, are an approximation and small
  337.      rounding errors will occur during calculations and
  338.      transformations between numeric types. For a complete discussion
  339.      of this topic, refer to the section on comparing reals in Chapter
  340.      14 in the Programmer's Guide.
  341.