News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Default code tags

Started by SKiD, February 18, 2010, 08:47:02 PM

Previous topic - Next topic

SKiD

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:

// $author $date


The new created code file:

// SkiD 2010-02-18


Did i have that possibility ?

Greetings,
SkiD.

MortenMacFly

Quote from: SKiD on February 18, 2010, 08:47:02 PM

// $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:

// $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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

SKiD

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!

MortenMacFly

Quote from: SKiD on February 18, 2010, 09:49:37 PM
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.:

export author=SKiD
codeblocks

Under Windows e.g.:

set author=SKiD
codeblocks.exe
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

SKiD

#4
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
author = SKID

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

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.