|
Page 1 of 1
|
[ 6 posts ] |
|
view varibles in virtual world
| Author |
Message |
|
blainegray
Rookie
Joined: Mon Sep 24, 2012 3:03 pm Posts: 14
|
 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
|
| Mon Apr 01, 2013 12:32 pm |
|
 |
|
JohnWatson
Site Admin
Joined: Thu May 24, 2012 12:15 pm Posts: 386
|
 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.
_________________Check out our Blog! And our Facebook page! Need help? Take a look at our Wiki and our Forums.I just met you, And this is crazy, But here's my code now, So fix it, maybe? ~ Carly Rae Jepsen parody
|
| Mon Apr 01, 2013 3:41 pm |
|
 |
|
blainegray
Rookie
Joined: Mon Sep 24, 2012 3:03 pm Posts: 14
|
 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
|
| Mon Apr 01, 2013 8:23 pm |
|
 |
|
tfriez
Site Admin
Joined: Wed Jan 24, 2007 10:42 am Posts: 537
|
 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.
_________________Timothy Friez ROBOTC Developer - SW Engineer tfriez@robotc.net
|
| Mon Apr 01, 2013 10:10 pm |
|
 |
|
blainegray
Rookie
Joined: Mon Sep 24, 2012 3:03 pm Posts: 14
|
 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
|
| Tue Apr 02, 2013 4:47 pm |
|
 |
|
blainegray
Rookie
Joined: Mon Sep 24, 2012 3:03 pm Posts: 14
|
 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
|
| Tue Apr 02, 2013 8:45 pm |
|
|
|
Page 1 of 1
|
[ 6 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 3 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
|
|