# API reference

## `w96.WRT` <a href="#w-96-sys-reg" id="w-96-sys-reg"></a>

### `WRT.run(script: String, params?:` [`WRTParameters`](https://windows96.gitbook.io/dev-docs/wrt/api-reference/wrtparameters)`): Promise<any>`

**Description**: Runs a script under WRT and returns the result of the evaluation. The result is a `Promise`, since WRT scripts are ran asynchronously by default.

**Examples:**

```javascript
const scriptResult = await w96.WRT.run("return await FS.readstr('c:/system/credits.txt')");
// Returns the contents of c:/system/credits.txt
```

```javascript
// A simple module include demonstration
// Includes can use relative paths, unlike the standard Windows 96 FS functions.

/* ======= code to eval with WRT ======= */
const code = `const myModule = await include("c:/test.js");

console.log(myModule.something());`;

await w96.WRT.run(code);

/* ======= code for c:/test.js ======= */

module.exports = {
    something: ()=>"Hello, world!"
}
```

```javascript
// Returns the current working directory, which has been preset in the parameters.
await w96.WRT.run("console.log(current.cwd)", {
    cwd: "c:/system"
});
```

### `WRT.runFile(path: String, params?:` [`WRTParameters`](https://windows96.gitbook.io/dev-docs/wrt/api-reference/wrtparameters)`): Promise<any>`

**Description**: Runs a script file under WRT and returns the result of the evaluation. Like `WRT.run`, the result is a `Promise` since its ran asynchronously.

**Examples:**

```javascript
// Runs a script file located in c:/user
await w96.WRT.runFile("c:/user/test.js");
```
