Custom_Code.c coding help:Perl script

Forum for problems or queries regarding other Flowcode Components. Eg LEDs, Switches, LCD, Gfx LCD etc

Moderators: Benj, Mods

Post Reply
nils
Posts: 33
Joined: Fri Nov 02, 2007 11:03 am
Contact:

Custom_Code.c coding help:Perl script

Post by nils »

Hello

I alread posted my script in the Component vote thread, but am not quite sure if every one has seen it, or I may be the only one who forgets to set the code right or makes typing errors. ;-)
Anyway, I coded a script, that sets inside the Custom_Code.c file the corresponding MacroReturns, MacroNames and so on, so that YOU do not need to care about them while implementing new functions to the file. I sometimes was tired of editing these descriptions when I tried to implement different things and finally wrote a Perl script that now does the job for me, so I can concentrate on ONLY writing the C code and nothing else, an easy "perl set_code.pl" on the command line does the job and you're done with it.
well, it may not be for everyone, but it helps me from now on in new projects so that I don't have to care about how many functions I am writing and so on. now it is coding -> perl script -> flowcode implementation -> done! and no more fiddling with spelling errors.
for setting things up, there is a short description at the beginning of the script.

cheers and have fun,
Nils

PS: you get a free Perl version for windows @ activestate.com
PPS: if you find bugs or have ideas what to implement next, write it down in this thread and I try to figure it out.
PPPS: I WILL POST NEW VERSIONS EVERY ONCE IN A WHILE, SO LOOK FOR THE LATEST ONE IN THIS THREAD AS I WILL NOT UPDATE THE DOWNLOAD LINKS
Attachments
set_code.pl.zip
(3.68 KiB) Downloaded 876 times
Last edited by nils on Sat Feb 23, 2008 12:28 pm, edited 1 time in total.
Custom_Code.c help needed? -> http://tinyurl.com/2y2mzq
Flowchart high quality vector graphic output =>>http://tinyurl.com/6sx2sx

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Custom_Code.c coding help:Perl script

Post by Benj »

Hello Nils

I had thought of creating a Perl or PHP script to do this but never managed to get around to it.

Thanks for your input. I hope you will be happy in the knowledge that your code will aid us to creating new components. :mrgreen:

If I find bugs, incompatibilities or problems with the code then I will let you know here.

Thanks again.

nils
Posts: 33
Joined: Fri Nov 02, 2007 11:03 am
Contact:

Re: Custom_Code.c coding help:Perl script

Post by nils »

I thought you would ;-)
it is not completely bug proven, but it works for me. unfortunately it does not contain compatibility to your style of coding i.e.

Code: Select all

void something()
{
    some code;
    more code;
}
in contrast to mine that is

Code: Select all

void something(){
    some code;
    more code;
}
but maybe you have the excellent solution and can contribute on the script :P
Custom_Code.c help needed? -> http://tinyurl.com/2y2mzq
Flowchart high quality vector graphic output =>>http://tinyurl.com/6sx2sx

nils
Posts: 33
Joined: Fri Nov 02, 2007 11:03 am
Contact:

Re: Custom_Code.c coding help:Perl script

Post by nils »

dupe, double post ;)
Last edited by nils on Wed Feb 13, 2008 5:36 pm, edited 1 time in total.
Custom_Code.c help needed? -> http://tinyurl.com/2y2mzq
Flowchart high quality vector graphic output =>>http://tinyurl.com/6sx2sx

nils
Posts: 33
Joined: Fri Nov 02, 2007 11:03 am
Contact:

Re: Custom_Code.c coding help:Perl script

Post by nils »

so if anyone is interested in what my script is doing (in a brief explanation + flowchart), I wrote up a little LaTeX document to introduce my script and the "Macro" definitions I am altering/generating with it.
hope it helps people that were a bit helpless like me seeing the Custom_Code.c file for the first time :shock:

cheers,
nils
Attachments
Custom_Code.pdf
(116.46 KiB) Downloaded 966 times
Custom_Code.c help needed? -> http://tinyurl.com/2y2mzq
Flowchart high quality vector graphic output =>>http://tinyurl.com/6sx2sx

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Custom_Code.c coding help:Perl script

Post by Benj »

Hello Nils

Just had a look through your PDF. It's fantastic, thanks for all the work you have put into this. I have yet to verify the script itself but the next coding that I do I will try it out.

Thanks again.
Ben

nils
Posts: 33
Joined: Fri Nov 02, 2007 11:03 am
Contact:

Re: Custom_Code.c coding help:Perl script

Post by nils »

version 1.1b_2
hi there

this evening I tweaked a bit the code for supporting different styles of braces, as I know that you folks of MM do it another way as I do, and maybe others out there too. now following things are possible:

Code: Select all

void something1(){
    some code;
    more code;
}

void something2()
{
    some code;
    more code;
}

void something3()
{   some code;
    more code;
}

void something4()
{   some code;
    more code;}
there are a few things missing, but I hope you like it anyway.
I used it a few times this week while adding/deleting functions and it worked like a charm :mrgreen:

edit: added support for closing curly braces, wherever they may be. only thing with braces not working is some weird stuff like the following code, but this is REALLY ugly IMO:

Code: Select all

void Test(short Foo){int Bar;
    more code;
}
PS: comments and bug reports are always welcome.
Attachments
set_code.pl_1.1b_2.zip
(4.29 KiB) Downloaded 701 times
Last edited by nils on Sat Feb 23, 2008 2:48 pm, edited 1 time in total.
Custom_Code.c help needed? -> http://tinyurl.com/2y2mzq
Flowchart high quality vector graphic output =>>http://tinyurl.com/6sx2sx

nils
Posts: 33
Joined: Fri Nov 02, 2007 11:03 am
Contact:

Re: Custom_Code.c coding help:Perl script

Post by nils »

version 1.2
changed recognition of functions, so that ugly things like this one

Code: Select all

void Test(char Foo, short Bar){ugly code; do not try to do so;}
will result in

Code: Select all

void Test(char Foo, short Bar){
/*Macro_Test_Start*/
ugly code; do not try to do so;
/*Macro_Test_End*/
}
and now time stamps of the backups are a bit nicer than before e.g. Custom_Code.c.Sat_Feb_23_13-43-23_2008.

regards,
nils
Attachments
set_code.pl_1.2.zip
(4.32 KiB) Downloaded 677 times
Custom_Code.c help needed? -> http://tinyurl.com/2y2mzq
Flowchart high quality vector graphic output =>>http://tinyurl.com/6sx2sx

nils
Posts: 33
Joined: Fri Nov 02, 2007 11:03 am
Contact:

Re: Custom_Code.c coding help:Perl script

Post by nils »

Hi there

new updated version of the documentation:
- changed flowchart
- added a short description how to invoke the script in Win/Lin/Uni/Mac environments

have fun with it
nils
Attachments
Custom_Code.pdf
(150.38 KiB) Downloaded 920 times
Custom_Code.c help needed? -> http://tinyurl.com/2y2mzq
Flowchart high quality vector graphic output =>>http://tinyurl.com/6sx2sx

Post Reply