Scripts allow us to write programs for execution within Manifold using a variety of built in and supported languages. Scripts can be edited when they are opened in a Script window. In addition, JavaScript, IronPython and IronRuby can be edited and executed from the Command window, using the Command window as a REPL (Read-Eval-Print Loop) console.
Must read info: All programmers should review the API Documentation online. The API Documentation provides total details on the API and also provides hundreds of examples, many of which are provided side-by-side in three versions, in C#, in VBScript and in IronPython, for example:
The above example connects to an IMG file and retrieves a table that contains image data. The file format can be ERDAS IMG, ENVI IMG, IDRISI IMG or any other supported technology that matches the filename.
Running a script:
Manifold allows scripting in eleven different scripting languages by supporting them for use within Script windows. Six scripting languages are always available for use in every Manifold installation without requiring any additional installation of any kind, either because they are built in to Manifold (Javascript) or because they are automatically available as a result of Microsoft facilities that are required for any Manifold installation.
Two additional languages, IronPython and IronRuby, are automatically supported by the Command Window when they are installed. Five more languages, F#, PerlScript and PythonScript, are supported when they are installed.
JavaScript
C#
JScript
JScript.NET
VB.NET
VBScript
JavaScript using the Google V8 engine is built into Manifold and is the recommended default. The other always available languages are provide by Microsoft COM/.NET, which are required for Manifold installation.
IronPython
IronRuby
IronPython and IronRuby are supported by the Command Window just like the built in JavaScript engine, but they are not part of Manifold installations. IronPython and IronRuby are installed separately.
F#
PerlScript
PythonScript
Manifold understands and supports the above languages for scripting using script components.
Following are examples of the default "Hello, World!" scripts which are created when we create a new script using the various languages used by Manifold. The default scripts write the "Hello, World!" text to a log window that is automatically opened when the script is executed. In addition to illustrations the code is included below as text to enable copy and pasting from this documentation.
// C#
class Script
{
static Manifold.Context Manifold;
static void Main()
{
Manifold.Application.Log("Hello, World!");
Manifold.Application.OpenLog();
}
}
// F#
//
// Note: running script requires F# and F# PowerPack (FSharp.Compiler.CodeDom.dll)
module Script
let mutable Manifold: Manifold.Context = null
let Main() =
Manifold.Application.Log("Hello, World!")
Manifold.Application.OpenLog()
# IronPython
#
# Note: running script requires IronPython (IronPython.dll)
def Main():
Manifold.Application.Log("Hello, World!")
Manifold.Application.OpenLog()
# IronRuby
#
# Note: running script requires IronRuby (IronRuby.dll)
def Main()
manifold.application.log('Hello, World!')
manifold.application.open_log()
end
// JavaScript
var Main = function()
{
Manifold.Application.Log("Hello, World!");
Manifold.Application.OpenLog();
}
// JScript
var Main = function()
{
Manifold.Application.Log("Hello, World!");
Manifold.Application.OpenLog();
}
// JScript.NET
class Script
{
static var Manifold: Manifold.Context;
static function Main()
{
Manifold.Application.Log("Hello, World!");
Manifold.Application.OpenLog();
}
}
# PerlScript
#
# Note: running script requires ActivePerl
sub Main
{
$Manifold->Application->Log("Hello, World!");
$Manifold->Application->OpenLog();
}
# PythonScript
#
# Note: running script requires ActivePython
def Main():
Manifold.Application.Log("Hello, World!")
Manifold.Application.OpenLog()
' VB.NET
Class Script
Shared Manifold As Manifold.Context
Shared Sub Main()
Manifold.Application.Log("Hello, World!")
Manifold.Application.OpenLog()
End Sub
End Class
' VBScript
Sub Main
Manifold.Application.Log "Hello, World!"
Manifold.Application.OpenLog
End Sub
Agnosticism - Manifold is completely agnostic about programming languages, as can be seen by the wide range of languages which are directly supported for scripting in Manifold. JavaScript is built in for convenience and to leverage the ubiquity achieved by JavaScript as a result of Internet. The V8 engine was selected as a high quality and fast JavaScript engine that is compatible with Manifold parallelism and which would fit within an .msi installation. The Manifold Command Window by default supports both IronPython and IronRuby to provide stylish alternatives to JavaScript. C#, JScript, JScript.NET, VB.NET and VBScript are supported and are always available because of the Microsoft infrastructure required for a Manifold installation. Manifold also supports F#, PerlScript and PythonScript, which are easy to install if desired.
Example: Run JavaScript in the Command Window - How to run a simple V8 JavaScript script in the Command window.