Author Topic: Tool macros  (Read 5253 times)

Offline orefa

  • Multiple posting newcomer
  • *
  • Posts: 102
Tool macros
« on: May 12, 2006, 01:26:33 am »
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.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Tool macros
« Reply #1 on: May 12, 2006, 10:10:02 am »
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.
One obvious (maybe not the most efficient) way is:
echo $(ACTIVE_EDITOR_FILENAME) | sed -e "s/\.[ch]pp/\.o/" | xargs strip
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline orefa

  • Multiple posting newcomer
  • *
  • Posts: 102
Re: Tool macros
« Reply #2 on: May 12, 2006, 01:42:00 pm »
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?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Tool macros
« Reply #3 on: May 12, 2006, 02:44:40 pm »
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. :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline orefa

  • Multiple posting newcomer
  • *
  • Posts: 102
Re: Tool macros
« Reply #4 on: May 12, 2006, 05:00:42 pm »
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...


Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Tool macros
« Reply #5 on: May 12, 2006, 05:44:53 pm »
Quote
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
No you haven't, they were not there before.
I added them about 3 hours ago:
please check out / update to the latest svn version


About the Project filename, usually it looks like this:
SomeFolder
 |
 +- blah.cbp
 +- foo.c
 +- bar.h


But it is also possible to arrange it differently (some people prefer that):
SomeFolder
 |
 +- project
 |    +-blah.cbp
 +- sources
 |    +-foo.c
 +- headers
      +-bar.h



Thinking about this, I forgot that you have the common toplevel path available as a variable (which is identical with the project's path if the project is in the toplevel directory). Since you are probably not interested in the project file's location anyway, but the common toplevel directory, that should solve your problem.
In the above example, the common toplevel path would be /path/to/SomeFolder.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline orefa

  • Multiple posting newcomer
  • *
  • Posts: 102
Re: Tool macros
« Reply #6 on: May 12, 2006, 06:14:17 pm »
Quote
No you haven't, they were not there before.
I added them about 3 hours ago:
Ah, I feel less dopey by at least some measureable quantity.

Quote
please check out / update to the latest svn version
I haven't tried compiling the source myself yet but I'll try them out at the next nightly build. Thank you for adding the variables! :)

Quote
that should solve your problem.
Yes it should. I was also hoping to address unforeseeable future needs for everyone.

Thanks again, great work is taking place all the time on this project. I'm sure you already knew that, but it doesn't hurt to repeat it.

lfm

  • Guest
Re: Tool macros
« Reply #7 on: May 16, 2006, 05:49:18 am »
C::B's tool setting is not very handy(to use). in this respect, C::B can reference "EditPlus": http://www.editplus.com