Guide

The Principles of Batch Process Program Development: ELSE Statements

Learn how to develop, test, debug, and implement batch process programs on your home computer with The Principles of Batch Process Program Development series. Along with this, the principles of wavemaker rad tool are stated in the article. The reading of the information will provide enormous benefits in the development of platform of the organization. 

ELSE statements are essentially the inverse of the IF statement. What they generally do is instruct the computer to perform a command if no other option is available. In other words (and I do suggest reading the lesson on IF statements to better understand this) , setting up an IF statement that asks the computer to compare the variable x to the number one would yield a desirable command if the two were to match, however, if they were not to, instead of programming an infinite amount of possible commands, one could just build an ELSE statement. It has come to my attention that the ELSE statement is extremely similar to the IF NOT statement, please do note that they are in fact NOT entirely the same. The IF NOT statement is an exclusive expression, demonstrating concepts like ;

IF x does not = HAM, then say, “HELLO!”

Whereas ELSE statements are inclusive, demonstrating concepts like;

IF x = HAM , say, “Hello!”. Otherwise, say “Too bad!”

Understanding this concept is key (though I do realize the extreme similarities). Let’s examine the first statement. This statement expresses to a user that the variable MUST meet the requirement of x equaling HAM, however, expression two takes a more passive approach stating that x does not have to equal HAM. This will become important when building arrays (which we’ll go over in future lessons).

To properly implement an ELSE statement will be key to the function of your program. Let’s examine the several ways in which we can do this.

First of all, understand that each build of Window’s is completely different from one another (so the latter of the two examples will be more helpful), and there is no truly universal way to go about ELSE statements, but we’ll give it an old fashioned try. Take a look at the example below:

IF %var%==1 ECHO “The two terms match” ELSE ECHO “The two terms DO NOT match”

Note that if that variable var were to meet the condition of the shell, that the shell would ECHO “The two terms match” and if not; it would have echo’ed “The two terms do not match”. This way will do the trick, but has been known to fail within some builds and versions of Windows 98 and XP. When it fails, the display will look something like this:

“The two terms match” ELSE ECHO “The two terms DO NOT match”

This is obviously not the desired effect, and putting this into a build of a universal Windows application may be a bad idea. Boy, it’s a good thing that there is a more reliable way.

In the next example, we will make use of the parenthesis (which is seldom used in batch process programming). The parentheses will help the shell organize command lines (and thoughts). Below, we will demonstrate how to further universalize this process by using the template from above.

IF %var%==1 (ECHO “The two terms match”) ELSE (ECHO “The two terms DO NOT match”)

Notice that all subsequent commands are placed within parentheses following their conditional counterpart. This greatly helps the shell organize what would otherwise be a muddled collection of commands. This, in fact, is the way that a great deal of other languages utilize their IF and ELSE statements as well. Cool, huh?

Mastering the ELSE statement may help document your transition into programming manhood. This is serious stuff, and serious stuff can be brought on by it. There is literally NO limit to what one can do with the IF / ELSE tandem, and knowing that should make you feel good. Another thing that you may be able to do to help you out with all of this is to take a few logic classes. In may seem illogical to take logic classes for programming, but they will help in deciphering and organizing chaotic, hierarchical systems much like these (if you don’t watch out).

Paola

Paola Garcia lives in Jakarta Indonesia. She is an associate professor in University of Indonesia and also managing Scoopinion at the same time. She is also fond of watching theatrical plays.

Related Articles

Back to top button
Close
Close

Notice: ob_end_flush(): failed to send buffer of zlib output compression (0) in /home/scoopini/public_html/wp-includes/functions.php on line 3783

Notice: ob_end_flush(): failed to send buffer of zlib output compression (0) in /home/scoopini/public_html/wp-content/plugins/really-simple-ssl/class-mixed-content-fixer.php on line 111