View unanswered posts | View active topics It is currently Mon Sep 01, 2014 5:04 pm






Reply to topic  [ 5 posts ] 
**Error**:Task 'task1' is not defined at global scope level 
Author Message
Rookie

Joined: Sun Jan 13, 2008 6:48 pm
Posts: 5
Post **Error**:Task 'task1' is not defined at global scope level
I'm calling a task from within a do while loop, but I'm getting the following error on the first line of the task which is - task fwd100().

**Error**:Task 'fwd100' is not defined at global scope level

Can anybody tell me what I'm doing wrong?
Thanks


Sun Jan 13, 2008 7:06 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA
Post 
Hi Skyminding,

Can you post your code so we can take a look at it? Thanks! B-)

Scott

_________________
Mmmm Legos B-)

My Robot Projects:
http://www.freewebs.com/robotprojects/


Sun Jan 13, 2008 8:19 pm
Profile WWW
Rookie

Joined: Sun Jan 13, 2008 6:48 pm
Posts: 5
Post 
Hi Scott thanks for the reply, Here's thecode.
Code:
//*!!Start automatically generated configuration code.                           !!*//
const tSensors touchSensor          = (tSensors) S3;   //sensorTouch        //*!!!!*//
//*!!CLICK to edit 'wizard' created sensor & motor configuration.                !!*//




bool bump = false;

task fwd100();
task rev75();

task main()
{
   do
      {
     StartTask(fwd100);
      }
   while (SensorValue[S3] == 0);
      {
      bump=true;
   do
      {
     StartTask(rev75);
      }
   while (bump ==true);
      {

}

task fwd100()
   {
         PlaySound(soundUpwardTones);

        motor[motorA] = -100;
      motor[motorC] = -100;
   }

task rev75()
   {
         PlaySound(soundDownwardTones);

         motor[motorA] = 75;
         motor[motorC] = 75;
         wait1Msec(2000);
   }
}
}


Mon Jan 14, 2008 4:56 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA
Post 
Ahh ok, the problem is you cannot have a task within a task, Tasks are processes that run independently from one another and are defined separately. Void statements also work the same way, they are defined outside of a task.

I moved the brackets and it should work for you now. :-)
Here ya go, hope this helps B-)

Scott


Code:
bool bump = false;

task fwd100();
task rev75();

task main()
{
   do
      {
     StartTask(fwd100);
      }
   while (SensorValue[S3] == 0);
      {
      bump=true;
   do
      {
     StartTask(rev75);
      }
   while (bump ==true);
      {
      }
      }
}


task fwd100()
{
         PlaySound(soundUpwardTones);

        motor[motorA] = -100;
      motor[motorC] = -100;
}

task rev75()
{
         PlaySound(soundDownwardTones);

         motor[motorA] = 75;
         motor[motorC] = 75;
         wait1Msec(2000);
}

_________________
Mmmm Legos B-)

My Robot Projects:
http://www.freewebs.com/robotprojects/


Mon Jan 14, 2008 5:15 pm
Profile WWW
Rookie

Joined: Sun Jan 13, 2008 6:48 pm
Posts: 5
Post 
Thanks Scott, I can see that I've got a lot to learn.


Tue Jan 15, 2008 4:07 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.