- Qbs Manual
- General Services
- Qbs 1.6.1

# General Services

These are operations that do not fit into any of the other categories. They are automatically available in any Qbs project file or JavaScript file.

## Available Operations

### loadFile

    loadFile(filePath: string): any

Loads a JavaScript file and returns an object that contains the evaluated context of this file. This function is only available in JavaScript files. For example:

    var MyFunctions = loadFile("myfunctions.js");
    MyFunctions.doSomething();

### loadExtension

    loadExtension(extensionName: string): any

Loads a Qbs extension and returns an object that contains all functions of that extension. This function is only available in JavaScript files. For example:

    var FileInfo = loadExtension("qbs.FileInfo");
    var fileName = FileInfo.fileName(filePath);

## Extensions to JavaScript Built-in Objects

### Array.contains

    Array.contains(e: any): boolean

Returns `true` if the array contains the element `e`. Returns `false` otherwise.

### Array.containsAll

    Array.containsAll(other: any[]): boolean

Returns `true` if the array contains every element in the `other` array. Returns `false` otherwise.

### Array.containsAny

    Array.containsAny(other: any[]): boolean

Returns `true` if the array contains some element(s) in the `other` array. Returns `false` otherwise.

### Array.uniqueConcat

    Array.uniqueConcat(other: any[]): any[]

Returns a copy of this array joined with the array `other`. Duplicates that would originate from the concatenation are removed. The order of elements is preserved.

### String.contains

    String.contains(s: string): boolean

Returns `true` if the string contains the substring `s`. Returns `false` otherwise.

### startsWith

    String.startsWith(s: string): boolean

Returns `true` if the string starts with the substring `s`. Returns `false` otherwise.

### endsWith

    String.endsWith(s: string): boolean

Returns `true` if the string ends with the substring `s`. Returns `false` otherwise.

## Console API

Qbs provides a subset of the non-standard Console API available in most ECMAScript runtimes.

The output of each of these functions will only be displayed if the logging level is at least the level which the function outputs at. Logging levels from lowest to highest are: 'error', 'warning', 'info', 'debug', and 'trace'. The default is 'info'.

Warning: The contents of this section are subject to change in order to align with future standardization processes.

### console.debug

    console.debug(s: string): void

This method is an alias for `console.log()`.

### console.error

    console.error(s: string): void

Logs an `error` level message. Outputs to stderr when the logger output is a terminal. The string will be prefixed with `"ERROR: "` and colored red when the logger output is a color-capable terminal.

### console.info

    console.info(s: string): void

Logs an `info` level message. Outputs to stdout when the logger output is a terminal.

### console.log

    console.log(s: string): void

Logs a `debug` level message. Outputs to stderr when the logger output is a terminal.

### console.warn

    console.warn(s: string): void

Logs a `warning` level message. Outputs to stderr when the logger output is a terminal. The string will be prefixed with `"WARNING: "` and colored yellow when the logger output is a color-capable terminal.