Code::Blocks Forums

User forums => Help => Topic started by: Pecan on November 15, 2006, 09:57:58 pm

Title: Problem with $(ACTIVE_EDITOR_FILENAME) in Tools
Post by: Pecan on November 15, 2006, 09:57:58 pm
Tools used to substitue $(ACTIVE_EDITOR_FILENAME) in Tools.
I cannot get it to do so since the latest SVN 3222.
Has this been deprecated since %s etc work in abbreviations?
Title: Re: Problem with $(ACTIVE_EDITOR_FILENAME) in Tools
Post by: thomas on November 16, 2006, 02:34:52 am
Not on purpose. Will look at it tomorrow (actually today).
Title: Re: Problem with $(ACTIVE_EDITOR_FILENAME) in Tools
Post by: thomas on November 16, 2006, 12:43:34 pm
Input:

(http://img247.imageshack.us/img247/5566/aefnyc4.gif)


Output:
-------------- Build: default in activeeditorfilename ---------------
mingw32-g++.exe -Wall -O2  -DD:\Desktop\activeeditorfilename\main.cpp  -IC:\MinGW\include  -c main.cpp -o obj\main.o
<command line>:1:2: warning: ISO C requires whitespace after the macro name
mingw32-g++.exe -LC:\MinGW\lib  -o .\activeeditorfilename.exe obj\main.o   -s 
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 1 warnings


Don't see anything unusual? Seems to work just fine for me.


EDIT:
Yes, this is the compiler, not tools, I know ;) That's because I never use tools, so I don't even know where to find the menu entry :lol:

But seriously: Compiler, tools, and everything else call the very same function to expand variables, so it either works for all, or it works for none.
Title: Re: Problem with $(ACTIVE_EDITOR_FILENAME) in Tools
Post by: thomas on November 16, 2006, 12:55:52 pm
But... you're right.

I tried tools and configured this:
(http://img293.imageshack.us/img293/213/0001vz8.png)


... and got:

$(ACTIVE_EDITOR_NAME) 15728 2006-11-16 D:\wxWidgets-2.6.3

Process returned 0 (0x0)   execution time : 0.031 s
Press any key to continue.


Everything is expanded correctly, except $(ACTIVE_EDITOR_NAME).
Title: Re: Problem with $(ACTIVE_EDITOR_FILENAME) in Tools
Post by: thomas on November 16, 2006, 01:33:34 pm
I've implemented a partial fix so far. Partial as in "fixes the problem you observed", but it still doesn't work.

The problem that you observed is peculiar insofar as $(ACTIVE_EDITOR_NAME) is not recognised as variable at all. And more, this is true for any other variable being at the beginning of a string, too. That's because the regex matching the variables was too simple (worked fine for the compiler, which I tested with). This is fixed now.

However, now I see another issue. $(ACTIVE_EDITOR_NAME) is recognised as variable, but it seems to be empty.
Title: Re: Problem with $(ACTIVE_EDITOR_FILENAME) in Tools
Post by: thomas on November 16, 2006, 02:22:25 pm
Hmm... are you sure this ever worked? :shock:

ToolsManager::Execute()
contains the lines:
    // hack to force-update macros
    Manager::Get()->GetMacrosManager()->RecalcVars(0, 0, 0);



... but RecalcVars(0, 0, 0) really runs:
    if(!editor)
    {
        m_ActiveEditorFilename = wxEmptyString;
        m_lastEditor = NULL;
    }

RecalcVars(0, 0, 0) does not reload anything. It's been like that for ages (revision 1497, December 2005), so I could not imagine that $(ACTIVE_EDITOR_NAME) ever worked correctly in tools, under that premise...
I'll try what happens if the behaviour of RecalcVars(0, 0, 0) is changed to reload the current editor/project name (if any). Should not do any harm (hopefully).
Title: Re: Problem with $(ACTIVE_EDITOR_FILENAME) in Tools [resolved]
Post by: thomas on November 16, 2006, 02:43:43 pm
Right... it does work. Now I remember, it's that terribly complicated thing with setting everything to zero, so it updates on the next call to ReplaceMacros()... all is fine. No changes necessary.

The reason why it still did not work was because I was using $(ACTIVE_EDITOR_NAME), not $(ACTIVE_EDITOR_FILENAME) to test... of course that one will always be empty. Stupid me :)

So I guess one can consider the issue resolved.
Title: Re: Problem with $(ACTIVE_EDITOR_FILENAME) in Tools
Post by: Pecan on November 16, 2006, 03:13:41 pm
Again, thank you thomas.
Works fine.