Batch processing is an effective way to automate repetitive tasks. All of the main display and processing functions can be saved in a batch file to be used later. The batch file is written in ASCII text format, and can be easily edited. Variables, if-then statements, for-next loops, and goto-label jumps can be used in a batch file.
To create a batch file, select Batch Record from the menu. You will be asked to give a filename to the batch file. After this, each WinDisp3.5 command that you execute will be saved to the batch file. When you are finished recording, select Batch Stop in the menu.
These commands can now be executed again by selecting Batch Play and specifying the name of the file.
To see what the batch file looks like, and to make changes to it, use Batch Edit.
|
If you want to execute the commands one at a time, use Batch Debug; with this option you can also change parameters in each step before executing them. See the example at the left. |
The basic format for a command in a batch file is:
Function, "Parameters"
where Function is the menu command and "Parameters" are the parameters associated with this command. The "Parameters" are listed, separated by commas, in the same order as in the dialog box corresponding to the menu command.
For example, a command to display an image might look like this:
File Open Image, " c:\ccd_af\1997\Dc97073.af,,c:\data\projects\c.clr, 88,174,341,401"
It is important to note:
Repetitive tasks can be simplified by using variables in a batch file. For
example, dekad images (every 10 days) can be given file names similar to the
one shown on the previous page (dc97073.af), substituting variables for the
month and dekad. The month and dekad will be stored as variables and used to
specify the correct file name.
The user will then be prompted to enter the number of the month and dekad for
the image desired. The responses will be read into the batch file to identify
the image to display.
The dialog would look like this:
Batch Variable Prompt, "Month, Enter month desired, 7"
Batch Variable Prompt, "Dekad, Enter dekad desired, 3"
File Open Image, "c:\ccd_af\1997\Dc97%Month%%Dekad%.af,,c:\data\projects\c.clr,
0,0,0,0"
After replacing the variables by the values attributed to them, (%Month% by 07 and %Dekad% by 3), the command line becomes:
File Open Image, "c:\ccd_af\1997\Dc97073.af,,c:\data\projects\c.clr, 0,0,0,0"
The open file can now be used to display the desired image.
It is important to note:
With the command Batch If, an if-then statement can be used in a batch file as an error check, and allows the user to validate values for the variables. In programming procedures the commands of an if-then statement are indented to improve the readability.
Batch If Begin, "(%Dekad% > = 1) & (%Dekad% < = 3)"
File Open Image, " c:\ccd_af\1997\Dc97%Month%%Dekad%.af,,c:\data\projects\c.clr, 0,0,0,0"
Batch If Else
File Open Image, "c:\ccd_af\1997\default.img,,c:\data\projects\c.clr, 0, 0, 0, 0"
Batch If End
The example above is an if-then clause delimited by the commands Batch If
Begin and Batch If End. Here the variable %Dekad% is used to select
the image that will be loaded. The first line checks that the value attributed
to this variable is between 1 and 3. If the value is valid, the following line
is executed by WinDisp3.5, and Batch If Else is not executed. If the
value is not valid, the Batch If Else is executed.
This statement can be useful in automatically adapting names of variables when an error is detected as in section 2.6.3. For example, if the variable %Month% must contain two digits to be valid, but the user enters only one digit (1 to 9 for the months January to September), the if-then statement will place a 0 before the digit to correct the entry:
Batch If Begin, "%Month%<10"
Batch Variable Set, "MonthOK, 0%Month%"
Batch If Else, ""
Batch Variable Set, "MonthOK, %Month%"
Batch If End, ""
After this evaluation, the variable %Month% is replaced by the variable %MonthOK% in the batch file and program processing.
With the help of if-then statements, expressions to evaluate variables can be written in a batch file. Some of the frequently used symbols are used in the following example:
Batch If Begin,"((%Dekad1%=1) &
(Dekad2%=3)) | (%Month1%=%Month2%)"
...
Batch If End
Batch processing permits the execution of the command only if the variables %Dekad1% and %Dekad2% are equal to 1 and 3 respectively, or if the variable %Month1% is equal to the variable %Month2%. You will find a list of the symbols used in expressions of this type in section 2.6.8.
It is important to note:
To repeat the same command for a series of files (for example, the same type of image for different dates) the for-next loop can be adapted. The example below shows how a for-next loop is used to display images of three consecutive dekads:
Batch For Begin, "Dekad, 1, 3, 1"
File Open Image, " c:\ccd_af\1997\Dc97%Month%%Dekad%.af,,c:\data\projects\c.clr,
0,0,0,0"
Batch For End
The part "Dekad, 1, 3, 1" signifies that the loop is repeated from the value of 1 to the value of 3, increasing successively by 1, and that these values are assigned to the variable %Dekad%. This variable is then used in the command to display the image.
Note that in for-next loops the value of the increment (the last parameter in the Batch For Begin line), can be negative, allowing you to have a command like the following:
Batch For Begin, "Dekad, 3, 1, -1"
....
Batch For End
This loop will load successively the dekad images from 3 to 1. The command executes the loops diminishing the value of the variable.
WinDisp3.5 can execute loops placed within loops as well as within if-then
statements.
For example:
Batch For Begin, "LoopOut, 1, 5, 1"
Batch For Begin, "LoopIn, 1, 10, 1"
....
Batch For End
Batch For End
In this example LoopIn is included in LoopOut. As in the previous examples, indenting these commands improve the legibility.
In certain cases, you will want to go from one location to another within a
batch. A simple example would be if you ask the user if he wants to repeat the
batch and display another image. The batch would resemble the following:
Batch Goto Name, "Loop_begin"
....
....
Batch Variable Set, "Repeat to display another image? (y/n), n"
Batch If Begin, ""%Repeat%" = "y""
Batch Label Goto, "Loop_Begin"
Batch If End
WinDisp3.5 is capable of calling up one batch from another. Simply save a Batch Play command within a batch, and this batch will execute the other. For example, the following batch executes Mybatch.cmd, then requires the user to rerun the batch a second time:
Batch Label Define "Call_Start"
Batch Play "mybatch.cmd"
Batch Variable Prompt, "UserInput, Run mybatch again?, n"
Batch If Begin ""%UserInput%"="y"
Batch Label Goto, "Call_Start"
Batch If End
It is important to note:
Parentheses must delimit each expression.
| = | Equal to |
| >= | Greater than or equal to |
| <= | Less than or equal to |
| > | Greater than |
| < | Less than |
| <> | Not equal to |
| & | And |
| | | Or |