Revision as of 23:01, 24 August 2013

Scripting is no good if all you can do is use the scripting language's built-in commands only. The host application (Code::Blocks) needs to expose parts of its internals to scripts, so scripts can use and control the host.

Code::Blocks has exposed a very large chunk of its SDK to scripts. This makes scripting in Code::Blocks nearly as powerful as native code (C++).

In this page all the exported constants, functions and classes are documented as a quick reference. For detailed documentation on each function/class, refer to the Code::Blocks SDK documentation.

NOTE: Please remember that Squirrel is typeless. Data types mentioned below are only used for documentation purposes.

NOTE: Please keep in mind that if a function has default parameters in C++ (which can be ommitted), you still have to type them for scripts (for e.g. exposed wxWidgets functionality). This means you *have* to use e.g. wxFileName.GetFullPath(wxPATH_NATIVE) instead of e.g only wxFileName.GetFullPath().

The second argument (menu item) is a string containing the full menu path to create the menu item. The path separator is a slash (/). For example, the string "Settings/Sample menu/Sample item" would create the menu path "Settings->Sample menu->Sample item".

When each part of the path is evaluated, it is checked whether it starts with a number followed by a colon (:). If so then this is considered to be a menu index in the parent menu and the menu is inserted at that index instead of being appended to the menu. The number and colon are removed from the string.

If the menu item starts with a dash (-), then a separator line is prepended in the menu before the menu item (e.g. "Scripts/-Sample script").

For your convenience, all menu items created using this function have one extra functionality: if you keep the SHIFT key pressed while clicking on any of these "script menu items", instead of running the attached script, Code::Blocks will open it in the editor for you to view/edit :).

Notes:
The namespaces are accesses by prepending it's name (e.g. "IO.") to the scripting function, e.g. "IO.DirectoryExists(...)". "::" is only used when declaring the members of the namespace.
The functions in bold are going through the scripts security layer so there is no guarantee calling them will succeed. You should always examine the return value...
There exists one constant too, named allowInsecureScripts, which allow you to test whether Code::Blocks was compiled with the functions going through the security layer.

CompilerFactory

Return value

Name

Arguments in Prototype

Remarks

bool

IsValidCompilerID

(const wxString& id)

int

GetCompilerIndex

(const wxString& id)

wxString

GetDefaultCompilerID

( )

wxString

GetCompilerVersionString

(const wxString& Id)

bool

CompilerInheritsFrom

( )

wxString

Return value

Name

Arguments

Remarks

wxString

_T

const char*

basically this is the wxString constructor

wxString

_

const char*

the same as _T, but should be used for translatable strings

wxString

operator=

const wxString

wxString

operator+

const wxString

wxString

operator+

const int

wxString

operator+=

const wxString

wxString

operator+=

const int

bool

operator<

const wxString

_T("abc") < _T("cba") -> true

bool

operator<=

const wxString

bool

operator>=

const wxString

bool

operator>

const wxString

int

Find

wxString

-1 if not found

bool

Matches

wxString

not use '==' !!

void

AddChar

char

char

GetChar

int

arg1=position

bool

IsEmpty

int

Length

int

length

same as Length()

int

len

same as Length()

int

size

same as Length()

wxString

Lower

wxString

LowerCase

same as Lower()

void

MakeLower

wxString

Upper

wxString

UpperCase

same as Upper()

void

MakeUpper

wxString

Mid

int, int

arg1=position, arg2=long

wxString

Remove

int, int

arg1=position, arg2=long

void

RemoveLast

the last character

int

Replace

wxString, wxString,bool

arg3=true -> all occurrences else the first

wxString

Right

int x

return the x last characters

wxString

AfterFirst

char

not found -> _T("")

wxString

AfterLast

char

not found -> all the character string

wxString

BeforeFirst

char

not found -> all the character string

wxString

BeforeLast

char

not found -> _T("")

NOTE: Is instantiated in a script using: local my_wxstring = ::wxString();

wxArrayString

Return value

Name

Arguments

Remarks

void

Add

wxString, size_t

arg1=string, arg2=number of copies to add

void

Clear

int

GetCount

int

Index

wxString

-1 If not found

wxString

Item

int

not work with wx 2.9.x ?!

NOTE: Is instantiated in a script using: local my_wxarraystring = ::wxArrayString();

wxColour

Return value

Name

Arguments

Remarks

byte

Red

byte

Green

byte

Blue

bool

IsOk

ONLY if (wxVERSION_NUMBER < 2900)

void

Set

byte, byte, byte, byte

red, green, blue, alpha : into [0..255]

NOTE: Is instantiated in a script using: local my_wxcolour = ::wxColour();