Subscribe to this thread
Home - General / All posts - Automate Running a Script in Manifold 9
CalvinChipman3 post(s)
#07-Jul-18 01:53

Is there a way in Manifold 9 to run a script from the command line or any 3rd party application? Trying to automate the running of a script externally.

adamw


8,216 post(s)
#20-Jul-18 09:30

Late to the thread, sorry.

You can drive Manifold 9 from a third-party application using the script API or using ODBC. You can run a query. You cannot currently run a script directly, but a query can run a script, so, yes, you can run a script.

CalvinChipman3 post(s)
#20-Jul-18 17:10

Can you provide some step-by-step instructions for how to do what you are talking about in this link? Specifically, how to create an instance of Manifold.Root in Visual Studio C#. Can you provide an example that shows how to do this?

adamw


8,216 post(s)
#25-Jul-18 15:22

Sure.

Setup: have the portable version of Manifold 9.0.167 installed in c:\programs\manifold-9.0.167-x64. Verify that it launches (can find the license of 9 and does not ask for a serial number).

Launch Microsoft Visual Studio. I used Visual Studio Community 2017 with .NET desktop development workload installed.

Invoke File - New - Project. In the template tree on the left, select Visual C#, Windows Desktop. In the template list on the right, select Console App (.NET Framework). Click OK. (Visual Studio creates a project.)

In the Solution Explorer, right-click the Properties node and invoke Open. Select the Build tab. Under Platform target, uncheck the 'Prefer 32-bit' option (we are going to use 64-bit).

In the Solution Explorer, right-click the References node and invoke Add References. Click Browse at the bottom of the dialog. Navigate to c:\programs\manifold-9.0.167-x64\bin64 and select EXTNET.DLL. Click OK.

In PROGRAM.CS, provide example code for Program.Main:

//C#

 

...

 

[STAThread]

static void Main(string[] args)

{

  using (Manifold.Root root = new Manifold.Root(

    @"c:\programs\manifold-9.0.167-x64\bin64\ext.dll"))

  {

    Manifold.Application app = root.Application;

    using (Manifold.Database db = app.CreateDatabase())

    {

      using (Manifold.Table table = db.Search("mfd_root"))

      {

        Console.WriteLine("Fields in mfd_root:");

        Manifold.Schema schema = table.GetSchema();

        foreach (Manifold.Schema.Field field in schema.Fields)

          Console.WriteLine(field.Name);

      }

    }

  }

}

Build, run / debug, and you should have the code launch the runtime of 9, create a new database (temporary MAP file), and list all fields in its MFD_ROOT.

You can omit the path in the call to new Manifold.Root(), then the system will try to locate 9 in the default installation folder under Program Files.

The STAThread attribute is currently mandatory because parts of the runtime use system services that require apartment threading. We will probably relax this in the future (and let those parts fail graciously with free threading, which is the default for .NET projects).

Hope this helps.

CalvinChipman3 post(s)
#31-Jul-18 01:22

Sorry for the long delay. I was gone on vacation.

This is perfect! Thanks!

Manifold User Community Use Agreement Copyright (C) 2007-2017 Manifold Software Limited. All rights reserved.