ROBOTC.net forums
http://www.robotc.net/forums/

RobotC Programming
http://www.robotc.net/forums/viewtopic.php?f=32&t=10170
Page 2 of 2

Author:  kewlguy535 [ Thu Jan 08, 2015 3:20 pm ]
Post subject:  Re: RobotC Programming

**Error**:Executable statements not valid in 'main' declaration block
**Error**:Executable statements not valid in 'main' declaration block

in lines 61 and 68

Author:  MHTS [ Thu Jan 08, 2015 3:40 pm ]
Post subject:  Re: RobotC Programming

This is how your latest code looked when doing a "whole file format". You can see how the braces not matching up. Unfortunately, not knowing what you intended to do, it is hard for us to try fixing it. Please look at it and put braces in the correct places.
Code:
#pragma config(Sensor, in1, Sensor1, sensorReflection)
#pragma config(Sensor, in2, Sensor2, sensorReflection)
#pragma config(Sensor, in3, Sensor3, sensorReflection)
#pragma config(Sensor, in4, Sensor4, sensorLineFollower)
#pragma config(Sensor, in5, Sensor5, sensorReflection)
#pragma config(Sensor, in6, Sensor6, sensorReflection)
#pragma config(Sensor, in7, Sensor7, sensorReflection)
#pragma config(Sensor, in8, Sensor8, sensorReflection)
#pragma config(Sensor, dgtl1, BuzzeLight, sensorDigitalOut)
#pragma config(Motor, port1, Flashlight1, tmotorVexFlashlight, openLoop, reversed)
#pragma config(Motor, port2, buzz1, tmotorVexFlashlight, openLoop, reversed)
#pragma config(Motor, port8, Flashlight2, tmotorVexFlashlight, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

/*
Project Title: Smart Goal
Team Members: Jordon Hayes, Bryce Menzer, Katie Otsuka, Calvin Nguyen
Date: December 19, 2014
Section:


Task Description: Create a goal control system that will light up when a goal is made. Must differentiate between
human and ball.


Pseudocode:

*/

task main()
{
    turnFlashlightOff(Flashlight1);
    turnFlashlightOn(Flashlight1, 127);
    turnFlashlightOn(Flashlight2, 127);

    wait(1);

    while (1 == 1) //

    if(SensorValue[Sensor2] >= 120)

    waitInMilliseconds(5);

    clearTimer(T1);
}
if(SensorValue[Sensor1] <= 120 && SensorValue[Sensor2] <= 120 && time1(T1) <=5)
{
    waitInMilliseconds(5);
    turnFlashlightOn(buzz1, 127);
    wait(10);
    turnFlashlightOff(buzz1);
}

else

if(SensorValue[Sensor1] >= 120)
{
    waitInMilliseconds(5);

    clearTimer(T1);
}
if(SensorValue[Sensor1] <= 120 && SensorValue[Sensor2] <= 120 && time1(T1) <=5)
{
    waitInMilliseconds(5);
    turnFlashlightOn(buzz1, 127);
    wait(10);
    turnFlashlightOff(buzz1);
}

Author:  MHTS [ Thu Jan 08, 2015 3:48 pm ]
Post subject:  Re: RobotC Programming

This is one way to fix it but I am not sure it's correct without knowing your intention.
Code:
task main()
{
    turnFlashlightOff(Flashlight1);
    turnFlashlightOn(Flashlight1, 127);
    turnFlashlightOn(Flashlight2, 127);
    wait(1);
    while (1 == 1)
    {
        if(SensorValue[Sensor2] >= 120)
        {
            waitInMilliseconds(5);
            clearTimer(T1);
        }
        if(SensorValue[Sensor1] <= 120 && SensorValue[Sensor2] <= 120 && time1(T1) <=5)
        {
            waitInMilliseconds(5);
            turnFlashlightOn(buzz1, 127);
            wait(10);
            turnFlashlightOff(buzz1);
        }
        else if(SensorValue[Sensor1] >= 120)
        {
            waitInMilliseconds(5);
            clearTimer(T1);
        }
        if(SensorValue[Sensor1] <= 120 && SensorValue[Sensor2] <= 120 && time1(T1) <=5)
        {
            waitInMilliseconds(5);
            turnFlashlightOn(buzz1, 127);
            wait(10);
            turnFlashlightOff(buzz1);
        }
    }
}

Page 2 of 2 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/