In this article
At the beginning at the script there should be a part that define the Extension's Attribute (See Extension File Structure).
// @api = 1.0
// @id = ch.banana.apps.example.docfilepath
// @description = Hello world
// @task = app.command
// @doctype = nodocument
// @publisher = Banana.ch SA
// @pubdate = 2015-05-12
// @inputdatasource = none
// @timeout = -1
The attribute is a commented text line
- Start with //
- Followed by the attribute that start with @
- Followed by the " = " and the value
Tags defines the purpose (import, export, extract, ...), the name displayed in the dialogs, the kind of data it expect to receive, the kind of data it returns, and other information of the script. Tags are inserted at the beginning of the script in comment's lines though the following syntax: "// @tag-name = tag-value".
Attribute list
Attribute name | Required | Value 1) | Description |
@api | Required | The required API version. Available API versions: | Define the required API to be executed in the form of MAIN_VERSION.SUB_VERSION The implemented API in the application have to be equal or newer. See the page API Versions for a list of implemented versions, and the Changelog page for the list of changes in the API. |
@contributors | List of contributors separated by ';' | This attribute contains the list of people that contribute to the developing of the Banana Extensions. | |
@description[.lang] | Required | The name or description of the script | This text will be displayed in the dialogs. This tag is localizable. |
@docproperties | any text | Define a property the script is written for.
It works in combination of the @docproperties and @visibility | |
@doctype | Required | nodocument * XXX.* XXX.YYY !XXX.YYY ... | Define the type of document the script is written for. nodocument = doesn't require an open document, the add-on is always visible
300.* = All productivities App The sign "!" before the file type of the file will exclude the indicate type. The above codes can be combined together like the following examples: 100.130 = for double entries with VAT and with foreign currencies |
@exportfilename | A string defining the name of the file where to export the data. | If the string contains the text <Date>, it will be replaced by the current date in the format of yyyyMMdd-hhmm. | |
@exportfiletype | A string defining the type of data exported txt | This parameter is used for export scripts, it defines the type of exported data and it is used for the extension in the save file dialog. | |
@id | Required | An identification of the script | It is used when setting and reading the preferences. In order to avoid duplicate banana.ch use the following scheme. country.developper.app.domain.name for example: ch.banana.app.patriziato.consuntivopersubtotali |
@includejs | Relative path to a javascript .js file to load before the execution of the script. | Include the javascript file. Every function and object defined in the file are then available to the current script. The application searches for include files in this order:
Each distinct included script is evaluated once, even if it is included more than one time from different scripts. | |
@inputdatasource | One of the following values: none openfiledialog opendirdialog fixedfilepath 2) | With this attribute you can specify if you don't need to input data, if you want the user to select a file to import (openfiledialog), a directory to import (opendirdialog), or if you want to get a file which path is defined in @inputfilepath. If you set fixedfilepath the program will ask the user the permission to open this file, the user's answer will be saved for the next execution. | |
@inputencoding | The encoding of the input data. One of the following values: | The encoding used to read the input file (for import apps). If the attribute is empty or not defined, the application try to decode the input data with utf-8, if it fails, the application decode the input data with latin1. For a complete list see QTextCodec | |
@inputfilefilter[.lang] | The file filter for the open file dialog Ex.: Text files (*.txt *.csv);;All files (*.*) | This value describes the file filters you want to show in the input file dialog. If you need multiple filters, separate them with ';;' for instance. This tag is localizable. | |
@inputfilepath | The file to read for the input data | If the script has the value fixedfilepath as @inputdatasource, you can define here the path of the file to load. | |
@inputformat | One of the following values: text ac2 | If "text" the filter receive the selected file in inData as a text. If "ac2" the filter receive the selected file in inData as a Banana.Document object. | |
@outputencoding | The encoding of the input data. One of the following values: | The encoding used to write the output file (for export apps). For a complete list see QTextCodec | |
@outputformat | One of the follwing values: tablewithheaders transactions.simple | If the script has an import tasks this value define the format of the returned value. The format transaction.simple contains the transaction as income / expenses. For details of the formats see Import data from a txt file. | |
@pubdate | Required | The publication date in the format YYYY-MM-DD | This publication date is also used for scripts published by Banana.ch to check if newer version exist. |
@publisher | The publisher of the script | ||
@task | Required | One of following values: accounting.payment app.command create.init export.file export.rows export.transactions import.rows import.transactions import.accounts import.categories import.exchangerates import.vatcodes report.general report.customer.invoice report.customer.statement report.customer.reminder | This value define the purpuse of the script, and determine in which dialog or menu the script is visible.
|
@testapp | Path and name of the test(s) app. The path can be relative or absolute, contains wildcards or be a list of files separated by ';'. Default is './test/*.test.js | This can be used if there is a test app and the path to the test app is different to the default path. If the path is not in the script's folder, a confirmation dialog is showed to the user before running the tests. Since Banana 9.0.4 | |
@testappversionmin @testappversionmax | Only for test cases. Minimum and mximum application's version to whitch the test is applicable. | ||
@timeout | The timeout for the script in milliseconds, default is 2000 (2 seconds). If you set -1 the timeout is disabled and the application allow you to abort it though a progress bar. | If the script takes longer than this value to finish, it will be aborted and a message showed. If you have a script with a very long run time, you can increase the timeout or set it to -1. | |
@visibility | always never extentionlinked | Define if the extension will be added to the menu Extensions.
from version 10.0.7 |
1) Default values are listed in bold.
2) Function not yet available
Example:
// @api = 1.0
// @id = ch.banana.apps.example.docfilepath
// @description = Hello world
// @task = app.command
// @doctype = nodocument
// @publisher = Banana.ch SA
// @pubdate = 2015-05-12
// @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);
}
}