View Single Post
  #12   Spotlight this post!  
Unread 22-01-2008, 23:41
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: A New Programmer

Examples of toggle functions are common on the Chief Delphi forums. Here's another:
Code:
  :
  :
  static char prev_trig = 0;
  static char toggle = 0;
  :
  if (p1_trig && !prev_trig)
  {
    toggle = !toggle;
  }
  prev_trig = p1_trig;
  :
This will switch toggle from 0 to 1, or vice versa, each time the port 1 joystick trigger is depressed. You can test its value to decide what to do next.