View unanswered posts | View active topics It is currently Fri Sep 25, 2020 12:45 am

Reply to topic  [ 2 posts ] 
Question about Void functions 
Author Message

Joined: Thu Jan 30, 2014 9:28 am
Posts: 8
Post Question about Void functions
I wanted to know how robot c tells whether or not to multitask a void function. For example, if a void function is:
void StopFor1Second()
  motor[leftServo] = 0;
  motor[rightServo] = 0;

It would only run through once, but what if it had a while statement that wasn't true. Like while a variable does not equal zero, would it multitask or does the while statement have to be while(true)? Is there any type of function that I could use that would run the function until it was finished before moving on to the next command?

Tue Apr 15, 2014 8:18 am
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: Question about Void functions
Multitasking is a bit different than running through a function multiple times. When you execute a function, the program will run through all of the code in between the function's curly braces {} and, once the function is complete, return to where the function is called from. The 'void' data type means that the function doesn't return any data back to where the function was called from.

In this case, you may want to take a look through the 'Behaviors and Functions' of the VEX Cortex Video Trainer using ROBOTC (under the Sensing -> Behaviors and Functions section), as it walks through how to create and use functions in ROBOTC.

Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.

Mon Apr 21, 2014 1:10 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.