Script file

Diese Dokumentation ist veraltet

Die umfangreichste und aktuellste Dokumentation ist die von Banana Buchhaltung Plus : Probieren Sie es sofort aus!

In this article

The script file is a ECMA-262 Javascript compliant script file.

The script file has to contain:

  • Script's attributes, inserted through tags in comment's lines at the beginning of the file, and to define the function "function exec(string)". The script's attributes give information about the script, like it purpose, description and so on.
     
  • The function exec() that is called every time you execute the script.
    It has one argument, the requested input data as string.
    The result is returned as a string. The format of the returned string have for import scripts to match the tag @outputformat, for other tasks the format is not determined. Errors are notified through exceptions (clause throw), or just by returning a string beginning with "@Error:".
     
  • The script has to be saved in UTF-8 without BOOM

For a list of supported functions, objects and properties see: Qt4.8 ECMAScript Reference, Qt5.3 ECMAScript Reference.

The script global environment provides a collection of predefined objects that the Javascript program can reference in order to interact with Banana Accounting. Those objects are described under Banana Script API.

Example:

// @id = ch.banana.script.helloworld
// @version = 1.0
// @publisher = Banana.ch SA
// @description = Hello world
// @task = app.command
// @inputdatasource = none
// @timeout = -1

/**
 * Hello world example for Banana Accounting.
 */
function exec(inData) {
    Banana.Ui.showInformation("", "Hello World");
    
    if (Banana.document) {
       var fileName = Banana.document.info("Base","FileName");
       Banana.Ui.showInformation("Current document", fileName);
    }
}