Page 1 of 2
I have a couple questions about NXC
Posted: 19 Mar 2011, 00:08
by rrawat
firstly i just want to say that NXC is amazing!
im quite new to programming but learn nxc has been not too difficult
i was wondering (noobish question) how does one debug an NXC code?
in bricxx i see there are in the compile menu things like "step over" etc. these are all debugging functions, right?
but how do you use it, i can seem to (and dont know how to) debug at all. >.<
its frustrating because i have this giant code but I have where the code goes wrong.
isn't there a way to check the code line by line and slowly?
Also:
- i was reading the nxc tutorial and i see line numbers in the left hand side of the code
but when i use bricxx, there are no line numbers and when ever i have to use the go to line function, i have to manually count the lines!
-and how do you watch variables? i was looked at the three methods and all of them are difficult to understand b/c the variable are named var1, var2 etc.
P.S this is not a rant, i guess need to figure out a couple (but crucial) things on Bricxx.
sorry for the trouble,
Rahul R.
Re: I have a couple questions about NXC
Posted: 19 Mar 2011, 00:25
by timpattinson
rrawat wrote:
Also:
- i was reading the nxc tutorial and i see line numbers in the left hand side of the code
but when i use bricxx, there are no line numbers and when ever i have to use the go to line function, i have to manually count the lines!
-and how do you watch variables? i was looked at the three methods and all of them are difficult to understand b/c the variable are named var1, var2 etc.
.
You can view the line number in the bottom left column eg
- Screenshot
- ScreenClip000001.jpg (3.34 KiB) Viewed 12901 times
For more info about variable watching view this thread
https://sourceforge.net/apps/phpbb/mind ... ?f=3&t=583
Good luck
-Tim
Re: I have a couple questions about NXC
Posted: 19 Mar 2011, 00:35
by h-g-t
For line numbers, open 'Preferences', click on the 'Options' tab and click on the 'Line Numbers' box.
Re: I have a couple questions about NXC
Posted: 19 Mar 2011, 00:37
by nxtreme
I'm not an NXC programmer, but I find that one easy way to see what your program is doing is to use the light sensor's LED. One way of doing it is to have it blink momentarily after every line or section of code has completed. Then, just count the number of blinks and you'll know where it got hung up. I'm sure you can think of other, better, ways of implementing this into your program. The screen is also very useful for debugging numbers and such.
Re: I have a couple questions about NXC
Posted: 19 Mar 2011, 00:45
by rrawat
OMG THANK YOU ALL FOR YOU REPLIES
i cant believe you guys replies so fast
so their is no way to do step by step debugging like in RobotC?
i just downloaded the enhanced firmware
I just was to learn how to make use of the function in the compile menu (Step into, break all etc.)
also to nxtextreme
how do you make the led blink every line using nxc
?'
once again thanks so much!
sincerely,
Rahul R.
Re: I have a couple questions about NXC
Posted: 19 Mar 2011, 01:08
by mattallen37
rrawat wrote:...also to nxtextreme
how do you make the led blink every line using nxc
?'....
I think he means every so often (maybe 10 lines). However, the screen or speaker seems to be a much better debugging method for me. nxtreme programs PICAXE's, and you don't exactly have a screen to debug with. In that case, an LED is one of the best ways.
Re: I have a couple questions about NXC
Posted: 19 Mar 2011, 01:44
by nxtreme
I don't use NXC, so I wouldn't know the exact commands. However, in NXT-G I'd turn the LED on, wait 70+ ms and turn it back off. It will slow down your program ever so slightly, but when debugging that isn't a major concern. Remember, if you just can't get your program working, there are plenty of people on the forums here that are always willing to help. Most of them are actually pretty smart, but don't tell them I said that
.
And yes, Matt has a point there. However, the screen or speaker is sometimes being used for other things, in which case using the light sensor can have an advantage. Like I said before, think of a better way of implementing this!
Re: I have a couple questions about NXC
Posted: 19 Mar 2011, 01:51
by afanofosc
The BricxCC debugging (step into, etc...) requires the enhanced NBC/NXC firmware and it has not been extensively tested to the point where it is iron clad. I have used it with success on several occasions but it definitely is not perfect or bug free. Currently I have not implemented any way to set breakpoints, though the enhanced NBC/NXC firmrware has code in place for that.
I often use TextOut or NumOut commands and Waits for debugging purposes.
As Matt mentioned, you can turn on line numbers in the gutter via the Preferences dialog on the Options tab.
- Choose the "Line numbers" option on the Options tab to turn on line numbers in the gutter.
John Hansen
Re: I have a couple questions about NXC
Posted: 19 Mar 2011, 02:14
by afanofosc
All three of the variable watch tools name the variables something other than var1, var2, etc... Here are some screenshots.
hints on variable fields in the original watch window
- hints on variable fields in the original watch window
- watch1.jpg (39.21 KiB) Viewed 12901 times
The variable name shown on the configurable watch tool.
- The variable name shown on the configurable watch tool.
variables watches in the new NXT Watch List tool
- variables watches in the new NXT Watch List tool
Watch list popup menu options
- Watch list popup menu options
Watch properties dialog with drop down list of variables
- Watch properties dialog with drop down list of variables
I'd love to have some help documenting all three of these tools more fully.
John Hansen
Re: I have a couple questions about NXC
Posted: 19 Mar 2011, 02:33
by rrawat
Mr Hansen:
I find the NXT watch list most convenient
however, i cannot find the variable i want to watch in the drop down expression list.
what if i just type the variable in the expression space; will it work??
thanks,
RRawat