Skip to content

The Console, Dialogs and Other Utilities

Phil Beauvoir edited this page Feb 28, 2020 · 15 revisions

Table of contents


The Console

Output can be sent to jArchi's Console window using the following functions:

console.show();
console.hide();
console.setText("Clear previous text and display this text");
console.log("Hello World");
console.log(object);
console.log("One thing: ", object, another, ...);
console.error(error);
console.clear();
console.setTextColor(redValue, greenValue, blueValue);
console.setDefaultTextColor();

Prompt, Alert and File Dialogs

Alert

window.alert("Hello World");

Confirm

var response = window.confirm("Are you sure?");

Prompt

var name = window.prompt("Please enter your name", "Default Name");

Prompt to open a file

var filePath = window.promptOpenFile({ title: "Open Model", filterExtensions: [ "*.archimate" ], "default.archimate" });

Prompt to open a directory

var dirPath = window.promptOpenDirectory({ title: "Open Folder", "/defaultPath" });

Prompt to save a file

var filePath = window.promptSaveFile({ title: "Save Model", filterExtensions: [ "*.archimate" ], "default.archimate" });

Including Other Script Files

You can include other Archi script or JavaScript files:

load(absolute_path)
load(url)

There is no support for relative locations, so the following format is used:

load(__DIR__ + "path/file.js")
__DIR__ contains the absolute path of the directory containing the current script.
__FILE__ contains the absolute path of current script.
__LINE__ contains the line number in which __LINE__ is used.

Other Features

ACLI arguments

If you are running a jArchi script from the Archi Command Line Interface (ACLI) you may wish to provide additional command line arguments and retrieve these from jArchi. For example you can run a jArchi script like this: