Banana (Objects)

Documentation •
Dans cet article

Banana is the namespace (object) through which all Banana script's methods, class and objects are accessible.

Banana Properties


The object Banana.application represents the running application.


The object Banana.console is used to send messages to the debug script.


The class Banana.Converter contains methods useful to convert data from and to various formats.


The object Banana.document represents the document currently open in the application. It contains base properties and methods, see Banana.Document (Base), and if the document represents an accounting document that contains additional accounting's properties and methods, see Banana.Document (Accounting). If any document is opened this object is of type Undefined.


The class Banana.IO is used to read and write files.


The class Banana.Report enables you to create reports, preview and print them in Banana Accounting.


The object Banana.script is used to get information about the running script.


The class Banana.SDecimal contains methods useful for decimal math calculation.


The class Banana.Test contains methods to run test units.


The class Banana.Ui contains predefined dialogs to interact with the user, and methods to load dialogs from .ui or .qml files.


The class Banana.Xml contains methods to parse and access Xml data.

Banana Methods

Banana.compareVersion(v1, v2)

Compares two version strings. Version strings are in the form of "x.y.w.z". Returns 0 if v1 and v2 are equal, -1 if v2 is later and 1 if v1 is later.

var requiredVersion = "8.0.5";
if (Banana.compareVersion && Banana.compareVersion(Banana.application.version, requiredVersion) >= 0)
   Banana.Ui.showInformation("Message", "More recent or equal than version " + requiredVersion);
   Banana.Ui.showInformation("Message", "Older than version " + requiredVersion);


The method Banana.include(path) includes a javascript file evaluating it.
If an error occurs, i.e. the file is not found or is not valid, the method throws an exception.

The path is relative to the current script being executed, if no protocol is specified. 

The application searches for include files in this order:
1) In the same directory as the current file.
2) In the directories of the currently opened include files, in the reverse order in which they were opened. 

If a protocol is defined, depending on the protocol, the path is relative to the main script's folder, the document's folder or the name of a document attacched to the current file.
- <relative_path_to_current_script>/<file_name>
- file:script/<relative_path_to_main_script>/<file_name>
- file:document/<relative_path_to_file>/<file_name>
- documents:<attachment_name>

Scripts included through the method Banana.include(path) can include other scripts through the method Banana.include(path), but not via the script's attibute @includejs. The method Banana.include(path) garantees that each distinct script is evaluated once, even if it is included more than one time from differents scripts. Path can contain ".." (parent folder), in the case the destination path is outside the main script's folder, the method will throw a security exception.

Banana.include("cashflowlib.js"); // a js file in the same folder
Banana.include("folder/cashflowlib.js"); // a js file in a subfolder
Banana.include("file:document/cashflowlib.js"); // a js file stored in the document table


Dites-nous comment nous pouvons mieux vous aider
Si les informations contenues dans cette page ne correspondent pas à ce que vous recherchez, ne sont pas suffisamment claires ou ne sont pas à jour, faites-nous savoir.

Partager cet article: Twitter | Facebook | LinkedIn | Email