Script attributes

Cette documentation est dépassée

La documentation la plus complète et actualisée est celle de Banana Comptabilité Plus : Essayez-le maintenant

In this article

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".

 

Tag Required

Value 1)

Description

@id

Yes

Identification in form of reversed Internet domain name

Ex.: ch.banana.script.import.bbank

If two scripts have the same id only the first one is loaded. The order in which the scripts are loaded is: application folder, all user folder and user folder.

The id is also used to save and restore script settings.

@version   Version of the script This is used to check if newer version of the script exist. This apply only to the scripts published by Banana.ch.
@pubdate   The publication date in the format YYYY-MM-DD  
@publisher   The publisher of the script  
@description[.lang] Yes The name or description of the script

This text will be displayed in the dialogs.

This tag is localisable.

@task  

One of following values:
import.rows
import.transactions
import.accounts
import.categories
import.exchangerates
import.vatcodes
export.file
export.rows
export.transactions
app.command

This value define the purpouse of the script, and determine in which dialog or menu the script is visible.
@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
@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.
@inputdatasource  

One of the following values:
none
openfiledialog
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), 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.
@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.
@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.
@encoding  

The encoding of the input data.

One of the following values:
latin1
utf-8
iso 8859-1 to 10
...

The encoding to use to read the input file.

For a complete list see QTextCodec

@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.
@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.

 

1) Default values are listed in bold.

2) Function not yet available

 

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);
    }
}