Banana.Application

Documentation • 4 minutes de lecture
Dans cet article

Banana.Application represents the interface to the program and can be accessed through Banana.application.

Properties

 apiVersion

Returns the version of the implemented Js Banana API in the form of "1.2.2".

For the different versions see API Versions and the changelog.

Javascript
Copy


var qtVersion = Banana.application.apiVersion; // Returns "1.2.2"

 

 isExperimental

Returns true if the application is an experimental version.

Javascript
Copy


var isExperimental = Banana.application.isExperimental;

 isInternal

Returns true if the application is an internal version.

Javascript
Copy


var isInternal = Banana.application.isInternal;

 

 license

Returns an object containing informations about the active license, or null if no license is active.

The properties of the returned object are:

  • licenseType (string):  one of "professional" or "advanced"
  • exprirationDate (string):  null if no expiration, or the expiration in form of "yyyy-mm-dd"
  • language (string):  "all" if all languages are available, or the licensed language code, i.e: "it", "nl", ...
  • isWithinMaxFreeLines(bool): (from version 10.0.7)  true if you have not yet passed the limits of the demonstration mode. For accounting applications: 70 Transaction rows, 20 Budget rows, 20 rows for added table. For other applications (Invoices, Inventory, Addresses) 20 rows for any table.
    isWithinMaxFreeLines returns always false if the license type is Advanced, because the rows limit is not checked
Javascript
Copy


var license = Banana.application.license;

// Example:
// { 
//    "licenseType": "professional",
//    "expirationDate": "2022-10-24",
//    "language":"all",
//    "isWithinMaxFreeLines":true
// }

if (!Banana.application.license || Banana.application.license.licenseType !== "advanced") {
   Banana.document.addMessage("This extension requires Banana Accounting+ Advanced");
}

 

 qtVersion

Returns the version of the used qt framework in the form of "6.4.1".

Javascript
Copy


var qtVersion = Banana.application.qtVersion; // Returns "6.4.1"

 

 serial

Returns the serial of the application in the form of "100010-320".

Javascript
Copy


var serial = Banana.application.serial; // Returns "100012-320"

 

 version

Returns the version of the application in the form of "10.0.12".

Javascript
Copy


var version = Banana.application.version;

 

locale

Returns the locale of the application in the form of "language_country", where language is a lowercase, two-letter ISO 639 language code, and country is an uppercase, two- or three-letter ISO 3166 country code.

Javascript
Copy


var locale = Banana.application.locale;

 

progressBar

Returns an object of type ProgressBar used to give the user an indication of the progress of an operation and the ability to cancel it.

Javascript
Copy


var progerssBar = Banana.application.progressBar;

 

Methods

 

 addMessage(msg [, idMsg])

Adds the message msg to the application. The message is showed in the pane "Messages", and in a dialog if the application option "Show Messages" is turned on.

If idMsg is not empty, the help button calls an url with script's id and message's id (idMsg) as parameters.

Javascript
Copy


Banana.application.addMessage("Hello World");

 

See also: Table.AddMessage, Row.AddMessage, Document.AddMessage.

 

clearMessages()

Clears all the messages showed in the pane "Messages".

Javascript
Copy


Banana.application.clearMessages();

 

 getMessages()

Returns all messages showed in the pane "Messages".

Javascript
Copy

let msgs = Banana.application.getMessages();
for (let i = 0; i < msgs.length; ++i) {
   let msg = msgs[i];
   Banana.console.log("Error: " + msg.message);
}

The message object contains following properties:

  • message: the message in the application language;
  • referer:  a string describing to which the message refer (usually the file name);
  • level: the level of the message as string, can be one of "debug", "info", "warning", "debug";
  • helpId: the help id of the message, used to link to the documentation;
  • fileUuid: an id as string that uniquely identifies the file to which the message refer or empty;
  • fileName: the file name that identifies the file to which the message refer or empty;
  • tableName: the table name to which the message refer, or empty;
  • rowNr: the row number as number to which the message refer, or -1;
  • columnName: the column name to  which the message refer to, or empty;

See also: Document.getMessages.

showMessages([show])

Enable or disable the notification of new messages through the message dialog.

Javascript
Copy


Banana.application.showMessages(); // Next messages are showed to the user through the message dialog.
Banana.application.showMessages(false); // Next messages will not pop up the message dialog.

 

 openDocument(ac2FilePath [, password] [, title])

Opens the ac2 file located in filePath and returns an Object of type Banana.Document or undefined if the file is not found. The path can be relative, in this case the base directory is the path of the current document.

If the path is empty or contains a "*" or a "?" an open file dialog is showed to the user, and the title is used in the caption of the file open dialog.

With this function you can also open ISO 20022 and MT940 files, in this case a cash book with the transactions of the file is returned.

Javascript
Copy


var file1 = Banana.application.openDocument("*.*");
if (!file1)
   return;

var file2 = Banana.application.openDocument("c:/temp/accounting_2015.ac2");
if (!file2)
   return;

 

Aidez-nous à améliorer la documentation

Nous serions heureux de recevoir des commentaires sur l'amélioration de cette page.

Dites-nous quel thème doit être mieux expliqué ou comment clarifier un sujet.

Partager cet article: Twitter | Facebook | LinkedIn | Email