Difference between revisions of "Startup script"
m (wikify) |
(Updated info for latest changes) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
[[Category:Scripting Code::Blocks]] | [[Category:Scripting Code::Blocks]] | ||
− | When Code::Blocks finishes loading, it tries to load a script named ''startup.script''. If it is found it then | + | When Code::Blocks finishes loading, it tries to load a script named ''startup.script''. If it is found it then executes it (no need for ''"function main()"'' inside it anymore). The user can edit this script to run arbitrary customization commands on application startup. |
− | The shipped ''startup.script'' | + | The shipped ''startup.script'' demonstrates a couple of the newest scripting features. |
+ | |||
+ | Log(_T("Running startup script")); | ||
+ | |||
+ | // #include any script plugins; this will register them too | ||
+ | // un-comment the line below to register a pointless sample plugin | ||
+ | // Include(_T("sample_plugin.script")); | ||
+ | |||
+ | // add a menu entry to edit this script | ||
+ | GetScriptingManager().RegisterScriptMenu(_T("edit_startup_script.script"), _T("Settings/-Edit startup script")); | ||
+ | |||
+ | |||
+ | == Example == | ||
+ | An example script is now shipping with Code::Blocks. Please read the last line of the startup.script above: | ||
+ | |||
+ | // add a menu entry to edit this script | ||
+ | GetScriptingManager().RegisterScriptMenu(_T("edit_startup_script.script"), _T("Settings/-Edit startup script")); | ||
+ | |||
+ | This actually binds the script named <tt>edit_startup_script.script</tt> to the menu entry <tt>"Settings/-Edit startup script"</tt>. | ||
+ | |||
+ | And don't forget that Code::Blocks conveniently allows you to edit the <tt>edit_startup_script.script</tt> at any time. All you have to do is keep SHIFT pressed while clicking on the <tt>"Edit startup script"</tt> menu item ;). | ||
+ | |||
− | |||
− | |||
− | |||
− | |||
== See also == | == See also == | ||
* [[Scripting commands]] | * [[Scripting commands]] |
Latest revision as of 12:29, 15 December 2006
When Code::Blocks finishes loading, it tries to load a script named startup.script. If it is found it then executes it (no need for "function main()" inside it anymore). The user can edit this script to run arbitrary customization commands on application startup.
The shipped startup.script demonstrates a couple of the newest scripting features.
Log(_T("Running startup script")); // #include any script plugins; this will register them too // un-comment the line below to register a pointless sample plugin // Include(_T("sample_plugin.script")); // add a menu entry to edit this script GetScriptingManager().RegisterScriptMenu(_T("edit_startup_script.script"), _T("Settings/-Edit startup script"));
Example
An example script is now shipping with Code::Blocks. Please read the last line of the startup.script above:
// add a menu entry to edit this script GetScriptingManager().RegisterScriptMenu(_T("edit_startup_script.script"), _T("Settings/-Edit startup script"));
This actually binds the script named edit_startup_script.script to the menu entry "Settings/-Edit startup script".
And don't forget that Code::Blocks conveniently allows you to edit the edit_startup_script.script at any time. All you have to do is keep SHIFT pressed while clicking on the "Edit startup script" menu item ;).