Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Batch Files Aim: To introduce the concept of Batch processing and programming techniques. Lesson Outcomes  The need for Batch Processing.

Similar presentations


Presentation on theme: "Programming Batch Files Aim: To introduce the concept of Batch processing and programming techniques. Lesson Outcomes  The need for Batch Processing."— Presentation transcript:

1 Programming Batch Files Aim: To introduce the concept of Batch processing and programming techniques. Lesson Outcomes  The need for Batch Processing.  Types of VARIABLES in batch processing.  Programming Commands and Techniques.

2 Learning Objectives By the end of the practical session, students should be able to:  Explain what is meant by Batch Files.  Identify situations in which Batch Files will enhance the performance of certain operations.  Describe the types of variables used with Batch Files.  Identify and describe some Batch File Commands.  Write a simple Batch File to perform specific operation.

3 Definition of a Batch File A Batch File is an unformatted text file that contains one or more DOS Commands. A Batch File is an unformatted text file that contains one or more DOS Commands. Why USE Batch Files?  To increase the speed of tasks (saves time!).  You need to remember only one command.  To create files that can quickly implement personalised functions.

4 How to Create Batch Files Use an ordinary TEXT EDITOR to create and save batch files. Use an ordinary TEXT EDITOR to create and save batch files. Enclose your filename and extension in QUOTATION marks to successfully save (e.g. “myfile.bat”). Enclose your filename and extension in QUOTATION marks to successfully save (e.g. “myfile.bat”). Directly copy from the keyboard to a file (e.g. copy con myfile.bat, ctrl + Z saves the file and allows you to exit when finished). Directly copy from the keyboard to a file (e.g. copy con myfile.bat, ctrl + Z saves the file and allows you to exit when finished).

5

6 Batch File :LABELS Labels identify the location of the next set of instructions (e.g. if your program is required to goto bob, then there must be a line starting with :bob ). Labels identify the location of the next set of instructions (e.g. if your program is required to goto bob, then there must be a line starting with :bob ). Labels always start with a colon (e.g. :label ) Labels always start with a colon (e.g. :label ) Labels generally contain a number of instructions similar to a sub-routine. Labels generally contain a number of instructions similar to a sub-routine.

7 Some Batch File Commands REM – also (;). Use this to document all files. REM – also (;). Use this to document all files. ECHO – prints the following text to screen or turns the ECHO ON or OFF ECHO – prints the following text to screen or turns the ECHO ON or OFF PAUSE – stop batch and wait for user input. PAUSE – stop batch and wait for user input. CALL – do another external process (batch file) & return to continue processing original batch file. CALL – do another external process (batch file) & return to continue processing original batch file.

8 Some Batch File Commands GOTO – jump to the following location in file. GOTO – jump to the following location in file. IF – conditional decision process (if next statement is true perform the following instructions). IF – conditional decision process (if next statement is true perform the following instructions). FOR – determines a set of conditions (e.g. FOR I = 1 to 10). FOR – determines a set of conditions (e.g. FOR I = 1 to 10). SHIFT – replace the current replaceable parameter variable with the next (may be left or right). SHIFT – replace the current replaceable parameter variable with the next (may be left or right). CHOICE – allows the user a choice of options. CHOICE – allows the user a choice of options.


Download ppt "Programming Batch Files Aim: To introduce the concept of Batch processing and programming techniques. Lesson Outcomes  The need for Batch Processing."

Similar presentations


Ads by Google