I have a script situation where it make more sense to work backward from a higher number to a lower number in a SC while loop since the tab number I'm looking for will probably always be a the high end of the list. The script works fine incrementing from the low end (ie., tab #1 'til it found it's tab name match which was usually tab #18 - the last tab added). The script section looked like this...incrementing...
Code: Select all
$t = tab("get", "count");
$tabToCloseCaption = "$drivename";
while ($i++ <= $t) {
$tabCaption = tab("get", "caption", $i);
if ($tabCaption == $tabToCloseCaption) {
tab("close", 0, $i); end(1==1);
}
}
To work from the last tab downward, I know I can do this here and it also works...
Code: Select all
$i = tab("get", "count");
$tabToCloseCaption = "$drivename";
while ($i > 0) {
$tabCaption = tab("get", "caption", $i);
if ($tabCaption == $tabToCloseCaption) {
tab("close", 0, $i); end(1==1);
}
$i--;
}
But is there any way to use "$i--" or similar directly in the while loop as in the first example without using the separate line at the bottom of the while loop to decrement? In other words, when incrementing in the first example, it starts with value "1" and works up the the last tab. When decrementing using "$i--", it will immediately subtract 1 so the first tab number is 1 minus the total of 18 which is 17. I read the help but I'm not sure if there's a way around not having the separate line to do the decrementing for this situation. The help under increment states, "Note that before v14.30.0100 the value was incremented/decremented before it was passed to the function!" But, isn't that what is happening here, at least for decrementing?
Thanks,
Ken