|
A script is a plain text file containing CC2 commands. It is just like typing the commands at the command prompt. They can be used to draw just about any thing you could draw yourself, with the advantage of automation. A script cannot drive dialog boxes. They are especially useful to programmers who don’t want to master CC2’s rather esoteric file format. The file must be saved with a .scr suffix. If you name the script file the same as a map then when that map is first loaded, CC2 automatically runs the script file. Scripts can include ordinary CC2 commands (text equivalents of the ones in the standard menu) or special macro commands. The text equivalent of commands is listed after each command in the help file and in the help index under Commands > Alphabetical list of commands. How do you use a script? There are three ways of executing a script file. The first is the only one you need to know to start with.
MACRO SCRSCRIPTM #myscript.scrENDM Type SCR and press ENTER at the command prompt to activate the script
The drawing environment The first thing to do is to create a template that your script can modify. It should have all the layers, fill styles, line styles and symbol defintions inserted in it that you need. Your script should be tested with this drawing current. Scripts can work on any drawing, but you may have to add fill styles, line styles, colors, etc. before proceeding (see PARTM below for an example of how to do this) An example The following script adds a path to a map: COLOR 29LAYER COAST/SEAFSTYLE SolidLSTYLE SolidPATH 0,0100,10020,23123,23434,243SAVE This script is fairly self-explanatory. It adds a Color 29 path to the map on the COAST/SEA layer, then saves the drawing. Each RETURN character acts as a delimiter. With commands that keep going until you cancel them (e.g. PATH, above) you will need to put an extra delimiter to finish the command. Semicolons and spaces also acts as a delimiter in most commands, except those which can take a line of text with spaces (e.g. TEXTM) The easiest way to find out how a command works is to type it in at the command prompt and see what questions it asks. Selection Methods used in scripts You don’t often need to perform editing or copying commands in scripts, but you can. Note that entities on hidden or frozen layers will not be affected. SELBYA Select entities by: All SELBYP selection prior entities SELBYL select all entities on a layer SELBYC select all entities of a particular color (beware – all entities have a color, but some don’t display it, e.g. symbol references) SELBYD Restores normal selection method Examples: Examples: LINE 0,0 100,100 SELBYPCHANGEL COAST/SEASELBYD Draws a line then changes the layer of the line to the COAST/SEA layer SELBYCCHANGEC 2 4SELBYD Changes all color 2 entities to color 4 entities. This example could be used as a basis for changing the color scheme of a contour map. Combining selections You can’t use AND, OR and NOT. The only way you can imitate these is by freezing layers. In the color change example above, you could exclude entities on the COAST/SEA layer as follows: SELBYCFREEZECOAST/SEACHANGEC 2 4SELBYD |