Question about Void functions
Page 1 of 1

Author:  gk20 [ Tue Apr 15, 2014 8:18 am ]
Post subject:  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?

Author:  JohnWatson [ Mon Apr 21, 2014 1:10 pm ]
Post subject:  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.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group