Ok, I think C::B don't have this feature(expand the %VAR% string to its value in its argument settings)
You can enhance it by implement it, so patch are welcome.
Another way I think you can use is to use the Tool+ plugin, which you can use the command line tool, you can see a related discuss here:
http://developer.berlios.de/bugs/?func=detailbug&bug_id=19180&group_id=5358
So, write some command like (I don't try this yet, you can try it yourself)
cmd /c $(TARGET_NAME) %VAR%
See: http://wiki.codeblocks.org/index.php?title=Variable_expansion as another reference.
Thanks to your suggestions, I got 2 workarounds to this problem:
1.
Post-build Steps (a) Go to the
Project's Build Options, select the
"Pre/post build steps" tab.
(b) Under
Post-build step, type
"$(TARGET_OUTPUT_FILE) %VAR%".
(c) Check
"Always execute, even if target is up-to-date" (d) Build the project. Due to (c), the executable will run regardless of whether it's up-to-date, which is what I want.
* If we "Build and Run" the project, the executable will run twice.
2.
External Tool (a) Go to
Tools -> Configure tools, click
Add to create a new tool.
(b) Fill up the
Edit tool dialog. For my case, the data is as follows:
Name: Whatever
Executable: ${TARGET_OUTPUT_FILE}
Parementers: %VAR%
Working directory: ${PROJECT_DIR}
(c) Go to
Tools and click
Whatever to run the program.
Though these are not the most desired ways, but it's good enough for me.
EDIT:
So, maybe, C::B already replace the %XXX% like string reference to Variable expansion - CodeBlocks, so just enable the macro replace feature for the argument input dialog?
Somehow I couldn't find the "enable the macro replace feature" in the argument input dialog. Did I miss something?
At least on linux, the environment variables get expanded:
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
for (int i; i < argc; ++i)
cout << argv[i] << endl;
cout << "Hello world!" << endl;
return 0;
}
called with argument $HOME (set in "Project -> Set programs's arguments..." gives the (expected) result:
/tmp/test/bin/Debug/test
/home/jens
Hello world!
Process returned 0 (0x0) execution time : 0.002 s
Press ENTER to continue.
Thanks. Too bad I'm not using Linux. Tried everything I could with the program's argument but it just doesn't work.