1.

Solve : Sample of an If statement, comparing two variables . . .?

Answer»

I'm used to using the PL SQL if-then-else CONCEPT, so this is really frustrating me.  I've found some examples, but evidently I'm doing something wrong, because when I add my if statement to the code, the file just bombs out and can't even capture what the error is.  Anyway, can someone show me a good example of an If statement, comparing two variables?

THANK you.
Jeanette Code: [Select]if %var1%==%var2% (
  echo Match
) else (
  echo No match
)
Use this when comparing two string variables to see if they match (Note: That is two equal signs.) As far as the structure goes, the "THEN" in what you are used to is implied after the logic test, making it a simple IF-ELSE structure, or even just an IF statement if nothing needs to happen if the logic test returns a "no" value. As I learned earlier today, watch out for quotation marks within the strings, as if there is only one, it can cause the IF construct to not WORK.

If you are comparing numerical values, you can use different compare operations such as equ, neq, gtr, lss, geq, leq; equal, not equal, greater than, less than, greater than or equal to, less than or equal to; respectively. Also, be sure that your parenthesis (if used) are correctly placed. The open parenthesis must start on the same line as either the IF or the ELSE commands, and the ELSE must be on the same line as the close parenthesis from the IF statement.Raven  .  .  .  thank you very much.  I will TRY that.  All the samples I found didn't use the 'else'.  Good to know that I can.

Thanks again.



Discussion

No Comment Found