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