Difference between revisions of "Startup script"

From Code::Blocks
m (removed extra category)
(Updated info for latest changes)
 
(One intermediate revision by the same user 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 tries to execute the ''"function main()"'' inside it (if there). The user can edit this script to run arbitrary customization commands on application startup.
+
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'' just logs its presence in the application's debug log.
+
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 ;).
 +
 
  
function main()
 
{
 
    Log(_T("Running startup script"));
 
}
 
  
 
== 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 ;).


See also