georeference.org
Subscribe to this thread
Home - Scripting / All posts - FAQ - Scripting
adamw


6,803 post(s)
#24-Dec-07 07:01

Frequently Asked Questions for Scripting

Q: What questions should I ask in this forum area?

A: Anything related to creating and maintaining scripts, web sites and external applications, that is, anything related to the Manifold object model. For where to post other questions, see the FAQ for the General forum area.

Q: What is the Manifold object model?

A: A set of COM objects which can be accessed programmatically from a script or application.

Q: Can I use the Manifold object model in .NET applications?

A: Yes.

Q: Can I use the Manifold object model in the context of a web site?

A: Yes, as long as your web server can create and use COM objects. Both of today's most popular web servers, IIS and Apache, can do this.

Q: Can I use the Manifold object model in the context of a .bat file?

A: No, but you can use it in the context of a .vbs or .js file which can be run from the command line similarly to a .bat file. You can also use the Manifold object model in the context of a PowerShell script.


Feel free to post whatever else you think should be in the list in this thread.

Lorne

653 post(s)
#08-Jan-08 15:27

Adam

I think that a good scripting FAQ would be an explanation of the differences between scripted and GUI SQL selections. It seems that this question is asked by everyone new to Manifold programming. I refer people to some of your postings such as.

x17367

Manifold-L

adamw


6,803 post(s)
#08-Jan-08 21:26

Yep, this will appear in the next version of the FAQ. Thanks!

adamw


6,803 post(s)
#13-May-08 22:34

Q: I am writing an external application. How do I open a MAP file?

A: Create an instance of the Application object using CreateObject("Manifold.Application") or a similar construct and call the NewDocument method. Alternatively, create an instance of the MapServer object using CreateObject("Manifold.MapServer") and call one of the Create methods, eg, CreateWithFile.

Q: How do I obtain a reference to the Document object for my MAP file?

A: It depends:

  • For a script run within the Manifold GUI, use the global Document object (scripts in VBScript, Javascript or other ActiveX scripting languages) or the Document property of the global Context object (scripts in C#, VB .NET or other .NET languages).

  • For an add-in script, do the same.

  • For an add-in pane (.NET or COM), implement the IEventsConnection interface defined in Manifold.Interop.Scripts.dll, subscribe to the desired events, and use the Document object or objects passed to the event handlers.

  • For an external application, create an instance of the Application object, then use its NewDocument method.

  • For a web site, create an instance of the MapServer object, call one of its Create methods, then use the Document property.

Q: How do I import data?

A: Obtain a Document object corresponding to the MAP file you want to import data into (see above). Call the NewImport method to create an import object, configure import options by setting properties, then call the Import method. If you want to import or link data from a database, call the NewDataSource method of the Document object to create a data source object, specify connection type and connection string for the data source, then use one of the Import or Link methods.

Q: How do I export data?

A: Obtain a Document object corresponding to the MAP file you want to export data from (see above). Call the NewExport method to create an export object, configure export options by setting properties, then call the Export method. If you want to export data to a database, call the NewDataSource method of the Document object to create a data source object, specify connection type and connection string for the data source, then use one of the Export methods.

Q: How do I locate a component?

A: Obtain a Document object corresponding to your MAP file (see above). Retrieve the component set using the ComponentSet property, then search for the component by name (ComponentSet("name") or ComponentSet["name"] depending on the language) or ID (ComponentSet(ComponentSet.ItemByID(id)) or ComponentSet[ComponentSet.ItemByID(id)]). If you are using a strongly typed language (eg, C#), cast the retrieved object to the appropriate type.

Q: How do I run a query?

A: Obtain a Document object corresponding to your MAP file (see above). For an existing query component, obtain the component object (type Query). For an ad-hoc query, use the NewQuery method of the Document object to create a new Query object, then set the text of the query using the Text property. Specify query parameters via the ParameterSet property of the Query object. If the query is an action query, call the Run method of the Query object. If the query returns a table, get the Table property of the Query object which will run the query automatically and process the table.

Q: I am running a SELECT query programmatically but the objects in the windows are not getting selected. Why?

A: Selecting objects and records returned by a query is a purely UI thing which can be turned off in options. To change the visual selection state of objects returned by a SELECT query, convert the query into an equivalent UPDATE query and alter the value of the [Selection (I)] field (example here).

zua37 post(s)
#22-Jan-09 07:24

[Deleted: please post questions related to specific features of Manifold in other threads.]

gisadvisor
191 post(s)
#27-May-09 17:15

[Deleted]

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