How to? Shortcut evaluation

Jun 24, 2008
Siegen, Germany
Is there any way to achieve shortcut evaluation of logical expressions?

E.g. iff not isfile abc .or. %@fileage[abc] gt 12345 then...

runs into an error if file "abc" doesn't exist.
May 20, 2008
Elkridge, MD, USA
Is there any way to achieve shortcut evaluation of logical expressions?

E.g. iff not isfile abc .or. %@filesize[abc] gt 12345 then...

runs into an error if file "abc" doesn't exist.
I presume what you mean is to evaluate a logical expression left-to-right, and STOP when the result is known? AFAIK that would require a major redesign of the parser.
May 20, 2008
Elkridge, MD, USA
Not really feasible unless I remove support for the boolean operations, as the parser can't tell whether you might reverse the condition somewhere later in the evaluation.
Excluding the .XOR. operator, wouldn't reversing the result of a test already performed require that it be within parentheses? But I see the other major parsing issue: IIRC variable expansion is performed before anything else, thus in the OP's example the attempt to evaluate %@fileage[abc] would fail before the "isfile abc" test is performed.

When I come across a compound test such as in the OP, where the result of one of the tests determines whether or not a second test can be validly performed, I use nested IF/IFF tests; and I may need to perform Boolean manipulations to get them in the proper order. Auxiliary variables may be need, too.

unset x
if isfile abc if not %@filesize[abc] GT 12345 set x=no
iff not defined x then ...

It is more complicated than in some other programming languages, but it's all that can be done...
May 31, 2008
not exactly what the OP asked for, but here's another idea, using do/leave as a glorified goto
do 1
  if %a == %b .and. %c == %d leave
  if %e != 32 .or. %f == A leave
  iff %something% then
Similar threads
Thread starter Title Forum Replies Date
vefatica Literal double quotes in SHORTCUT's "args" parameter? Support 6
D The SHORTCUT command again,.. Support 16
C How to bypass UAC warning when shortcut in \Startup folder ? Support 9
D [cosmetic] Shortcut for v24 still has v23 in its comment Support 1
vefatica New Shortcut Key box Support 1
M TCC Taskbar Shortcut Breaks Support 1
C How to? SHORTCUT question..... Support 6
R Shortcut key assignments - default Support 0
vefatica Shortcut/start-up folder nonsense Support 20
samintz How to? Use tilde shortcut Support 3
vefatica Keeping taskbar-pinned shortcut? Support 6
G How to? Trying to create TCC shortcut that opens with blue background (on Windows 8.1 x64) Support 1
vefatica Update removes pinned shortcut? Support 17
noahcoad How to? Create shortcut with env var in path Support 4
vefatica Must update remove my taskbar-pinned shortcut? Support 20
vefatica Update removes taskbar-pinned shortcut Support 7
A Limitation regarding creation of shortcut keys for "copy" Support 0
vefatica SHORTCUT behavior (Win7) Support 3
C starting a shortcut from desktop Support 14
N Shortcut stops working after 4NT to TCC Upgrade Support 73
S SHORTCUT command question Support 1
S Desktop Shortcut Hotkey question Support 1
S SHORTCUT command failure Support 1
S Desktop hotkey creation using SHORTCUT command Support 4
D Always get shortcut in Start Menu folder Support 6
S OT: WinXP shortcut vs. junctions Support 2
M "Shortcut key" on Windows start menu shortcuts Support 5
E Bug in shortcut command Support 2
fpefpe How to? issue with % and evaluation Support 5
WadeHatler Fixed Breaking change in Expression evaluation (.and.) in v17 Support 6
mfarah How to? Lazy evaluation on %@if[]? Support 4
A WAD function return values with parentheses prevent evaluation of additional functions Support 31
nikbackm Command line evaluation question - variable inside parenthesis Support 7
vefatica Order of evaluation? Support 3

Similar threads