home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / PASCAL.ZIP / QUESTIN.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-09-20  |  6.0 KB  |  172 lines

  1.                    TURBO PASCAL Questions and Answers
  2.                    ----------------------------------
  3.  
  4.  
  5. Q: How can I get a listing of my program?
  6.  
  7. A: From within the TURBO editor
  8.    ----------------------------
  9.    The blockwrite command (Ctrl-K-W) can be used to write a
  10.    listing of your program to the printer:
  11.  
  12.    Mark the complete file as a block:
  13.  
  14.    1. Type: Ctrl-Q-R to move to the beginning of the file.
  15.    2. Type: Ctrl-K-B to mark the top of the block.
  16.    2. Type: Ctrl-K-B to mark the beginning of the block.
  17.    3. Type: Ctrl-Q-C to move to the end of the file.
  18.    4. Type: Ctrl-K-K to mark the end of the block.
  19.  
  20.    Now write the marked block:
  21.  
  22.    1. Type: Ctrl-K-W to write the block.
  23.    2. Respond to the prompt "Write Block to File" by typing PRN
  24.       and hit return.
  25.    3. Type "Y" to the prompt "Overwrite old PRN. (Y/N)?" and  the
  26.       file will be printed.
  27.  
  28.    At the MS-DOS Prompt
  29.    --------------------
  30.    When at the system prompt, type the line:
  31.  
  32.    COPY FILENAME PRN <Return>
  33.  
  34.    Your file will be copied to the printer.
  35.  
  36.  
  37. Q: How do I direct data from my program to a line printer?
  38.  
  39. A: TURBO  PASCAL provides a very easy way to direct data to the
  40.    line printer.  All you have to do is include the logical
  41.    device LST in your  write statement:
  42.  
  43.      Writeln(LST,'TURBO PASCAL IS FAST');
  44.  
  45.  
  46. Q: How can I send a "run" of my program to the printer?
  47.  
  48. A: To direct all write procedures to the printer, assign the
  49.    pointer that is used for console output to the value of the
  50.    listing device output pointer.  The following statement should
  51.    be the first statement after the "begin" of your main program
  52.    body:
  53.  
  54.      ConOutPtr := LstOutPtr;
  55.  
  56.    All output  to the console  will  now  be re-directed to the
  57.    list device.
  58.  
  59.  
  60. Q: How can I use more than 64K in my code segment?
  61.  
  62. A: TURBO PASCAL is a very powerful compiler.   A maximum of 64K
  63.    has been  allocated  for the code size,  static data,  area
  64.    and the Stack.   Any  remaining  memory is placed on the heap
  65.    and can be accessed by using dynamic variables.
  66.  
  67.    The  code  segment  limitation  can be overcome  by  the  use
  68.    of overlays or chain files.  For  more information,  please
  69.    refer to the section on overlays in your TURBO PASCAL
  70.    Reference Manual.
  71.  
  72.  
  73. Q: How Can I create a .COM File?
  74.  
  75. A: TURBO PASCAL allows you to produce executable .COM files.
  76.    Just follow these steps:
  77.  
  78.    1)  With the TURBO PASCAL diskette in the default drive and
  79.        a DOS prompt, type <T><U><R><B><O> and hit <RETURN>.
  80.    2)  Type <Y> to include error messages.
  81.    3)  Type <W> to specify the work file name.
  82.    4)  Type <O> for compiler options.
  83.    5)  Type <C> for .COM file.
  84.    6)  Type <Q> to quit back to main menu.
  85.    7)  Type <C> to compile your program.
  86.    8)  Type <Q> to return to the operating system.
  87.  
  88. To execute your program, you must first exit TURBO.  Then type
  89. your programs name at the DOS prompt.
  90.  
  91.  
  92. Q: How can I rename my work file?
  93.  
  94. A: Define the file as a block of text.
  95.  
  96.    1. Type: Ctrl-Q-R to move to the beginning of the file.
  97.    2. Type: Ctrl-K-B to mark the top of the block.
  98.    3. Type: Ctrl-Q-C to move to the end of the file.
  99.    4. Type: Ctrl-K-K to mark the end of the block.
  100.  
  101.    Now write the marked block to disk.
  102.  
  103.    1. Type: Ctrl-K-W to write the block.
  104.    2. Enter the file name you desire when you get the prompt:
  105.       "Write block to file:"
  106.  
  107.    This will write a copy of the file to the file name that  you
  108.    specify.
  109.  
  110.    Note: A portion of a file may be written to disk in the same
  111.          manner by reducing the size of the block.
  112.  
  113.  
  114. Q: When I compile my program to memory, it runs just fine.  But
  115.    when I compile it to a .COM file it doesn't.
  116.  
  117. A: A program may  appear  to be completely debugged when
  118.    compiling directly to memory,  yet when  the  same program is
  119.    re-compiled to a .COM file,  it  does not run as expected.
  120.    There are three possible explanations for this behavior:
  121.  
  122.    1. Un-initialized variables
  123.       -----------------------
  124.       You should make sure that all variables have been properly
  125.       initialized (reals and integers set to zero, characters set
  126.       to blank, pointers set to nil, etc.).
  127.  
  128.       Your program may not encounter problems with a variable
  129.       that has not been initialized. The reason for this is the
  130.       data area for that variable may have a bit pattern which
  131.       initially gives this variable an acceptable value.
  132.  
  133.       If your program is placed at a different location in
  134.       memory, your variables will be initialized with different
  135.       values.  This may cause your program to stop executing
  136.       correctly.  The following conditions can cause this to
  137.       happen.
  138.  
  139.       a. Compiling to disk (.COM file) instead of memory.
  140.       b. Adding aditional lines of code to your program, thus
  141.          changing the location of the data segment.
  142.       c. Adding more data to your program.
  143.       d. If you add or remove memory-resident programs (SIDEKICK,
  144.          SUPERKEY,  RAM disks, etc.).
  145.  
  146.    2. Misuse of pointer variables
  147.       ---------------------------
  148.       If  the uninitialized variable happens to be a  pointer,
  149.       results are even more unpredictable.  A pointer variable
  150.       can point to any memory  location in your computer.   If
  151.       this pointer is  used  to store data,  you could easily
  152.       overwrite your own code, your data, or even destroy the
  153.       memory resident operating system in memory.
  154.  
  155.  
  156. Q: When running my TURBO program, I get a "Memory Allocation
  157.    Error..."
  158.  
  159. A: The  error message "memory allocation error,  cannot load
  160.    command file,  system halted"  is an operating system error
  161.    message.
  162.  
  163.    The program  you  are executing has overwritten the operating
  164.    system  and cannot return control to DOS.  This condition may
  165.    be caused by:
  166.  
  167.    1. Heap/Stack collision
  168.    2. Writing to an absolute address in memory occupied by DOS.
  169.  
  170.  
  171. {End Of File!}
  172.