03-28-2006, 08:05 AM

Moneo:

Here's another one-liner to turn a switch on and off, in accordance with, and I quote you, "Most programmers consider TRUE as -1, and FALSE as 0."

x = -1 - x

Starting with x = 0, the next time it encounters the above, the new value will be, x = - 1, then, x = 0, then, x = -1, and so on...

In other words, as long as the previous value of x is 0 or -1, the one-liner will toggle the value of x to either -1 or 0, etc.

Here's another one-liner to turn a switch on and off, in accordance with, and I quote you, "Most programmers consider TRUE as -1, and FALSE as 0."

x = -1 - x

Starting with x = 0, the next time it encounters the above, the new value will be, x = - 1, then, x = 0, then, x = -1, and so on...

In other words, as long as the previous value of x is 0 or -1, the one-liner will toggle the value of x to either -1 or 0, etc.

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.