Definitions of terms used in my batch file essays

bar
The second standard metasyntatic variable.
Batch
A batch program is a file containing command line type commands (with extensions) in a form that can be interpreted by the command processor as if someone had typed them in manually. Batch programs were originally intended to consolidate commands for a sequence of programs and their setups into one file.
baz
The third standard metasyntatic variable.
CALL
a form of invocation in which the called program eventually returns to the calling program. All invocations of executable programs from batch files are structurally calls. Compare Jump
Command
A command is whatever you would have to type at the C:> prompt to get the system to do something besides come back with "Bad command or filename". A command in a batch file is anything that works from the command line plus a few addition possibilities discussed under "COMMAND.COM" and "External Commands" (and some others I haven't written about). Commands never exceed one line: the Enter key (from the keyboard) or the end-of-line (or end-of-file) marker in a batch file terminates the command and is required to terminate it and cause its execution.
Command Processor
The command processor is the program that interprets your commands given at the command prompt (the infamous C:> prompt) and in batch files. It also provides some services to executable programs, and, importantly, implements a number of the basic commands itself - commands such as COPY, RN, DEL, DIR, etc., but not those that have same named files in the /DOS directory. Normally, COMMAND.COM is the command processor used under DOS, but there are alternatives.
Environment
The environment is a block of memory associated with the command processor or an executable that contains a list of named strings. These user defined strings are used to provide information to programs about the world it lives in, such as where to look for various files, default switch settings, etc.; to define various options to programs or to the command processor, such as the description of the prompt. For batch files, its most important use is as various types of memory, such as scratch pad memory, and the equivalents of RAM, registers, stack, etc.
Executable
a program that exists in the form of machine level instructions and is started through the DOS program loader. Batch files are scripts, not executables.
foo
The first standard metasyntatic variable.
Invoke, Invocation
the process by which some code or program is caused to begin executing, as by a command at the command prompt or in a batch file (a jump, if the target is a batch file, but a call if it is an executable), or a CALL instruction in a batch file (all calls return to the following instruction, whether they are to batch files or programs).
Jump
a. A form of invocation in which the invoked batch file does not return to the one that invoked it when it terminates.
b. Any instruction that transfers program flow to some other code in such a way that the new code does not return to the following instruction. It is not possible to jump to an executable, except (simulated) from the last line in the batch file.
Metasyntatic variable
A metasyntatic variable is a string that stands for or represents any syntactically appropriate string, number, or other variable. Unlike normal syntactic variables, a metasyntatic variable stands for a value of any acceptable type, for example, foo in
 dir foo
represents filenames, directory names, and partial or complete, absolute or relative paths - a normal variable would represent only one or a few of those types.
NUL, NUL device, null device
Basically, the bit bucket - A dummy device that exists in every directory and simply discards any data sent to it, or returns EOF (end of file) when read. For most purposes, NUL can be treated like a file, except that it never has anything in it - it can usually be used as the filename argument to a program that won't start without one, but which you only need to open to get access to the help feature or something else that doesn't involve actually doing anything with the given file. It is frequently used with word processors to allow printing what you type, when you know it is a one-time job which need not be saved, but the word processor insists on having a file name before it will let you type anything. - also known as \dev\nul (from /dev/null in UNIX).
Pipe
a connection from the output of one program to the input of another. Usually thought of as (and actually implemented in MSDOS) as redirection.
program
A set of instructions to a computer to turn user input into error messages. Any complete set of related instructions to a computer at any level of abstraction.
Recursive, Recursion - see Recursive, Recursion.
Recursive programs and functions invoke or call themselves as subprograms or as functions.
Normally, these terms would be applied to functions that call themselves with the results of the current instance as the argument to the new instance, but here they are used to refer to batch files that call themselves in any form, with any arguments. Compare "reentrant".
Redirection
The process by which the input to a program is taken from a file or device instead of the default device (the console), and/or the output from a program is written to a file or device other than the default device (the console). Not all executables implement their inputs and/or outputs in a way that allows redirection, and some that do, do so in a way that is not DOS compatible (some of the DOS external commands are like that). In general, only text mode programs can allow redirection. COMMAND.COM is a text mode executable, and its internal commands write their normal output to the console. Anywhere you see
>, >>, <, or |
you are looking at redirection - the first of those redirects to a newly created or truncated file, the second appends to a file, the third reads from a file, and the fourth (a pipe) connects the output of one program to the input of the next.
foo > nul
redirects the output of foo - a program or command - to the null device to suppress display of normal, but not error messages. Redirection applies only to the command that precedes it on the same line. Pipes apply only to the two commands or programs which they separate.
Re-entrant
Normally used to indicate that a function can be interrupted by a new call, and can successfully cope with recovering the original process when it has completed servicing the interruption. Here, it is used to refer to a batch file that is entered one or more times after it has been invoked, usually by jumps from other batch files that it invoked. Reentrancy differs from recursion in that the reentry does not automatically return to the calling batch file. Reentrancy is sometimes used from within the same batch file, as to restart with a specified environment size or to split an environment string into fields.
Return
the process by which code that has been called as a function or subprogram causes executation to resume with the instruction following the calling instruction when the called code terminates. In most languages, this behaviour is controlled by an instruction at the end of the code in question, but in batch files, this is determined entirely by the method used to invoke the code (a call returns; a jump doesn't).
Script
a file containing a series of program instructions that are interpreted by an executable program. Batch files are scripts.
Symbols
== is the string equality operator, there are no "less than" or "greater than" operators because batch language doesn't have the concept of number.
< is the input redirection operator.
> and >> are the output redirection operators - >> appends to the existing file; > creates a new file.
| is the pipe operator.
[ and ] have no intrinsic meaning, but are used in HELP, and in command line examples in general, to indicate optional elements. For example: FOO [/a] [/b[:][x][y][z]] means that the FOO command can have, but does not require, a "/a" switch or a "/b" switch, and that if the "/b" switch is used, it must be followed by either an 'x', a 'y', or a 'z', with or without an intervening colon.
* and ? are wild cards - in filenames they stand for any characters: '*' stands for one or more of anything, and '?' stands for exactly one of anything.
Wild cards
The term is borrowed from card games - one or more designated cards can be used in place of any other card. Similarly, wild cards can be used in file names used as arguments to many commands to stand for one or more other characters, but cannot be used in real filenames themselves. In DOS, there are only two: '?' which stands for any single character, and '*', which stands for one or more characters of any kind, even those that aren't on the keyboard and shouldn't appear in file names (but sometimes do). In DOS, '?' can appear anywhere in a filename pattern, but '*' can appear only at the end of (or in place of) the name or extension: *.txt matches all files with the .txt extension, *.t?? matches all files having three latter extensions that begin with 'T'. In addition to the formal wild cards, '.' often is translated a "*.*", that is, as all the files in the default directory, and ".." as all the files in the parent directory. These symbols are most commonly used to refer to the directory in relative directory references (CD ..\foo changes the default directory to the foo directory in the parent of the default directory). In some versions of DOS (COMMAND.COM actually), DIR ... will list all the files, including the hidden ones in the defualt directory, in other cases it will list just the subdirectories without name extentions but DIR, lists the files - not reliable or recommended.
  ** Copyright 1995, 1996, 1997, 1998 Ted Davis - all rights reserved ** 

Input and feedback from readers are welcome. NOTE: the subject of the message must contain the word "batch" for the message to get past the spam filter.

Back to the Table of Contents page

Back to my personal links page - back to my home page