How do you do boolean "and" or "or" tests?

Started by geauga, July 16, 2015, 10:54:45 AM

Previous topic - Next topic

geauga

I need to evaluate two different variables using ââ,¬Å"andââ,¬Â or ââ,¬Å"orââ,¬Â logic and I cannot seem to come up with the correct "If" statement syntax.  Does anybody have suggestions   for the following two statements?

If a == ââ,¬Å"5ââ,¬Â and b == ââ,¬Âfredââ,¬Â then goto label 
If a == ââ,¬Å"5ââ,¬Â or b == ââ,¬Âfredââ,¬Â then goto label 

JTaylor

Use "&&" for "and"

Use "||" for "or"

More info can be found in the Help File under "Operators".

Jim

geauga

Thanks.  I had looked in the Help file and rummaged through various examples from other perople and must have missed theses.  Thanks again.

snowsnowsnow

Do be aware, though, that WinBatch's && and || operators do not work the same way as the identically spelled operators do in C and all other (to the best of my knowledge) C-derived languages (e.g., C++, AWK, Perl, etc).

So, if you are familiar with any of those other languages, finding out how it works in WinBatch can be something of a shock.

td

Quote from: geauga on July 16, 2015, 12:57:22 PM
Thanks.  I had looked in the Help file and rummaged through various examples from other perople and must have missed theses.  Thanks again.

If you open the Consolidated WIL Help file and click on the 'Contenst' tab you can find the language operator documentation by clicking on Windows Interface Language Reference -> Things to Know -> Operators. 

And don't let snow++ scare you. WIL operators aren't all that difficult for even geriatric programmers... 


"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

How old do you have to be to qualify as a "geriatric programmer" ?

Note, BTW, that the difference is that WIL's implementation of && and || is simpler than in C (so probably easier for geriatric programmers to understand...).

I've always wondered why they didn't go the extra mile to make it work like it does in C.

td

Quote from: snowsnowsnow on July 17, 2015, 01:48:25 PM
How old do you have to be to qualify as a "geriatric programmer" ?

I don't know. Maybe if you're fluent in two or three of the following: Cobol, C, Simula 67, Common LISP, Smalltalk-80, or Fortran 77?

Quote
Note, BTW, that the difference is that WIL's implementation of && and || is simpler than in C (so probably easier for geriatric programmers to understand...).

I suspect ease depends to some degree on your previous programing and scripting experience.

Quote
I've always wondered why they didn't go the extra mile to make it work like it does in C.

Because it's much farther than a mile.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

QuoteBecause it's much farther than a mile.

Interesting.  I'm guessing that the way WIL is setup, everything gets eval'd before anything gets executed, and it would be more than a bit difficult to change that.

DAG_P6

Also be aware that A | B is not the same as A || B.
The same holds for A & B is not the same as A && B.

Also, when in doubt, parenthesize.
David A. Gray
You are more important than any technology.