[NXC] Improve Help File

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

[NXC] Improve Help File

Post by muntoo »

Here you can post examples, fixes, etc for the NXC Help File. Hopefully, John Hansen will update the help file to accommodate your improvements.

For example, ex_SetVMRunState.nxc, contains the following at the moment this post was written:

Code: Select all

SetVMRunState(0); // stopped
Not too helpful, eh? Try your hand at improving it. This is a little better:

Code: Select all

SetVMRunState(UI_VM_IDLE); // stopped
*Disclaimer: I don't really understand what this code does. :)

There's many of these types of "examples" ** out there:

Code: Select all

y = ceil(x);
Could be improved to:

Code: Select all

float a = ceil(3.01);
// a == 4.0
float b = ceil(3.14);
// b == 4.0
float c = ceil(3.99);
// c == 4.0
float d = ceil(4.0);
// d == 4.0
** Not critisising anyone, least of all John. :D
Last edited by muntoo on 05 Mar 2011, 06:15, edited 2 times in total.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: Improve NXC Help File

Post by muntoo »

Switch the descriptions of UI_VM_RESET1 and UI_VM_RESET2.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Improve NXC Help File

Post by afanofosc »

I will certainly take these contributions and use them to improve the NXC help. Thanks!

It might also be helpful to email me replacement sample code files (e.g., ex_FUNCTIONNAME.nxc) directly or post them as attachments that I can simply download and rename from .txt to .nxc or something like that.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

NXC Example File: "ex_SetLongAbort.nxc"

Post by muntoo »

[This post provides an example, and also defines the format for future posts of example files.]


Attachment:
ex_SetLongAbort.zip
(554 Bytes) Downloaded 154 times
Notes:
This program example [and variations] can be used in more than one API call example.


[Optional code snippet.]
ex_SetLongAbort.nxc:

Code: Select all

task main()
{
	// Set exit button to end program only if it is pressed for longer than 2 seconds
#ifdef __ENHANCED_FIRMWARE
	SetLongAbort(true);
	// is equivalent to
	SetAbortFlag(BTNSTATE_LONG_PRESSED_EV);
#endif

	while(true)
	{
		ClearScreen();
		// Display on NXT Screen: "Press the exit button longer (for 2 seconds) to exit"
		TextOut(0, LCD_LINE1, "Press the exit", 0);
		TextOut(0, LCD_LINE2, "button longer", 0);
		TextOut(0, LCD_LINE3, "(for 2 seconds)", 0);
		TextOut(0, LCD_LINE4, "to exit.", 0);
		
		
		// Display number of times the user has pressed the exit button (for less than 2 seconds)
		NumOut(0, LCD_LINE8, ButtonPressCount(BTNEXIT), 0);
		
		
		// Wait until user presses and releases exit button before continuing loop
		while(!(ButtonPressed(BTNEXIT, 0)));
		while(ButtonPressed(BTNEXIT, 0));
	}
}

[Optional extra attachment at bottom.]
ex_SetLongAbort.zip
(554 Bytes) Downloaded 154 times


Last bumped by muntoo on 08 Apr 2011, 23:25.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests