View unanswered posts | View active topics It is currently Thu Oct 30, 2014 11:53 am






Reply to topic  [ 3 posts ] 
Program Loop not working 
Author Message
Rookie

Joined: Tue Jan 20, 2009 9:39 pm
Posts: 1
Post Program Loop not working
Simple problem, when my program is running, it says
it's not running. The program is supposed to break out of the loop
once you use the stop autonomous in the simulator.

Heres the code

EDIT: This should be simpler to understand, here in lies the problem

Code:
#include "Joystickdriver.c"

task main(){
  bool go=false;
  while(!go){
    getJoystickSettings(joystick);
    go=joystick.StopPgm;
    wait1Msec(50);
   }
}


Heres another way of it not working

Code:
#include "Joystickdriver.c"

task main(){
  bool go=false;
  while(1){
    getJoystickSettings(joystick);
    go=joystick.StopPgm;
    if(go)break;
    wait1Msec(50);
   }
}


For the Go loop to work the value has to return false.

A little help? :?


Last edited by Komodo on Wed Jan 21, 2009 7:16 am, edited 2 times in total.



Tue Jan 20, 2009 9:42 pm
Profile
Novice

Joined: Thu Oct 09, 2008 7:58 pm
Posts: 79
Post Re: Program Loop not working
Well. A few things.

1. If that is a forever loop, just use while(true). It would seem to me that you trying to write an autonomous code or something??? I don't know,

What is this code for? Teleop or autonomous?

2. Next time you post your code, please use whitespace and proper structure. It is extremely difficult to read the code and figure out what you are doing.


Tue Jan 20, 2009 10:00 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 613
Post Re: Program Loop not working
Use the templates at www.ftctraining.com ... it looks like you're trying to do code to wait for the enable signal from the FMS... this has already been done for you.

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Fri Jan 23, 2009 12:30 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.