Argile — language reference
Argile is Khnoum's scripting language. It reads like pseudo-code, in English or French (the two can be mixed), and ignores case. It is checked as you type in the workshop, then transpiled to Rust.
procedure Discount(amount: real, rate: real = 0.1): real
if amount > 1000 then
return amount * (1 - rate)
end
return amount
end
// In a button's click:
if trim(SAI_Nom.value) = "" then
error("The name is required.")
return
end
LIB_Total.text = "Total: " + Discount(NUM_Montant.value) + " €"
Types
| English | French | Rust |
|---|---|---|
integer, int | entier | i64 (overflows detected) |
real | réel, reel | f64 |
string | chaîne, chaine | String |
boolean, bool | booléen, booleen | bool |
list<T> | liste<T>, liste de T | Vec<T> |
Implicit conversions: integer → real; any simple value → string when a string is expected
(LIB_Total.text = total). The others go through to_integer, to_real, to_string,
floor…
Statements
var x: integer = 0 var x = 0 (type inferred from the value)
const VAT = 0.2
x = 3 x += 1 x -= 1 x *= 2 x /= 2
if c then … else if d … else … end si c alors … sinon si d … sinon … fin
if c then statement (short form, without "end")
while c do … end tant que c faire … fin
for i = 1 to 10 step 2 do … end pour i de 1 à 10 pas 2 faire … fin
for each e in list do … end pour chaque e dans liste faire … fin
switch v selon v
case 1, 2: … cas 1, 2: …
default: … autre cas: …
end fin
return value break continue renvoyer sortir continuer
var is also written variable, const is also written constante. function
(fonction) is a synonym of procedure (procédure), and retourner of return
(renvoyer). for i from 1 to 10 is accepted as well as for i = 1 to 10.
end may be followed by the word that opens the block (end if, end while). Comments are
written // … or /* … */.
Operators
+ - * / (division / always gives a real), div (integer division), mod or %;
comparisons = == <> != < <= > >=; logic and / et, or / ou, not / non; true / vrai,
false / faux. + concatenates as soon as one of its sides is a string.
Lists
Positions start at 1: l[1] is the first item; an out-of-range position is a runtime
error. Methods: add, insert, remove, clear, count (or size), contains,
index_of — in French ajouter, inserer, supprimer, vider, nombre (or taille),
contient, rang.
Windows and controls
In a window's code, its controls are named directly (SAI_Nom.value); those of another
window take a prefix (FEN_Clients.SAI_Nom.value), and mywindow (MaFenêtre) refers to
the current window.
Common properties: name (read-only), visible, enabled, x, y, width, height,
tooltip; method focus(). In French: nom, visible, actif, x, y, largeur,
hauteur, bulle.
| Controls | Properties | Methods |
|---|---|---|
| Label, Button, Group | text | |
| Text field, Text area | value (string), placeholder, read_only | |
| Number field, Slider, Progress bar | value (real), min, max | |
| Check box, Switch | text, checked (boolean) | |
| Selector, Drop-down list, List | index, value (read-only) | add(text), insert(position, text), remove(position), clear(), count(), item(position) |
| Table | row | add_row(list), remove_row(position), clear(), row_count(), cell(row, column), set_cell(row, column, text) |
| Date field | value (YYYY-MM-DD) | |
| Image | file | |
| Link | text, url |
In French: texte, valeur, indicatif, lecture_seule, indice, ligne, fichier
(checked is valeur); ajouter, inserer, supprimer, vider, nombre, element,
ajouter_ligne, supprimer_ligne, nombre_lignes, cellule, modifier_cellule.
Windows: title (titre), width (largeur), height (hauteur), is_open (ouverte,
read-only), open() (ouvrir), close() (fermer).
Data
Each entity has a current record: Client.Nom = SAI_Nom.value, then
Client.save().
| Method | French | Effect |
|---|---|---|
new() | nouvelle | clears the current record |
load(key) | charger | loads a record; returns false if it does not exist |
save() | enregistrer | inserts or updates the current record |
delete() | supprimer | deletes the current record |
first(), next(), previous(), last() | premier, suivant, precedent, dernier | go through the records; return false past the last one |
count() | nombre | number of records |
Relation rules (parent record exists, deletion forbidden, cascading or cleared) and required
or unique fields are checked on every save() and delete(), including between two
different sources; a rule that is not respected is a runtime error.
Reports
ETAT_Factures.preview() (apercu), .print() (imprimer),
.export("invoices.pdf") (exporter): the format follows the extension — pdf, odt,
ods, odp, odg, docx, xlsx or pptx.
Native functions
| Family | English | French |
|---|---|---|
| Dialog | info, warning, error, confirm, notify, log | message, avertissement, erreur, confirmer, notifier, journal |
| Strings | uppercase, lowercase, trim, contains, starts_with, ends_with, replace, substring, find, split, join, repeat, length | majuscules, minuscules, sans_espaces, contient, commence_par, finit_par, remplacer, sous_chaine, position, decouper, joindre, repeter, longueur (or taille) |
| Conversions | to_integer, to_real, to_string, is_numeric | vers_entier, vers_reel, vers_chaine, est_numerique |
| Math | abs, min, max, round, floor, ceil, sqrt, pow, random, if_else(condition, a, b) | abs, min, max, arrondi, partie_entiere, plafond, racine, puissance, aleatoire, si_sinon |
| Dates (YYYY-MM-DD) | today, current_time, now, add_days, days_between | date_du_jour, heure_actuelle, maintenant, ajouter_jours, ecart_jours |
| System | open_url, copy, language, set_language, translate("key"), sleep(ms), quit | ouvrir_url, copier, langue, changer_langue, traduire, attendre, quitter |
The accented French names are accepted too (sous_chaîne, vers_réel, aléatoire,
écart_jours…). The reference, with each function's signature, is also in the workshop's
Scripts tab.