Skip to content
Private alpha
Documentation — Argile — language reference

Documentation

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

EnglishFrenchRust
integer, intentieri64 (overflows detected)
realréel, reelf64
stringchaîne, chaineString
boolean, boolbooléen, booleenbool
list<T>liste<T>, liste de TVec<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.

ControlsPropertiesMethods
Label, Button, Grouptext
Text field, Text areavalue (string), placeholder, read_only
Number field, Slider, Progress barvalue (real), min, max
Check box, Switchtext, checked (boolean)
Selector, Drop-down list, Listindex, value (read-only)add(text), insert(position, text), remove(position), clear(), count(), item(position)
Tablerowadd_row(list), remove_row(position), clear(), row_count(), cell(row, column), set_cell(row, column, text)
Date fieldvalue (YYYY-MM-DD)
Imagefile
Linktext, 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().

MethodFrenchEffect
new()nouvelleclears the current record
load(key)chargerloads a record; returns false if it does not exist
save()enregistrerinserts or updates the current record
delete()supprimerdeletes the current record
first(), next(), previous(), last()premier, suivant, precedent, derniergo through the records; return false past the last one
count()nombrenumber 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

FamilyEnglishFrench
Dialoginfo, warning, error, confirm, notify, logmessage, avertissement, erreur, confirmer, notifier, journal
Stringsuppercase, lowercase, trim, contains, starts_with, ends_with, replace, substring, find, split, join, repeat, lengthmajuscules, minuscules, sans_espaces, contient, commence_par, finit_par, remplacer, sous_chaine, position, decouper, joindre, repeter, longueur (or taille)
Conversionsto_integer, to_real, to_string, is_numericvers_entier, vers_reel, vers_chaine, est_numerique
Mathabs, 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_betweendate_du_jour, heure_actuelle, maintenant, ajouter_jours, ecart_jours
Systemopen_url, copy, language, set_language, translate("key"), sleep(ms), quitouvrir_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.