Author Topic: Default code tags  (Read 6069 times)

Offline SKiD

  • Single posting newcomer
  • *
  • Posts: 3
Default code tags
« on: February 18, 2010, 08:47:02 pm »
Hello,

if i look in my default code editor for source files, i see an empty editor.
I want to make a new file template for header and cpp files, but i dont know how i can automatically insert the current date or author.

For example my editor default code file:
Code
// $author $date

The new created code file:
Code
// SkiD 2010-02-18

Did i have that possibility ?

Greetings,
SkiD.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Default code tags
« Reply #1 on: February 18, 2010, 08:58:17 pm »
Code
// $author $date

Did i have that possibility ?
Yes, do the following:
- Setup a variable with your name in the environment variables plugin, e.g. "author=SKID"
- Setup the code for the source file (and/or header file accordingly) as follows:
Code
// $author
// $NOW
The first line: Any environment variable will be resolved. This includes %USERNAME% on Windows, but always use the dollar ($) operator in the default code.
The second line: C::B features a lot of internal macros (you can consult the C::B documentation accordingly), one of it is NOW which is date and time in a certain format. Other formats are possible but named differently (obviously).

Notice that if you are using a version control system you'd probably want to use the the macro replacement functionality of e.g. subversion.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline SKiD

  • Single posting newcomer
  • *
  • Posts: 3
Re: Default code tags
« Reply #2 on: February 18, 2010, 09:49:37 pm »
Hello,

thanks for reply!
I search the environment variables plugin, but i only found a wiki-entry.

Can you tell me where i can download that plugin ?

Thank you!

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Default code tags
« Reply #3 on: February 19, 2010, 07:04:55 am »
Can you tell me where i can download that plugin ?
What version of C::B do you have? It's part of 08/02 and the nightlies. Just make sure (if you are using the installer) that you select this plugin to be installed. It is part of the contrib plugins. Alternatively you can also set the environment variable outside C::B and then run C::B in that environment.

Under Linux e.g.:
Code
export author=SKiD
codeblocks
Under Windows e.g.:
Code
set author=SKiD
codeblocks.exe
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline SKiD

  • Single posting newcomer
  • *
  • Posts: 3
Re: Default code tags
« Reply #4 on: February 19, 2010, 12:17:00 pm »
Okay thanks i found it!
I hava reinstalled the program and found it in the environment settings!

Thank you very much for your help to solve the problem ;)

Greetings,
SkiD.

//EDIT

Okay, iam cheered to soon.
I have insert variables with my name like that
Code
author = SKID

If i want to insert that tag in my source file, the variable always show $author and not SKID.
For example:
Code
Default code for source file:
// $author

New source file:
// $author

I look for the right profile in my project, but it shows always default.
My variables are created in the default profile, too.

« Last Edit: February 19, 2010, 05:40:07 pm by SKiD »