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

view varibles in virtual world
http://www.robotc.net/forums/viewtopic.php?f=1&t=5658
Page 1 of 1

Author:  blainegray [ Mon Apr 01, 2013 12:32 pm ]
Post subject:  view varibles in virtual world

Greetings
Is there any way to view the value of variables as the robotc code is running in the virtual world. That feature would certainly help in debugging programs as they are running.
Thanks,
Blaine

Author:  JohnWatson [ Mon Apr 01, 2013 3:41 pm ]
Post subject:  Re: view varibles in virtual world

Starting with version 3.5, ROBOTC now treats global variables and local variables as they are technically should be treated (prior to 3.5, local variables were treated like global variables for debugging purposes). This means that the local variables are not able to be displayed in the Local Variables Debug window while the program is running full-tilt. There are a couple of ways to compensate for this, such as stepping through your program manually, displaying the variables using the Debug Stream window, or changing all of the local variables to global variables.

For more information on this, take a look at our blog post from a while back that explains this specific change in detail.

Author:  blainegray [ Mon Apr 01, 2013 8:23 pm ]
Post subject:  Re: view varibles in virtual world

Hello John,
Thanks for the information about global variables. It looks that that works while the program is running in RobotC. Is there a way to view the ongoing state or value of the variables as the program is executing in the virtual world?

The only way I see to get the value of the variables in the real world as the program is running is with a long USB cord or a Bluetooth adapter and running the code from RobotC on a real robot with the debug window open. I have put the variables on the display but sometimes that is hard to catch as the robot is moving around.
Blaine

Author:  tfriez [ Mon Apr 01, 2013 10:10 pm ]
Post subject:  Re: view varibles in virtual world

If you set the variables to be global (declared outside of any function/task) or as a "static" variable (i.e. static int myVar;), your variables will show under the "Global Variables" debugger and constantly update as the program is running.

Another solution is to set your Menu Level (under the "Window" menu) to "Super User". If you do this, while the virtual worlds is opened, you can select "Open Debugger Manually" from the Robot menu to access the "Step" commands inside of the virtual worlds.

Author:  blainegray [ Tue Apr 02, 2013 4:47 pm ]
Post subject:  Re: view varibles in virtual world

Hello tfriez
Thanks for the suggestion. All the variables are declared as global but they are not appering in the Global Variables window.

I set the user mode to Super User, downloaded the program to the virtual world, clicked Open Debugger Manually and Start. The program does start in the virtual world. In the Debugger windows tab, Local Variables, Global Variables, and Remote NXT Display are checked, however, the global variables still do not appear. I will have to add some code for the display. Any suggestions on why the global variables are not appearing? Is that SensorValue(lightSensor) a global variable by default, perchance.

The program I am working on is Line Tracker 1 and the robot is counting but I am not sure what is being counted when. Of course, the program is not exactly working correctly.
Blaine

Author:  blainegray [ Tue Apr 02, 2013 8:45 pm ]
Post subject:  Re: view varibles in virtual world

Hello tfriez,
Well, I found that the variables were not global - they were local. Further reading showed that global variables have to be declared before task main. I moved the declaration to before task main and they display and update in the global variable window. Now all I have to do is get the logic to work correctly.
Blaine

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