Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
swet_Living With DOS

swet_Living With DOS

Ratings: (0)|Views: 57|Likes:
Published by swet bhushan

More info:

Categories:Types, School Work
Published by: swet bhushan on Feb 21, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Living with DOS:(( Intermediate BATch Tutorial ))by Barry SimonCopyright (c) 1986, Capital PC User Group Inc.This material may be republished only for internal useby other not-for-profit user groups.Additional material copyright (c) 1986, Barry SimonPosted on Compuserve with permission of CPCUG. May not bereproduced without including the above copyright notice.Published in the November 1986 issue of the Capital PC Monitor.IntroductionOne of the tools that most distinguishes the experienced DOS userfrom others is the effective use of BATch files. In this article, Iwill discuss some of the more advanced features of BATch files andtheir commands. I call this tutorial "intermediate" because I havetried to write in a manner accessible to those with only a littleexperience writing BATch files.Simple BATch filesTo begin with, a BATch file is a set of DOS commands which youplace together and which you can issue by just typing the name ofthe batch file. The classic example is the batch file whichchanges to the directory containing Lotus' 123 and then runs 123.The same idea can be carried much further; for example, when I executemy word processor with a batch file, ito loads the proper set of macros in by keyboard macro program;o makes a mark using Kokkennen's MARK/RELEASE package;o loads my thesaurus;o loads the appropriate mouse menu program;o runs the words processor; ando after I am finished with the word processor, clears the macros andruns RELEASE to boot the thesaurus and mouse menu from memory.BATch files must be pure ASCII text files with separate commands
on distinct lines separated by carriage return/line feed pairs.To create your BATch files, you can use EDLIN, a text editor, or anyword processor that produces straight ASCII text files.BATch programs can contain DOS commands, application program commands,or a variety of specialized programming features that are known asBATch commands.BATch Commands and FeaturesParametersYour editor may allow you to specify a text file to use as aparameter on the command line loading it. You would like tospecify the file name as a parameter on the command line calling aBATch file to start your editor and have this file name passed onto the editor when it is loaded. This is quite easy. If youreditor is called EDITOR.EXE and you load it via a BATch filecalled foo.bat, you need only make the line calling the editorsay:editor %1and then call up the BATch file asfoo filenameWhen the BATch processor comes to the %1, it looks for the firstparameter following "foo" and replaces %1 by that parameter, inthis case by filename.To be more precise, DOS parses the command line calling the BATchfile into distinct "words" separated by one of four delimiters:<space> , ; =That is, it looks for strings of allowed characters separated byone or more of these special four. Any of the 256 ASCIIcharacters are allowed in the strings except for these fourdelimiters, the three redirection characters (<,>,|) and the ASCIInul. The first word on the command line is assigned the value %0,the next %1, etc. Normally, %0 is just the name of the BATch filebut since "." is not a delimiter in parsing the line but is adelimiter in ending file names, if you have a BATch file foo.batand type infoo.cpcugisgreatfoo.bat will be run and %0 will have the full 17 character stringassigned to it. Similarly, since DOS knows that file names are nomore than 8 characters, the BATch file 12345678.bat will be run ifyou type in12345678ABCDEFGHIJbut %0 will have an 18 character string. These are admittedlycuriosities but DOS curiosities have a knack of being useful
sometimes. In a real sense, DOS assigns as many parameters asthere are words on the command line, but initially you can onlyaccess the first ten as %0 through %9. Any place that %1 appearsin the BATch file except as %%1, it will be replaced by the firstword after the filename even if that word is the empty word. Anyother time that the symbol % appears in the BATch file DOS willstrip the %-sign away except that %% is replaced by a singlepercent and %%1 becomes %1 so if foo.bat has the single line:echo %%1 has the value %1then typingfoo junkwill issue the message%1 has the value junkThere is no limit on the size of any individual parameter otherthan the overall limitation that the entire DOS command line cancontain no more than a total of 128 characters.To summarize, any time %i (for i=0,1,...,9) occurs in the fileexcept as a %%i, it will be replaced by the ith string in thecommand line.The real limitation of BATch file parameters is that they are notvariables. You cannot manipulate them by parsing them and cannotchange their values.LabelsAs a preparation for discussing BATch file GOTO commands, I needto discuss labels. Any line beginning with the character ":" willbe skipped by the BATch processor when it gets to it. This meansthat you can use such lines as remark lines which will not appearon the screen even if echo is on (in which case lines beginningwith rem do appear). You can also place the redirectioncharacters <,>,| on such a line (but you cannot place suchcharacters on a "rem" line). And % signs are not treatedspecially on such lines.While DOS ignores such lines, the string following the : becomes alabel for the GOTO command which I'll discuss next. The first word orthe first eight characters of the first word become the name of thatlabel. You can also place comments after a label name if you separatethese comments with a space.GOTOThe most significant way in which BATch files go beyond the DOScommand line concerns two logical control structures, the GOTO andthe IF commands. The linegoto <label>

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->