logo

img

Knowledgebase Home | Contact Knowledgebase Home | Contact
Search the Knowledgebase Browse by Category
What is the easiest way to learn Scripter?
User Opinions
No users have voted.

How would you rate this answer?
Helpful
Not helpful

Teaching yourself to write scripts is possible. MapViewer uses a Visual Basic-like model.  This means that objects are "drilled down" to get to commands.  If you are commpletely new to writing any types of scripts or macros, I would recommend getting a good book on Visual Basic, such as Visual Basic for Dummies.  This will give you a good understanding of how VB worked.

Once you have a good idea of how VB works, you are ready to move on and write your own scripts. MapViewer has examples for most commands. To access these, choose Help | Automation Help. The page that comes up shows the object hierarchy.


You can click on any object to see how to use that object and any commands available for that object. For instance, if you want to create a hatch map, you would click on the box that says Hatch Map. Then, you can scroll down on the new page to see the example script.  You can copy/paste this example into a new Scripter window.

This will help you get started in making your own scripts. You can also click on any of the commands in the list to see more information and the context for that command.

You would add these commands after the point in the script where the hatch map is actually created.

One key in making a script is first determining the process that you would use to make the same map in the program. Once you have the steps to making the map in the program, you can determine the steps needed to make the map in the script by searching through the help file for the correct command.

For example:

1. Start the script with the information needed to open MapViewer and create a new plot window:

'Declare the variable that will reference the application
Dim mvapp As Object

'Creates an instance of the MapViewer Application object
'and assigns it to the variable named "mvapp"
Set mvapp = CreateObject("MapViewer.Application")

'Make MapViewer visible
mvapp.Visible = True

'Declare Plot as Object and creates a new plot window
Dim Plot As Object
Set Plot = mvapp.Documents.Add(mvDocPlot)
2. Use the CreateBaseMap command to load the counties into the map:

'Declare BaseMap as object and creates the base map
Dim BaseMap As Object
Set BaseMap = Plot.CreateBaseMap(mvapp.Path + "\Samples\co2000.gsb")
3. Create the hatch map:
Set HatchMap = Plot.CreateHatchMap(DataFileName:=InPath$ + "co2000.dat", PIDCol:=1, VarCol:=5, NumClasses:=4)

Visitor Comments
No visitor comments posted. Post a comment
Related Questions
Attachments
No attachments were found.
Products