User forums > Using Code::Blocks

Tool macros

(1/2) > >>

orefa:
I have a question and a suggestion. Are there any undocumented tool macro? Specifically one to get the current file's name without its extension? For example, I see no obvious way to add a strip command to the tools menu that would only process the object file of the current editor. If it existed, it would be simple to use parameter ".objs\${ACTIVE_EDITOR_FILENAME_ONLY}.o" but I don't see it. The tool macros are:

PROJECT_FILENAME
PROJECT_NAME
PROJECT_DIR
ACTIVE_EDITOR_FILENAME
ALL_PROJECT_FILES
MAKEFILE

I was thinking that offering the separate (1) path (2) name and (3) extension of both the editor file and the project file would provide complete flexibility for all purposes:

EDITOR_PATH
EDITOR_NAME
EDITOR_EXT
PROJECT_PATH
PROJECT_NAME
PROJECT_EXT
PROJECT_ALL_FILES
MAKEFILE

This would make it easy to combine the needed parts at will and leave out the rest.

thomas:
Are there any undocumented tool macro?
We're not the Redmont Corp.  8)

With the exception of $LINK_FLAT_OBJECTS wich was only added to svn 11 hours ago, all builtin variables are documented in the WiKi under "builtin variables".


--- Quote ---For example, I see no obvious way to add a strip command to the tools menu that would only process the object file of the current editor.
--- End quote ---
One obvious (maybe not the most efficient) way is:
echo $(ACTIVE_EDITOR_FILENAME) | sed -e "s/\.[ch]pp/\.o/" | xargs strip

orefa:
Thanks for the wiki reference Thomas. :) I had not found that, but I searched using the wrong terms. I suggest replacing "You can use the following macros" with "You can use the following builtin variables" in the dialog box if this is what they should be called.

I run Windows so I cannot use the sed-based method you showed me.

But does the idea to have one macro for each file section make any sense? Feasible, practical, none of the above?

thomas:
Some of the variables which you request for the project file are already present, and the others cannot be implemented.
More precisely, they can be implemented, but they don't make sense. We only have the project's containing directory available as a relative path here, so if the project file is not in some subfolder, the containing directory will always be empty. Using that path as parameter to a tool will result in the executable's current working dir, which is not what you want.
On the other hand, if the project file is in a subfolder, you will get the error "cannot find file", which is not better, either.

Regarding the requested parts of the active editor's filename, please check out / update to the latest svn version and consult the WiKi for the variables' names. :)

orefa:
Ah yes of course, I had blindly panned over the other ACTIVE_EDITOR_ names that are not listed under "Edit Tool". Thanks, but they don't seem to actually work:

ACTIVE_EDITOR_FILENAME: Expands to absolute path + filename + extension (ok).
ACTIVE_EDITOR_DIRNAME: Expands to "".
ACTIVE_EDITOR_STEM: Expands to "".
ACTIVE_EDITOR_EXT: Expands to "".

You said that you only have a relative path but the paths returned by the other builtin variables are absolute on my system, not relative. Also you said "if the project file is not in some subfolder" but then where would it be? Did you mean that it is in the current working directory? Because then the path should be what the OS uses for the current directory like ".\" and not an empty string (unless that's what the specific OS uses).

Forgive my density if everything already seems obvious to you, I feel like a dope for asking...

Navigation

[0] Message Index

[#] Next page

Go to full version