3.3 Script expansion

CodeBlocks

[Contents] CodeBlocks Manual   [Search] Search

[Table of contents]

3.3 Script expansion


For maximum flexibility, you can embed scripts using the [[ ]] operator as a special case of variable expansion. Embedded scripts have access to all standard functionalities available to scrips and work pretty much like bash backticks (except for having access to CodeBlocks namespace). As such, scripts are not limited to producing text output, but can also manipulate CodeBlocks state (projects, targets, etc.).
Note:
Manipulating CodeBlocks state should be implemented rather with a pre-build script than with a script.
Example with Backticks
  objdump -D ‘find . -name *.elf‘ > name.dis
The expression in backticks returns a list of all executables *.elf in any subdirectories. The result of this expression can be used directly by objdump. Finally the output is piped to a file named name.dis. Thus, processes can be automatted in a simple way without having to program any loops.
Example using Script
The script text is replaced by any output generated by your script, or discarded in case of a syntax error.
Since conditional evaluation runs prior to expanding scripts, conditional evaluation can be used for preprocessor functionalities. Built-in variables (and user variables) are expanded after scripts, so it is possible to reference variables in the output of a script.
  [[ print(GetProjectManager().GetActiveProject().GetTitle()); ]]
inserts the title of the active project into the command line.


[Previous] 3.2.8  Conditional Evaluation
[Next] 3.4  Command Macros

Created: 2010/25/05 11:52   Updated: 2010/25/05 11:52
Author: HighTec EDV-Systeme GmbH
Copyright © 2010 HighTec EDV-Systeme GmbH