OS/2 Batch Files To Go
Description of Chapters

Chapter 1: Writing OS/2 Batch Files. Batch files are programs so they need to be written as ASCII files. Often, that's difficult to do with a word processor. However, the Enhanced Editor of OS/2 makes short work of writing batch files. This chapter explains how to use the OS/2 Enhanced Editor. It also explains how you can use your word processor to write batch files.

Chapter 2: Starting A Batch File. Under DOS, the only way to start a batch file is to enter its name on the command line. This works under OS/2 but as a graphical user interface, OS/2 offers a second way-you can install the batch file as an icon and just click on that icon to run the batch file. This chapter explains how to use both methods to run a batch file.

Chapter 3: Batch File Introduction. Batch files have four major uses: keystroke reduction, new command construction, consistency and safety. OS/2 can run three different types of batch files, DOS batch files, OS/2 batch files and OS/2 REXX programs. This chapter explains these concepts in more detail.

Chapter 4: Batch File Construction. This chapter explains naming conventions and layout considerations you need to understand when you begin to write batch files.

Chapter 5: REM Documentation: "Why In The World Did I Do That?" The batch language only has a few commands of its own but it can also run any program you own. As a result, some batch files tend to become very long. Using the REM command to document those longer batch files can make following their logic easier when you have to modify them in the future. This chapter explains how to do that.

Chapter 6: Let's Keep It Quiet. The default mode of operation for a batch file is to have command echoing on, which means that commands are displayed on the screen before they are executed. By turning command echoing off, your screens will look much neater. This chapter explains how to do that.

Chapter 7: Talking To The User. Batch files frequently need to "talk" to the user to display information, ask questions or provide warnings. The ECHO command provides the method for doing this. This chapter explains how to use the ECHO command effectively.

Chapter 8: Using High-ordered ASCII Characters. Your batch files can be made much more attractive by using some of the high-ordered ASCII characters available. This chapter explains how to use these characters.

Chapter 9: Hold That Batch File! Sometimes you need for the batch file to wait for the user to catch up. Maybe it has put a lot of information on the screen for the user to read or the user needs a chance to press Ctrl-Break and halt the batch file. This chapter explains how to use the PAUSE command in a batch file to suspend its operation until a key is pressed.

Chapter 10: Applications And Problems. Before moving on to the intermediate batch subcommands, you should understand the commands and concepts covered so far. This chapter is a quick test. Pass it, and you're ready to move on.

Chapter 11: Replaceable Parameters. Unless you have a way to get information into a batch file, it is difficult to have the batch file perform differently each time it runs. Replaceable parameters are a method of adding additional information on the command line that the batch file then has access to. This information can be used as file names, extensions, subdirectories, commands, or just about anything you use in a batch file.

Chapter 12: Using More Than Ten Replaceable Parameters. When it first starts, the batch file only has access to its name and the first nine pieces of information you entered on the command line. This chapter show you how to gain access to additional information.

Chapter 13: Looping And Program Flow. This chapter shows you how to define different execution paths through the batch file and how to create loops within a batch file.

Chapter 14: The Environment. The environment is an important scratch pad for the operating system. It uses the environment to store information that all the programs need access to.

Chapter 15: Errorlevel. The errorlevel is a one-byte portion of memory that programs can use to communicate to each other or with a batch file. While only a few programs use the errorlevel, batch file utilities use it to pass results back to the batch file that ran them. This chapter provides an overview of the errorlevel.

Chapter 16: Command Line Punctuation. Many of the batch files you have seen so far have used varying types of punctuation to help them perform their work. This chapter documents that punctuation as a resource to help you understand these batch files as well as write more powerful batch files of your own.

Chapter 17: Logic testing. The different paths you learned to create are useless unless you have a method of selecting different paths at different times. Additionally, the loops you learned to create are endless unless you have a way to get out of them. In both cases, logic testing is the solution. This chapter shows you how to build logic testing into your batch files. Logic testing is what turns a batch file away from being just a dumb script the computer plays back into an intelligent program.

Chapter 18: Applications and problems. Before moving on to the advanced batch subcommands, you should understand the commands and concepts covered so far. This chapter is a quick test. Pass it, and you're ready to move on.

Chapter 19: Advanced logic testing. In Chapter 17, we covered simple logic testing. This chapter expands logic testing to include all the available logic testing commands OS/2 offers.

Chapter 20: Advanced getting information from users. OS/2 makes it fairly difficult to get information from the user, giving you just replaceable parameters and Ctrl-Break to do the job. This chapter shows how to use the utility programs that come with this book to greatly expand the ability of a batch file to interact with the user.

Chapter 21: Advanced Screen Design I. Most batch files use a series of ECHO commands to communicate with the user in a very boring fashion. This chapter covers things you can do to improve your boring batch file screens.

Chapter 22: Advanced Screen Design 2: ANSI. This chapter continues where Chapter 21 leaves off by showing you how to used advanced ANSI commands to construct colorful and highly formatted screens. It also briefly covers other uses for ANSI.

Chapter 23: Batch file subroutines. Subroutines are one of the most powerful approaches available to writing complex batch files. This chapter shows you how to use them.

Chapter 24: When batch files don't work. Even after reading a book as good as this one, you are going to occasionally have problems with the batch files you write. While nothing can eliminate the need for you to work through the logic of your batch file to resolve this problem, this chapter shows you some ways to expedite the process.

Chapter 25: Applications and problems. Before moving on, you should understand the commands and concepts covered so far. This chapter is a quick test. Pass it, and you're ready to move on.

Chapter 26: REXX. The REXX language that comes with OS/2 is a very powerful language. This chapter provides a brief introduction into this very powerful language.

Chapter 27: Batch File Utilities. The REXX language that comes with OS/2 gives me the ability to provide you with some very powerful and useful batch file utilities. This chapter will document their function as well as showing you the actual source code and giving you modification hints so you can easily customize these utilities for your own use.

Chapter 28: An Automated Batch File Help System. One problem with having a lot of batch files is remembering which batch file does what. As it turns out, batch files can solve this problem and, in the process, give you a set of very powerful tools for locating the right batch file for your needs. This chapter documents this most powerful utility.

Chapter 29: A Document Archival System. Never lose an important file again! That is a strong claim, but this chapter will show you how.

Chapter 30: Keeping Two Computers In Synchronization. You are working on a project at work and you decide to take work home with you. Now, you've got to remember to grab copies of all the files that have changed since you last worked on this project at home. Tomorrow morning, you'll face this same problem again as you get ready to bring the finished work back to the office. This chapter will show you how to fully automate this process-even if one machine is running OS/2 and the other is running DOS!

Chapter 31: Simulating DOSKEY Using Batch Files. The DOS DOSKEY gives you command line recall, keyboard macros, and the ability to enter multiple commands on a single command line. OS/2 supports entering multiple commands on one command line and has command line recall if you have KEYS ON. It does not have macro capabilities. In this chapter, we will see how to add macros and improve command line recall-even with KEYS OFF-all using nothing but batch files.

Chapter 32: Smaller Batch File Applications. This chapter presents a number of batch file applications that were too small to put in their own chapter.

Appendix A: Solutions To Problems. This appendix explains my solutions to the various problems I ask you to attempt. You could have a different solution that is just as good or even better so don't worry if your solution does not match my solution.

Appendix B: Documentation. This appendix briefly documents all the batch files and other utilities you will find on the disk.

Appendix C: Icons. Many batch files run other programs. In order to assign the appropriate icon to many of your batch files, you are going to need many general purpose icons. These are included on the disk. To help you quickly find the right one, this appendix shows all the icons and their associated file names.

Appendix D: Batch File Icons. The batch files that come with this book have their own icons. Each icon has the same name as the batch file, only with an .ICO extension. This appendix shows all the batch file icons and their associated file names.

Appendix E: Utility Icons. The utilities that come with this book have their own icons. Each icon has the same name as the utility, only with an .ICO extension. This appendix shows all the batch file icons and their associated file names.

 

 

© 2002 by Ronny Richardson, All Rights Reserved