File - Create - New Script

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, IronPython and IronRuby can be edited and executed from the Command window, using the Command window as a REPL (Read-Eval-Print Loop) console.   Add-ins to extend Manifold with new commands can also be written using scripts.

 

Two ways to create and run scripts -  In Manifold, we have two ways to write scripts:

 

 

 

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.

 

To create a script:

 

  1. Right-click into the Project pane and choose Create - New Script to create a new script, or choose File - Create - New Script.
  2. Specify a name for the new script.
  3. Choose the scripting language from the pull down menu.
  4. Press Create Script.
  5. Double-click the new script to open it in the Command Window.
  6. The new script will open with sample text appropriate for the language selected.
  7. Write the script as desired.
  8. The script is automatically saved as we edit.  Make a copy before editing an existing script.

 

We can also write a temporary script in a limited selection of languages that are installed, which will appear as choices of <scripting language> in the View - New Command Window command.  See the discussion in the View - New Command Window topic.

 

To write a temporary script:

 

  1. Choose View - New Command Window - <scripting language>
  2. Write the script as desired.
  3. If we want to save what we've written, we can copy the text and paste it into a script component we create.

 

New scripts created within the Command Window disappear when the Command Window is closed.   To save the script, copy the text and paste it into a new  script component created in the project.

 

For tips on editing the text of scripts in the Command Window, see the Editing Queries, Scripts and Comments topic.

 

Running a script:

 

 

File - Create - New script

 

In the main menu choose File - Create - New Script or right-click an empty spot in the Project pane and choose Create - New Script.

 

 

 

Choose the language for the script from the pull down menu.

 

Name

Name for the script.  "Script" by default.  Specify a more informative name as desired.

Language

Choose the desired language for the script.

Create

script

Create the new script.

Edit Query

We can write SQL in a query that creates other components.  For example, we can write a query that creates a table and a drawing.  We can also write a query that creates a new query component.  

 

The Edit Query button launch the Command Window loaded with a query that creates a new query using the given name. This is a a great way to learn how to use SQL to create queries.

Cancel

 Exit the dialog without doing anything.

 

See examples in the Scripts topic.

Notes

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. 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.

 

Documentation - For information on scripting, see the Manifold API Documentation website.

 

See Also

Tables

 

Queries

 

Scripts

 

Editing Queries, Scripts and Comments

 

View - New Command Window

 

Command Window

 

Command Window - Query Builder

 

SQL

 

SCRIPT

 

Example: Create and Run a JScript.NET Script - How to create and run simple JScript.NET scripts.

 

Example: VBScript to Create Locations from a Table - Use VBScript to take a table where each record has a name, scale, latitude and longitude and for each record create a Location component in the project.