View Full Version : NRG Code Repository
The code repository at http://nrg.chaosnet.org/repository is finished.
Anybody can view the code already posted there, but you need to register for an account at the above website to add code.
The repository works only if people add and view code fairly. If you're gonna use it, add some code too! If you have any questions post them here.
If you see any "bad" code, tell me so I can delete it.
And give some reputation to anybody whose code you use! :)
Raven_Writer
26-01-2004, 08:37
Great job!
Just 2 suggestions so far:
1] Add a way so that when you login, you don't have to do it everytime you return (just like the "Remember Me?" checkbox on CD).
2] When you do login, just redirect the user to where they were before logging in. Or atleast redirect the page after 5 or so seconds.
Problem (2): Fixed.
Problem (1): I'm figuring out how to do the "Remember Me" box right now.
Thanx for the help!
Raven_Writer
26-01-2004, 13:28
Problem (2) has been fixed.
I'm figuring out how to do the "Remember Me" box right now.
Thanx for the help!Just store a cookie, and don't delete it when the session ends. I think that'll work anywho. I know PHP & ASP has functions to get info from a cookie.
Got it.
Plz give reputation to anybody whose code you use. It'll tell them that they're appreciated and will make give people incentive to add useful code.
deltacoder1020
26-01-2004, 13:45
you still need to replace the <base href="..."> with actual references in the links.
I've kept the base tag AND changed all the "../uploads/" paths to absolute paths.
The rest of the links are in the same directory.
Might I suggest a directory structure of some sort? By no means, I'm not saying I know what would be a good structure ... but certainly some directory structure might help. Perhaps you could group it by input: a directory for controlling robot features using a pot, another using limit switches, gyros, encoders, etc. Maybe a special directory for autonomous code. Maybe a directory for code to control driving, and another for other elements of the robot.
The directories would, in my mind, help people to know what to contribute to the repository. Certainly short snippets that, say, lift a robotic arm via some switch, or control a gripper via pots, would help in training people to program the robot -- if they are sufficiently well-written, and well commented. The project sounds like it has potential.
Adding folders right now...
Raven_Writer
26-01-2004, 15:40
Is it possible to move the code that was previously submitted before the changes (folders)?
Also, I don't really see the need to let the user create a new folder. What if someone just does the process over & over again, flooding the server & using up more bandwidth than needed?
* Disabling new folder method (except for admins)
* Adding move feature (you can move your own code, and admins can move any code)
Standby...
Raven_Writer
26-01-2004, 15:43
* Disabling new folder method (except for admins)
* Adding move feature (you can move your own code, and admins can move any code)
Standby...Ok. Great job so far though mate!
I hope this pans out for the best.
echos asked about posting rights.
To make it clear:
To get posting rights, you must register for an account at nrg.chaosnet.org. Make sure you put your team number on the register page.
Could you make it highlight the syntax of php files?
here is the function
http://us3.php.net/manual/en/function.highlight-file.php
A problem with the highlighting:
When you download the code, it's supposed to give it to you in "pure text" so that you can simply save it. So, I'll add another option - "View with Highlighting" - good idea!
Thank you...
Dang your quick when it comes to changes.
Raven_Writer
26-01-2004, 16:10
Could you possibly make it highlight C code also?
Raven_Writer
26-01-2004, 16:14
How?I'm not excellent in PHP, but I'm pretty sure there's a way to search for certain strings, and if it's found, just color-code it. Kinda like:
$text = strtext("$filename");
if($text){
explode("void", "<font color='#0000FF'>void</a>");
}
(I highly doubt strtext(...) works, it's just something that came to me
Jeremy_Mc
26-01-2004, 16:16
I'm not excellent in PHP, but I'm pretty sure there's a way to search for certain strings, and if it's found, just color-code it. Kinda like:
$text = strtext("$filename");
if($text){
explode("void", "<font color='#0000FF'>void</a>");
}
(I highly doubt strtext(...) works, it's just something that came to me
Why are you using explode?
Check http://us3.php.net/manual/en/function.eregi-replace.php
You have to know regular expressions, but it's the quickest and most flexible way to do it.
Just search for the keywords and replace them when you read the file into a variable...it shouldn't be too tough.
Someone give me a list of keywords, and I'll use PCRE's to do the highlighting.
Raven_Writer
26-01-2004, 16:19
Why are you using explode?
Check http://us3.php.net/manual/en/function.eregi-replace.php
You have to know regular expressions, but it's the quickest and most flexible way to do it.
Just search for the keywords and replace them when you read the file into a variable...it shouldn't be too tough.I was just using what I knew :\
I haven't done PHP lately (for about 6 months), so most is gone.
<Edit>:
SilverStar: int, unsigned, char, double, float, void, return
There's prob. others, but those are the ones I know MPLAB uses.
here is a pre made program that does syntax highlighting, its free...
http://www.hotscripts.com/Detailed/10998.html
Raven_Writer
26-01-2004, 16:31
When I tried editing my boolean entry, it said "The page your are looking for cannot be found. Check the address or try again later." when I clicked on "Update"
everything is done, except C code highlighting...
I'm writing my own C/C++ code highlighter.
Raven_Writer
26-01-2004, 17:03
everything is done, except C code highlighting...
I'm writing my own C/C++ code highlighter.
Cool. I hope it all works well.
deltacoder1020
26-01-2004, 17:14
the function in php that was mentioned for syntax highlighting is highlight_string() - this automatically adds syntax highlighting for a string of PHP code. (similar but not the same as C)
Raven_Writer
26-01-2004, 17:17
One thing though. Please don't do the PHP-style orange commenting. It's very bad to have a light-on-light color scheme.
If you want, here's how VC++ does it:
keywords: blue (#0000FF)
- int, void, char, unsigned, return
processor directives: green (#00FF00)
- #define, #else, #ifndef
comments: green (#00FF00)
- /* */, //
deltacoder1020
26-01-2004, 17:29
i'm guessing that the custom syntax highlighting is currently a work in progress, seeing as right now is coloring most of my code pink ;)
Astronouth7303
26-01-2004, 18:06
If you want, here's how VC++ does it:
keywords: blue (#0000FF)
- int, void, char, unsigned, return
processor directives: green (#00FF00)
- #define, #else, #ifndef
comments: green (#00FF00)
- /* */, //
(Sorry, I'm looking at MPLAB, I don't have MSVC++ on this machine :( )
MPLAB does Proc. Directives blue, and I've seen them purple, too.
Keywords are bold.
Constants are a slightly lighter green then the comments.
Symbols are gray ({} > < = ; etc.)
Strings are blue BUT NOT BOLD!
The colors (and purposes) are below:
000000 Default
2121B5 Strings, Hex
2121CE Keywards, Processor directives
218C21 Numbers
296B52 Comments
848484 Symbols
FF0000 Errors
FFFFFF Background
I'd post the image, but I can't attach (or can't find the button) :(
Would it be possible (sometime in the future) to put the coloring specifics in the User CP?
Raven_Writer
26-01-2004, 18:10
(Sorry, I'm looking at MPLAB, I don't have MSVC++ on this machine :( )
MPLAB does Proc. Directives blue, and I've seen them purple, too.
Keywords are bold.
Constants are a slightly lighter green then the comments.
Symbols are gray ({} > < = ; etc.)
Strings are blue BUT NOT BOLD!
The colors (and purposes) are below:
000000 Default
2121B5 Strings, Hex
2121CE Keywards, Processor directives
218C21 Numbers
296B52 Comments
848484 Symbols
FF0000 Errors
FFFFFF Background
I'd post the image, but I can't attach (or can't find the button) :(
Would it be possible (sometime in the future) to put the coloring specifics in the User CP?I think having a light color on a light background is bad though. I've had numerous accounts of adding a double '{' thinking I didn't have the first one in, because of the very small contrast in colors.
But thanks for the list of the color/values. For attatchments, there's a button called "Manage Attatchments". Click that, and that'll let you upload stuff :D
I think having a light color on a light background is bad though. I've had numerous accounts of adding a double '{' thinking I didn't have the first one in, because of the very small contrast in colors.
But thanks for the list of the color/values. For attatchments, there's a button called "Manage Attatchments". Click that, and that'll let you upload stuff :D
My decision:
I'll go with everything in the post quoted above.
Want to see the current source of the highlighter?
Go here: http://nrg.chaosnet.org/source/repository/download.php
Raven_Writer
26-01-2004, 18:38
Want to see the current source of the highlighter?
Go here: http://nrg.chaosnet.org/source/repository/download.phpThat's really cool. Thanks for showing the source for it. Did you use any PHP functions for showing the code? (I know there's highlight_code(...) & show_source(...)....don't quite understand how they work though)
I use a buffer to hold all the source so that I can format it into a table with line numbers. You're right, I use show_source and highlight_file (not _code)
Raven_Writer
26-01-2004, 18:41
I use a buffer to hold all the source so that I can format it into a table with line numbers. You're right, I use show_source and highlight_file (not _code)Cool. Sorry about that, I forgot weither it was highlight_file or highlight_code
Our job now:
To get people to add code to the repository.
And, can this thread be made sticky?
Syntax hilighting is not quite so simple. There are special cases you have to account for, that make the code somewhat more complex. For example, if I make a comment that says:
// If the "if" statement's condition below is true, it should run the "auto-vivify-functifier"
I wouldn't expect 'if' to be highlighted another color, nor would I expect the text in quotation marks to be highlighted another color. Also, you have to watch out for "This string keeps on \" going \", even though I just had two quotation marks, I'm still not finished." There are many other conditions you have to watch out for, too. Sure, not all these cases might come up, ... and really, someone can just copy the coad into their favorite C editor anyway, ... but I'd look for an already done solution (why reinvent the wheel? unless, of course, this is for your edification, in which case you might want to think about more of the special cases yourself).
For an example of some conditions you didn't catch, look at the PID code. EDIT: especially, looking over it again, in the Trig lookup table, the "extra" highlighted parts of the comment can get annoying, and potentially mess someone up.
The reason I did not use an already made module is because I don't have permissions on the chaosnet server (our host) to install stuff. Since people can see the "special cases" in their own editor (like you said), I'm not gonna spend much more time working on the highlighter. If anyone wants to, they can post it in "Website (Perl/PHP)" folder.
Each entry can now be rated on 1 to 5 scale.
deltacoder1020
26-01-2004, 20:57
cool beans. ;)
deltacoder1020
26-01-2004, 21:05
btw, SilverStar, do you have AIM (preferably) or MSN?
deltacoder1020
26-01-2004, 21:07
pm, then? or just message me - deltacoder on AIM, mobile@vectorray.com on MSN
just post stuff here, i'll read it.
btw - would it be possible to add both a comments system and a file update system to the repository?
Working on comments system, should be simple.
File update system - you can always edit your code. But I'll work on an version managemtent system (will take time).
deltacoder1020
26-01-2004, 21:23
ick - one bug with the edit function, it resets the rating of the file - this should probably be fixed.
deltacoder1020
26-01-2004, 21:29
on another note, the guestbook forum on your site probably shouldn't be displaying this:
You do not have sufficient privileges to read the threads in this forum.
:)
source highlighter has a problem with keeping the integraty of the code. It place lots of spaces instead of using <pre> </pre> tags to maintain structure.
... ignore this message please ... Terribly sorry.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.