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

Return Codes
http://www.robotc.net/forums/viewtopic.php?f=1&t=4743
Page 1 of 1

Author:  Wolpi35 [ Sun Aug 12, 2012 9:08 am ]
Post subject:  Return Codes

Hi all,

after my first steps with programming our NXT 2.0 Robot I still have beginner questions. I checked too in the help of the RobotC IDE but I cannot find it.

Is there a possibility to give return/exit codes and can I check on it with the robot?

My next question is if it is possible to include an error handling and are error codes available, so I can display them?

Thanks and regards

Stefan

Author:  mightor [ Sun Aug 12, 2012 9:36 am ]
Post subject:  Re: Return Codes

Just like with C, you can declare a function to have a specific return type.
Code:
bool isItTrue(int checkthis)
{
  if (checkthis == 2)
    return true;  // return true
  else
   return false;
}

You can specify many return types, including int, long, bool and float.
Code:
int  addUp(int num1, int num2)
{
  return num1 + num2;
}

For debugging purposes, have a look at the Sample Programs\NXT\NXT Feature Samples\Debug Stream.c program. I use this extensively.

- Xander

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