Author Topic: Template with automatic text like author and date how can i do this?  (Read 3655 times)

Offline Denro

  • Multiple posting newcomer
  • *
  • Posts: 28
  • Just dont ask me
    • search to find
hi,

i am new to this C::B and i dont understand english ver well

i did look in the help file and found some code example...
/*************************************************************************
   *  Project:
   *  Function:
   *************************************************************************
   *  $Author: mario $
   *  $Name:  $
   *************************************************************************
   *
   *  Copyright 2007 by company name
   *
   ************************************************************************/



i did put this into the default code with nothing else then that
now new files are showing me this and thats great :D

but somehow it is not replacing my name
as i understand $Author is a variable somewhere but i dont know where to change it?
i did try to make this veriable in the enviroment variables but it is somehow not working :(

how can i do some simple default code where some variables get replaced?

something like

/* this is $PROJECT_NAME
    Author: $NAME
    Date: $D_DD.MMMM.YYYY
    Contact: $MYADDRESS?
*/

can someone please enlighten me :D

i did search allready and found many things but somehow i dont understand it

if you help me it would be a great favor...

thanks :)
Max 255; characters remaining: 221

Offline Denro

  • Multiple posting newcomer
  • *
  • Posts: 28
  • Just dont ask me
    • search to find
Re: Template with automatic text like author and date how can i do this?
« Reply #1 on: February 08, 2010, 08:51:30 pm »
OK i found a way... maybe you know a better way so tell me ;)

i use now Settings>Editor>Abbveritations
u add a new Abbveritation

and enter some text like that
/* SOURCE HEADER
****************************************************************
   Project name: $PROJECT_NAME
   File name: $ACTIVE_EDITOR_STEM
   File extension: $ACTIVE_EDITOR_EXT
   Description: $(Description)
   Date: $WEEKDAY $NOW_L
   Author: $(Author_Name)
   Contact:
      Mail: $(Author_e-mail)
      Website: $(Author_website)
   Licence:
      Just run it and enjoy!
      Feel free to copy and share!
      Dont do any bussines with that!
      If you reuse or use it to do business,
      the author of this code will get 100% of your income!
      Agree with that or close the file now and delete it.
****************************************************************
*/

|


it will ask me for a File description, my name, my email and my website
it will automaticaly fill out the Porject name, the file name, the file extension, Day name, Date and time

and the text as it is

i did try to use  $ACTIVE_EDITOR_STEM.$ACTIVE_EDITOR_EXT somehow this is not working, its ignoring everything before the dot :(
i did also try $ACTIVE_EDITOR_STEM but this did return the whole file path :(
so i did two entries, one for file name and one for the extension

now i can open a new file and write the name of the abbrevation in example FHEAD and then press control+J so it will ask some questions and fill in the FHEAD :D

this will then look like that....

/* SOURCE HEADER
****************************************************************
   Project name: Test
   File name: TestFile
   File extension: c
   Description: A test file to test things
   Date: Monday 2010-02-08-19.51.22
   Author: Me
   Contact:
      Mail: me@mailer.net
      Website: http://www.somewhereintheinternet.net
   Licence:
      Just run it and enjoy!
      Feel free to copy and share!
      Dont do any bussines with that!
      If you reuse or use it to do business,
      the author of this code will get 100% of your income!
      Agree with that or close the file now and delete it.
****************************************************************
*/



if there is a better way you can tell me :D
Max 255; characters remaining: 221

Offline Denro

  • Multiple posting newcomer
  • *
  • Posts: 28
  • Just dont ask me
    • search to find
Re: Template with automatic text like author and date how can i do this?
« Reply #2 on: February 08, 2010, 11:26:15 pm »
is there someone who knows how to do this with conditions ?

$if(condition){true clause}{false clause}

i try to use it but somehow its not working properly

i did

$if($(TryMe)){$(TryMe)}{MEDefault}

somehow its allways displaying {MEDefault} ... they TryMe variable is only asked once
if there is no answer for Try me it will be black if there is a answer it will be AnSwEr{MEDefault}
somehow i would like that {MEDefault} is not appearing if there was a answer

how can i do this now?
Max 255; characters remaining: 221

Offline Denro

  • Multiple posting newcomer
  • *
  • Posts: 28
  • Just dont ask me
    • search to find
Re: Template with automatic text like author and date how can i do this?
« Reply #3 on: February 09, 2010, 03:06:47 am »
Ok now i know a bit more i hope it will be helpfull for someone...
maybe everyone here knows it allready ... but maybe to new people its can be helpfull....

go to setings>editor>abbrevitations make a new one and insert code...
/* SOURCE HEADER
****************************************************************
   Project name:
            $PROJECT_NAME
   File name:
            $ACTIVE_EDITOR_STEM
   File extension:
            $ACTIVE_EDITOR_EXT
   Purpose:
            $(Purpose)
   Usage:
            $(Usage)
   Date:
            $WEEKDAY $NOW_L
   Author:
            $Author_Name
   Contact:
            E-mail: $Author_e_mail
            Website: $Author_website
            Company: $Author_company
            Street: $Author_street_and_number
            Place: $Author_zip $Author_place
            Country: $Author_country
            Phone: $Author_phone
   Licence:
            Just run it and enjoy!
            Feel free to copy and share!
            Dont do any bussines with that!
            If you reuse or use it to do business,
            the author of this code will get 100% of your income!
            Agree with that or close the file now and delete it.
****************************************************************
*/

|

then go to settings>enviroment>enviroment_variables there you set all the $variables but without $-sign...
Author_Name
Author_e_mail
Author_website
Author_company
Author_street_and_number
Author_zip $Author_place
Author_country
Author_phone

then you go to editor you type the name of your abbrevitation and press controll + J

it will ask for file purpoese and file usage and the rest will be automatic

to explain this

variables as...
$PROJECT_NAME
$ACTIVE_EDITOR_STEM
$ACTIVE_EDITOR_EXT
are build in variables coming from codeblocks you can find them in the CHM help file that is somewhere in the codeblocks directory ... in the chm file you look at chapter 3.2 to find more

variables which are not build in avaibal can be set in the global enviroment variable table. just insert the name and value without the $-sign... so you can acces them as the build in variables with a leading $ sign and the variable name as you gave

variables as...
$(VaRiAbLeNaMe)
will force codeblocks to ask you for some value

....
there is somehow no good way to make such auomatic entries under conditions somehow the $IF($whatever){do $whatever}{or $(that)} is not working properly

maybe later someone will enlighten me how to do it or maybe its just not possible until now

how ever i hope it will help someone to do some kind of template with automatic text
Max 255; characters remaining: 221