Code archives/Algorithms/k.i.s.s. toggle

This code has been declared by its author to be Public Domain code.

Download source code

k.i.s.s. toggle by Russell
(Posted 26 years ago)
Probably the absolute easiest way to toggle between two numbers.
;Toggle between 0 and 1:
a = 0
Repeat
  Print a
  a = 1 - a ; <- The clever part!
Forever

; Learned this from waaaaaaaay back in the
; Commodore 64 days... <big sigh>

Comments

aCiD2
(Posted 23 years ago)
its even easier to jsut do a = not a :)

Cygnus
(Posted 23 years ago)
Haa, but "a=not a" only works with the value 1.

a=64-a toggles between 0 and 64

@rtur
(Posted 23 years ago)
A little faster method:

a = a xor 1

Inner
(Posted 23 years ago)
@rtur: please remove that thing in your sig which displays IP my ISP and my operating system + which version of IE.

Nilium
(Posted 23 years ago)
Yeah, @rtur. It goes over the recommended forum signature size: 80 pixels or 5 lines, if I recall correctly.

Inner
(Posted 23 years ago)
not to mention an invasion of my privacy, who knows what else that thing is doing.

Dreamora
(Posted 23 years ago)
It is only analyzing the the data your browser is sending. that's what every page statistic knows as well.

TomToad
(Posted 23 years ago)
Wouldn't it be faster to do

Repeat
Print 0
Print 1
Forever

Nilium
(Posted 23 years ago)
TomToad: ... You missed the whole point I'm guessing.

@rtur
(Posted 23 years ago)
2 Inner
It show all info only to u...no one else know your ip,isp etc...;-)

Warren
(Posted 23 years ago)
Could you still remove it, please? It's huge and annoying.

Cygnus
(Posted 23 years ago)
...i like it. but i suppose if its anoying people, best to stay in the good books.

puki
(Posted 23 years ago)
"@rtur" doesn't appear to be doing it himself - looks like he is accessing the info via a 3rd party and relaying it in - I don't think it is malicious, but I would be a bit concerned that the data is being collated by a 3rd party website that he has nothing to do with.

Inner
(Posted 23 years ago)
@rtur: I don't care, if it's telling me my entire life history, remove it please.

Rook Zimbabwe
(Posted 23 years ago)
3rd party can also grab email from outlook (and a few other mailbox programs as well now...) create SPAM for all... BAD @rtur... BAD... PLease remove it!
oh and:
musicflag=1
annoy=LoadSound("anoy1.ogg")
LoopSound annoy
Global play_annoy=PlaySound(annoy)

while not keyhit(1)

If KeyHit(50)>=1 Then musicflag=1-musicflag

If musicflag=1 Then ChannelVolume play_annoy,0.4 Else ChannelVolume play_annoy,0

wend
This is how I use that toggle. Wolron and MAtty both showed me how to do this... it could be modified for any key on the keyboard to control anything... haven't tried it with combos yet! :]

-Rook Zimbabwe

TomToad
(Posted 23 years ago)
Hmm, weird. I tried a benchmark using
musicflag = 1 - musicflag

and
musicflag = not musicflag

and the first version seems to be faster.

Warren
(Posted 23 years ago)
I doubt this is going to be your primary bottleneck, guys.

@rtur
(Posted 23 years ago)
ok ppl, i've removed it...

it was just fun signature..no collecting emails for spam or other bad things...just fun...:-(

Rook Zimbabwe
(Posted 23 years ago)
Thank you @rtur. I appreciate that you listened.

Code Archives Forum