home *** CD-ROM | disk | FTP | other *** search
- TURBO PASCAL Questions and Answers
- ----------------------------------
-
-
- Q: How can I get a listing of my program?
-
- A: From within the TURBO editor
- ----------------------------
- The blockwrite command (Ctrl-K-W) can be used to write a
- listing of your program to the printer:
-
- Mark the complete file as a block:
-
- 1. Type: Ctrl-Q-R to move to the beginning of the file.
- 2. Type: Ctrl-K-B to mark the top of the block.
- 2. Type: Ctrl-K-B to mark the beginning of the block.
- 3. Type: Ctrl-Q-C to move to the end of the file.
- 4. Type: Ctrl-K-K to mark the end of the block.
-
- Now write the marked block:
-
- 1. Type: Ctrl-K-W to write the block.
- 2. Respond to the prompt "Write Block to File" by typing PRN
- and hit return.
- 3. Type "Y" to the prompt "Overwrite old PRN. (Y/N)?" and the
- file will be printed.
-
- At the MS-DOS Prompt
- --------------------
- When at the system prompt, type the line:
-
- COPY FILENAME PRN <Return>
-
- Your file will be copied to the printer.
-
-
- Q: How do I direct data from my program to a line printer?
-
- A: TURBO PASCAL provides a very easy way to direct data to the
- line printer. All you have to do is include the logical
- device LST in your write statement:
-
- Writeln(LST,'TURBO PASCAL IS FAST');
-
-
- Q: How can I send a "run" of my program to the printer?
-
- A: To direct all write procedures to the printer, assign the
- pointer that is used for console output to the value of the
- listing device output pointer. The following statement should
- be the first statement after the "begin" of your main program
- body:
-
- ConOutPtr := LstOutPtr;
-
- All output to the console will now be re-directed to the
- list device.
-
-
- Q: How can I use more than 64K in my code segment?
-
- A: TURBO PASCAL is a very powerful compiler. A maximum of 64K
- has been allocated for the code size, static data, area
- and the Stack. Any remaining memory is placed on the heap
- and can be accessed by using dynamic variables.
-
- The code segment limitation can be overcome by the use
- of overlays or chain files. For more information, please
- refer to the section on overlays in your TURBO PASCAL
- Reference Manual.
-
-
- Q: How Can I create a .COM File?
-
- A: TURBO PASCAL allows you to produce executable .COM files.
- Just follow these steps:
-
- 1) With the TURBO PASCAL diskette in the default drive and
- a DOS prompt, type <T><U><R><B><O> and hit <RETURN>.
- 2) Type <Y> to include error messages.
- 3) Type <W> to specify the work file name.
- 4) Type <O> for compiler options.
- 5) Type <C> for .COM file.
- 6) Type <Q> to quit back to main menu.
- 7) Type <C> to compile your program.
- 8) Type <Q> to return to the operating system.
-
- To execute your program, you must first exit TURBO. Then type
- your programs name at the DOS prompt.
-
-
- Q: How can I rename my work file?
-
- A: Define the file as a block of text.
-
- 1. Type: Ctrl-Q-R to move to the beginning of the file.
- 2. Type: Ctrl-K-B to mark the top of the block.
- 3. Type: Ctrl-Q-C to move to the end of the file.
- 4. Type: Ctrl-K-K to mark the end of the block.
-
- Now write the marked block to disk.
-
- 1. Type: Ctrl-K-W to write the block.
- 2. Enter the file name you desire when you get the prompt:
- "Write block to file:"
-
- This will write a copy of the file to the file name that you
- specify.
-
- Note: A portion of a file may be written to disk in the same
- manner by reducing the size of the block.
-
-
- Q: When I compile my program to memory, it runs just fine. But
- when I compile it to a .COM file it doesn't.
-
- A: A program may appear to be completely debugged when
- compiling directly to memory, yet when the same program is
- re-compiled to a .COM file, it does not run as expected.
- There are three possible explanations for this behavior:
-
- 1. Un-initialized variables
- -----------------------
- You should make sure that all variables have been properly
- initialized (reals and integers set to zero, characters set
- to blank, pointers set to nil, etc.).
-
- Your program may not encounter problems with a variable
- that has not been initialized. The reason for this is the
- data area for that variable may have a bit pattern which
- initially gives this variable an acceptable value.
-
- If your program is placed at a different location in
- memory, your variables will be initialized with different
- values. This may cause your program to stop executing
- correctly. The following conditions can cause this to
- happen.
-
- a. Compiling to disk (.COM file) instead of memory.
- b. Adding aditional lines of code to your program, thus
- changing the location of the data segment.
- c. Adding more data to your program.
- d. If you add or remove memory-resident programs (SIDEKICK,
- SUPERKEY, RAM disks, etc.).
-
- 2. Misuse of pointer variables
- ---------------------------
- If the uninitialized variable happens to be a pointer,
- results are even more unpredictable. A pointer variable
- can point to any memory location in your computer. If
- this pointer is used to store data, you could easily
- overwrite your own code, your data, or even destroy the
- memory resident operating system in memory.
-
-
- Q: When running my TURBO program, I get a "Memory Allocation
- Error..."
-
- A: The error message "memory allocation error, cannot load
- command file, system halted" is an operating system error
- message.
-
- The program you are executing has overwritten the operating
- system and cannot return control to DOS. This condition may
- be caused by:
-
- 1. Heap/Stack collision
- 2. Writing to an absolute address in memory occupied by DOS.
-
-
- {End Of File!}