Writing Scripts


To create a script, the script text is typed into the Scripter code window or an existing script is edited. When you want to create a new script, you will most likely start with an empty Scripter window and type the entire script. If you want to perform a routine task such as creating a graph, you can probably open an existing script file and edit the file to meet your specific needs. Grapher comes with several sample scripts that you can modify as desired.


Consider a script that creates a 3D XYY ribbon/wall plot:

Sub Main

'Create a programmable object to represent

'the Grapher program

 Set GrapherApp = CreateObject("Grapher.Application")


'Make the Grapher window visible

 GrapherApp.Visible = True


'Assigns the Documents collection to the

'variable named "Docs"

 Set Docs = GrapherApp.Documents


'Creates a new plot window and assigns it to

'a variable named "Plot"

 Set Plot = Docs.Add(grfPlotDoc)


'Assigns the AutoShapes collection to

'the variable named "Shapes"

 Set Shapes = Plot.Shapes


'Creates a 3D XYY Ribbon/Wall Plot

 Shapes.Add3DLinePlotGraph(GrapherApp.Path + "\samples\bar chart orientations.dat")

End Sub


When you execute the script, Grapher is automatically started and a plot window is displayed. The graph is created. When the script execution is complete, the Grapher window remains open.



See Also

Introducing Scripter

Scripter BASIC Language

Running Scripts

Debugging Scripts

Object Hierarchy

Object List