Ch 10 Introduction to Batch Files - Del Mar College
Chapter 10
Introduction to Batch Files
ANSWERS TO DISCUSSION QUESTIONS (p. 539)
1. Explain the purpose and function of batch files.
Batch files are used to simplify long and complex OS commands. They allow a user to put together a string of commands and execute them with one command. They are used to automate frequent and/or consistent procedures that are always done in the same manner.
2. Compare and contrast batch processing with interactive processing.
Interactive processing requires continuous user interaction with the computer which updates the records immediately. In interactive processing the user interfaces with the computer directly by giving the computer an instruction and the computer performing that one instruction.
Batch processing does not require user interaction while batch files are running. In batch processing the computer runs a series of instructions without interruptions. This means that the user writes a command file that automates a sequence of commands and stores the text file under an easily remembered name. The user keys in the batch file command and the computer then reads and executes each line of the batch file without any user intervention.
3. You have a batch file called CHECK.BAT. You key in CHECK at the prompt. Where does it look for the file? What does the operating system then do?
The OS will first check for any CHECK file name internally, then any file with the .COM extension, then .EXE and last the .BAT or .CMD extension. OS will check the default drive and directory for the file CHECK.BAT. If it does not find the file there it will then look for the file on the search path. As soon as the batch file is found, the OS will open up that file and execute the commands in the file one at a time. After the batch file is completed, OS will return control to the system.
4. What is an ASCII file? Why is it important in batch processing?
ASCII refers to the way characters are represented in a computer. It is a code used by the operating system to interpret letters, numbers, and punctuation marks that are keyed in. It is important in batch processing because batch files must be written so that commands and statements are unformatted text files, i.e., ASCII files.
5. Under what circumstances can a word processor be used to write batch files?
A word processor can be used to write batch files only if it has a means to save files in ASCII. Most commercial word processors allow the user to do this. Sometimes this feature is called an unformatted text file.
6. Compare and contrast using Edit and COPY CON to write batch files.
COPY CON can be used to make simple batch files. However, if a typing error occurs it is necessary to start over from the beginning, as errors cannot be corrected once has been pressed at the end of a command line. It is not possible to correct errors in an existing file. COPY CON is fast, and is always available as it is an internal command.
EDIT is an external command and needs to be loaded into RAM before it is available for use. However, EDIT can open an existing file and make changes to it.
7. Explain the purpose and function of the /O and /A parameters when used with the DIR command.
The /O parameter, when used with the DIR command, is used to put the files in order. (It is possible to put the files in reverse order by using the -.) To show subdirectories on the DATA disk use /AD with DIR command. The /A switch means attribute and the attribute you want displayed is D to show subdirectories.
8. Explain the purpose and function of the REM command. What happens when the operating system sees REM in a batch file?
REM allows the user to document (explain the purpose a file serves) a file. When the OS is processing a batch file and encounters a REM, it ignores the line and proceeds to the next line.
9. In a data-processing environment, what does it mean to document a batch file? Why would it be important to document a batch file?
To give an explanation about the purpose of the file. Include the name of the batch file, time and date last updated, author of the file, or comments on specific parts of long batch files. The REM statements should tell anyone what the purpose of the batch file is. Remarks can include who wrote the batch file and when it was last updated.
10. Explain the purpose and function of the ECHO command.
The ECHO command can be used to minimize screen clutter. The ECHO command in batch files controls what is displayed on the screen. ECHO ON will display the commands themselves while executing a batch file. ECHO OFF will not display the commands themselves, but only the results of the commands while executing batch files.
11. Explain the purpose and function of the PAUSE command.
The PAUSE command will temporarily stop the execution of a batch file until the user presses a key. This gives the user a chance to read what is on the screen, or if the user wants to take some action, such as turning on a printer or confirming deletion of a file.
12. Why does the PAUSE command require user intervention?
The PAUSE command requires user intervention because the batch file just keeps running until the user presses a key.
13. How can you stop a batch file from executing once it has begun?
To stop a batch file from executing once it has begun press or C. Also, the PAUSE command can stop a batch file during execution until a key ispressesed.
14. What are parameters?
Parameters are qualifiers or modifiers that can be added to a command that will specify an action to be taken. In other words, parameters are information that you want the command to have.
15. What is a replaceable parameter? Describe how it might be used.
A replaceable or variable parameter (can have more than one in a file) is value/information provided by the user that is added to a command to give the command additional instructions on what to do. Parameters are placed on the command line after the name of the program. Parameters allow information, such as file names, to be passed into a batch file. The power of batch files is their ability to use replaceable parameters.
16. What indicates to the operating system that there is a replaceable parameter in a file?
The percent (%) sign followed immediately by a numerical value (0-9), indicates a replaceable parameter in a batch file. The OS then looks on the command line for what value to place in the batch files.
17. What advantages are there to using replaceable parameters in a batch file?
Replaceable parameters in a batch file allow reusing the same batch file with many different file names, and allow the user to write generic files or commands.
18. Replaceable parameters are sometimes called positional parameters. Explain.
Replaceable parameters are sometimes called positional parameters because they occupy specific positions on the command line. %0 is usually the command itself. %1 occupies the first position after the command, %2 the second position after the command, etc.
19. There appear to be two prompts when you do not use the ECHO OFF. Explain.
The OS reads each line in the batch file as if it were being keyed in. It has no way to know when there are no more lines to read. It finds out when it tries to put a batch file line at the prompt. Since there is no line, the OS exits the batch file and returns to the "real" prompt, thus giving the appearance of two prompts.
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
Related searches
- college student introduction to class
- 7000 14 r vol 10 ch 10 1000203a
- introduction to biology college level
- introduction to college statistics
- batch files examples
- batch files commands
- windows 10 batch files examples
- passing parameters to batch files
- batch files for beginners
- 10 keys to college success
- windows batch files to rename files
- how to batch rename files