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
Use "&&" for "and"
Use "||" for "or"
More info can be found in the Help File under "Operators".
Jim
Thanks. I had looked in the Help file and rummaged through various examples from other perople and must have missed theses. Thanks again.
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.
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...
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.
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.
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.
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.