mozdev.org

Delphi 

projects:
resources:
<- Back

Bridge Classes: TJSScript

This class provides methods for easy compilation, execution, serialization, and deserialization of JavaScript code. Methods are also available for loading, saving, and streaming both raw and compiled code. This class provides streaming for compiled code only, however, since streaming the raw JavaScript code is trivial.

Properties
  • Code: String

    Reads and writes the code contained in the class. This property may be empty, even though Compiled is true.
  • Compiled: Boolean

    When true the class contains an image of the compiled JavaScript in Code.
Methods
  • constructor Create; overload;

    Creates an empty class with no JavaScript.
  • constructor Create(const ACode: String); overload;

    Automatically populates the Code property with the JavaScript in ACode.
  • constructor Create(const ACode: String; AEngine: TJSEngine); overload;

    Automatically populates the Code property, then compiles it using the provided TJSEngine instance.
  • procedure Compile(AEngine: TJSEngine);

    Compiles the contained JavaScript and sets Compiled to true.
  • procedure Execute(AEngine: TJSEngine); overload;

    Executes the JavaScript using the provided TJSEngine instance in the global scope.
  • procedure Execute(AEngine: TJSEngine; AScope: TJSObject); overload;

    Executes the JavaScript using the provided TJSEngine instance in the specified scope.
  • procedure LoadCompiled(const AFile: String; AEngine: TJSEngine);

    Loads the precompiled JavaScript code from the specified file. The Compiled property is set to true, and the Code property is emptied.
  • procedure LoadCompiledFromStream(AStream: TStream; AEngine: TJSEngine);

    Loads the precompiled JavaScript code from the specified stream. The Compiled property is set to true, and the Code property is emptied.
  • procedure LoadRaw(const AFile: String);

    Loads raw (text) JavaScript from the specified file. The Compiled property is set to false.
  • procedure SaveCompiled(const AFile: String; AEngine: TJSEngine);

    Attempts to save the compiled JavaScript to the specified file. If the JavaScript has not yet been compiled, it will attempt to do so.
  • procedure SaveCompiledToStream(AStream: TStream; AEngine: TJSEngine);

    Saves the compiled JavaScript to the specified stream. If the JavaScript has not yet been compiled, it will attempt to do so.
  • procedure SaveRaw(const AFile: String);

    Saves the raw (text) JavaScript to the specified file.

The delphi project can be contacted through the mailing list or the member list.
Copyright © 2000-2017. All rights reserved. Terms of Use & Privacy Policy.