I have a couple questions about NXC

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
rrawat
Posts: 3
Joined: 18 Mar 2011, 23:57

I have a couple questions about NXC

Post 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.
timpattinson
Posts: 224
Joined: 30 Oct 2010, 04:10
Location: 127.0.0.1
Contact:

Re: I have a couple questions about NXC

Post 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
Screenshot
ScreenClip000001.jpg (3.34 KiB) Viewed 12800 times
For more info about variable watching view this thread https://sourceforge.net/apps/phpbb/mind ... ?f=3&t=583
Good luck
-Tim
Commit to Lego Mindstorms StackExchange Q&A http://area51.stackexchange.com/proposals/4105
Minboards IRC Channel #mindboards on Freenode
My blog: http://timpattinson.wordpress.com/
h-g-t
Posts: 552
Joined: 07 Jan 2011, 08:59
Location: Albania

Re: I have a couple questions about NXC

Post by h-g-t »

For line numbers, open 'Preferences', click on the 'Options' tab and click on the 'Line Numbers' box.
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
nxtreme
Posts: 246
Joined: 29 Sep 2010, 03:53
Location: 192.168.1.2

Re: I have a couple questions about NXC

Post 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.
Last edited by nxtreme on 19 Mar 2011, 00:59, edited 1 time in total.
One King to rule them all, One King to find them,
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
rrawat
Posts: 3
Joined: 18 Mar 2011, 23:57

Re: I have a couple questions about NXC

Post by rrawat »

OMG THANK YOU ALL FOR YOU REPLIES :D
i cant believe you guys replies so fast :D

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 :P ?'

once again thanks so much!
sincerely,
Rahul R.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: I have a couple questions about NXC

Post by mattallen37 »

rrawat wrote:...also to nxtextreme
how do you make the led blink every line using nxc :P ?'....
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.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
nxtreme
Posts: 246
Joined: 29 Sep 2010, 03:53
Location: 192.168.1.2

Re: I have a couple questions about NXC

Post 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 :P.

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!
One King to rule them all, One King to find them,
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: I have a couple questions about NXC

Post 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 &quot;Line numbers&quot; option on the Options tab to turn on line numbers in the gutter.
Choose the "Line numbers" option on the Options tab to turn on line numbers in the gutter.
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: I have a couple questions about NXC

Post 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
hints on variable fields in the original watch window
watch1.jpg (39.21 KiB) Viewed 12800 times
The variable name shown on the configurable watch tool.
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
variables watches in the new NXT Watch List tool
Watch list popup menu options
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
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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
rrawat
Posts: 3
Joined: 18 Mar 2011, 23:57

Re: I have a couple questions about NXC

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests