User forums > Help
"Variables" in "Default code" ?
polygon7:
Hi,
is it possible to add "variables" (global or project or whatever variables) to deafult code?
I want something like that:
"Variables":
--- Quote ---@author = p7
@date= 01 Feb 2006
@project_name= Some project
@currdate= `date`
--- End quote ---
Default code with "variables"
--- Quote ---**********************************************
Author: @author
Date: @date
Project: @project_name
Comments:
Last modification: @currdate
**********************************************
--- End quote ---
Default code in c/cpp/h file:
--- Quote ---**********************************************
Author: p7
Date: 01 Feb 2006
Project: Some project
Comments:
Last modification: 04 Feb 2006
**********************************************
--- End quote ---
How to make it?
Game_Ender:
You mean you want CodeBlocks to automatically replace @author with your name whenever it saves a file? But keep the keyword when you open it? You should take a look at Subversion it offers similar functionality and seems to fit better with the source control system. Also @ could not be used for keywords because it conflicts with doxygen style comments.
polygon7:
--- Quote from: Game_Ender on February 04, 2006, 05:03:11 pm ---You mean you want CodeBlocks to automatically replace @author with your name whenever it saves a file? But keep the keyword when you open it? You should take a look at Subversion it offers similar functionality and seems to fit better with the source control system. Also @ could not be used for keywords because it conflicts with doxygen style comments.
--- End quote ---
No, no. I want C::B to replace variables only with new files and only in "default code" placed at the top of c/cpp/h files.
KDevelop have dialog window for author, licenece, email and other things for "default code" when you create project.
I think something similar could be achieved using "default code" variables in C::B.
"@" is used as example it can be any character.
For example:
You have this "variable" set:
--- Quote ---@author = Game_Ender
--- End quote ---
You make new project "FooBar", then you open Settings->Editor->Default Code, and put:
--- Quote ---/****************************
* Author: @author
* Project: @project_name
* File: @file_name
*
****************************/
--- End quote ---
And then for every new c/cpp/h file in project FooBar C::B puts:
--- Quote ---/****************************
* Author: Game_Ender
* Project: FooBar
* File: FooBar.c / FooBar.h / whatever
*
****************************/
--- End quote ---
Sorry but my english isn't good, and i dont know how to explain it more clearly.
thomas:
What you want is possible, and it is quite easy too (in principle). All you need to do is add one call to MacrosManager::ReplaceMacros(). This will replace $(ANY_VARIABLE).
In any case, you should add a config option to turn this behaviour on and off, otherwise it may interfere with code that contains something that looks like a variable (in which case this behaviour is not wanted).
polygon7:
Thanks, now i see :)
Navigation
[0] Message Index
[#] Next page
Go to full version