# Class: System

## System()

#### new System()

MaiaScript system library.

Source:
  - System.js, line 24

### Methods

#### base64EncodeUnicode(str) → {string}

Convert Unicode caracters to Latin1.

##### Parameters:

Name | Type | Description
--- | --- | ---
`str` | string | Unicode string.

Source:
  - System.js, line 39

##### Returns:

The Unicode string converted to Latin1.

Type
  string

#### createCSV(csvData, recordSeparator, header) → {string}

Converts an array to a CSV file, using the character indicated as the column separator.

##### Parameters:

Name | Type | Description
--- | --- | ---
`csvData` | array | CSV data.
`recordSeparator` | string | The separator characters.
`header` | array | Column descriptors.

Source:
  - System.js, line 55

##### Returns:

The CSV file data.

Type
  string

#### downloadFile(fileName, fileData, mimeType)

Download a file.

##### Parameters:

Name | Type | Description
--- | --- | ---
`fileName` | string | File name.
`fileData` | string | Data to save.
`mimeType` | string | Mime type (default: 'text/plain').

Source:
  - System.js, line 99

##### Returns:

The file is downloaded.

#### loadCSV(inputFile, numberOfHeaderLines, recordSeparator, allowRepeatChar, doEval) → {array}

Loads a CSV file and converts it to an array, using the character indicated as the column separator.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputFile` | string | CSV file.
`numberOfHeaderLines` | number | Number of header lines and column descriptors to ignore.
`recordSeparator` | string | The separator characters.
`allowRepeatChar` | boolean | The separator character can be repeated (for formatting).
`doEval` | boolean | Run core.eval before adding the column to the record.

Source:
  - System.js, line 152

##### Returns:

The array containing the parts of the CSV or NULL if the CSV record is not well formed.

Type
  array

#### log(text)

Displays a message in the console.

##### Parameters:

Name | Type | Description
--- | --- | ---
`text` | string | Text to display.

Source:
  - System.js, line 139

#### parseCSV(csvData, numberOfHeaderLines, recordSeparator, allowRepeatChar, doEval) → {array}

Converts a CSV record to an array, using the character indicated as the column separator.

##### Parameters:

Name | Type | Description
--- | --- | ---
`csvData` | string | CSV file data.
`numberOfHeaderLines` | number | Number of header lines and column descriptors to ignore.
`recordSeparator` | string | The separator characters.
`allowRepeatChar` | boolean | The separator character can be repeated (for formatting).
`doEval` | boolean | Run core.eval before adding the column to the record.

Source:
  - System.js, line 121

##### Returns:

The array containing the parts of the CSV or NULL if the CSV record is not well formed.

Type
  array

#### print(text)

Displays a message in the console.

##### Parameters:

Name | Type | Description
--- | --- | ---
`text` | string | Text to display.

Source:
  - System.js, line 183

#### printf(fmt, arguments) → {string}

Displays a formated string based on format specifiers passed to the function.

##### Parameters:

Name | Type | Description
--- | --- | ---
`fmt` | string | A string containing format specifiers.
`arguments` | object | Objects to be formatted.

Source:
  - System.js, line 193

##### Returns:

A formatted string based on format specifiers passed to the function.

Type
  string

#### println(text)

Displays a message on the console and advances the cursor to the next line.

##### Parameters:

Name | Type | Description
--- | --- | ---
`text` | string | Text to display.

Source:
  - System.js, line 201

#### readDataFromStorage(obj, callBack)

Reads data from browser storage.

##### Parameters:

Name | Type | Description
--- | --- | ---
`obj` | object | Object to store data: {'key': value, 'key': value, ...}
`callBack` | object | Callback function to call after access to storage.

Source:
  - System.js, line 211

##### Returns:

Data from storage.

#### require(moduleName) → {object}

Imports a native module.

##### Parameters:

Name | Type | Description
--- | --- | ---
`moduleName` | string | Module name.

Source:
  - System.js, line 229

##### Returns:

The native module reference.

Type
  object

#### showConfirmDialog(text) → {string}

Displays a message in a dialog box asking for confirmation.

##### Parameters:

Name | Type | Description
--- | --- | ---
`text` | string | Text to display.

Source:
  - System.js, line 242

##### Returns:

User choice.

Type
  string

#### showInputDialog(text, defaultText) → {string}

Displays a message in a dialog box asking you to enter text.

##### Parameters:

Name | Type | Description
--- | --- | ---
`text` | string | Text to display.
`defaultText` | string | Default text to display in the text box.

Source:
  - System.js, line 252

##### Returns:

User-typed text.

Type
  string

#### showMessageDialog(text)

Displays a message in a dialog box.

##### Parameters:

Name | Type | Description
--- | --- | ---
`text` | string | Text to display.

Source:
  - System.js, line 260

#### source(inputFile) → {object}

Load a MaiaScript module.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputFile` | string | Module name.

Source:
  - System.js, line 269

##### Returns:

The MaiaScript module loaded.

Type
  object

#### uploadFile(fileObject, callBack)

Upload a file.

##### Parameters:

Name | Type | Description
--- | --- | ---
`fileObject` | object | File data structure.
`callBack` | function | callback to be called when the file is loaded.

Source:
  - System.js, line 302

##### Returns:

The file is uploaded.

#### writeDataToStorage(obj, callBack)

Writes data to storage.

##### Parameters:

Name | Type | Description
--- | --- | ---
`obj` | object | Object to store data: {'key': value, 'key': value, ...}
`callBack` | object | Callback function to call after access to storage.

Source:
  - System.js, line 328

##### Returns:

Data written to storage.

#### (inner) init()

Creates the attributes of the class.

Source:
  - System.js, line 30