Well, technically this shouldn't work in Operator Control or Autonomous. But Operator Control loops due to the way WPILIB is written. But, both you Autonomous and Operator Control should have a while() loop. Here is how it should look.
Code:
void Autonomous ( void )
{
unsigned char IR1;
while ( 1 )
{
ir1 = GetDigitalInput ( 1 ) ;
if ( ir1 == 1 )
{
SetRelay ( 2 , 1 , -1 ) ;
Wait ( 10 ) ;
SetRelay ( 2 , 0 , -1 ) ;
}
}
}