📗
Windows 96 Developer Documentation
  • Welcome
  • information
    • Important notes
      • Prerequisites
      • Best practices
      • Deprecated APIs
    • API typings
  • Getting Started
    • Creating your first app
    • Some examples
      • 1. A very basic app
  • API USAGE
    • GUI
      • Creating a window
  • API
    • File System
  • WRT
    • Introduction
    • The module system
    • API reference
      • WRTEnvEnum
      • WRTParameters
Powered by GitBook
On this page
  • w96.WRT
  • WRT.run(script: String, params?: WRTParameters): Promise<any>
  • WRT.runFile(path: String, params?: WRTParameters): Promise<any>

Was this helpful?

  1. WRT

API reference

The API reference for WRT.

PreviousThe module systemNextWRTEnvEnum

Last updated 3 years ago

Was this helpful?

w96.WRT

WRT.run(script: String, params?: ): 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:

const scriptResult = await w96.WRT.run("return await FS.readstr('c:/system/credits.txt')");
// Returns the contents of c:/system/credits.txt
// 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!"
}
// Returns the current working directory, which has been preset in the parameters.
await w96.WRT.run("console.log(current.cwd)", {
    cwd: "c:/system"
});

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:

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

WRT.runFile(path: String, params?: ): Promise<any>

WRTParameters
WRTParameters