Титульная страница
ISO 9000 ISO 14000
GMP Consulting
 
Mastering CorelDRAW 9

Previous Table of Contents Next


With previous versions of DRAW, automating this routine would have been practically impossible. You could create a style that includes the angled fountain fill, but you would have to skew the rectangle yourself. You could create a preset that skews the rectangle and applies the fill, but it would have been incapable of creating the guideline.

Only a script can perform the entire task, but in early versions of this tool, you had to create the script by coding each line, as if you were a programmer, and Figure 33.2 shows how daunting that task would be. This relatively simple maneuver created over 20 lines of mostly unintelligible instructions.


FIGURE 33.2  Creating scripts is easy, right? Maybe now, but before DRAW 7, you would have had to enter these instructions line by line. No thanks...

What You Can and Can’t Record

During the recording exercise, we referred to a “recordable action.” Not everything can be captured by the Script Manager during the recording process. As far as object creation goes, we have yet to find an object that cannot be captured during a recording. But with respect to interface changes or other types of commands, Script Manager has many limits.

For instance, if you were to toggle Snap to Guideline on or off, DRAW would ignore that. If you were to waive the mouse cursor all over the screen without stopping to click on anything, DRAW would ignore you. If you were to tear off a toolbar and float it on the screen, DRAW would ignore you. By ignore, we mean that the command would be carried out, but it would not be incorporated into the script.

This is not to say that you cannot program many of these commands into a script—the scripting language is immense. But you would have to manually encode them; you can’t record them. In this regard, the Script Manager is different from a conventional keyboard macro program or the now-ancient Windows Recorder. Those programs would try to retrace your every move, regardless of context. Script Manager tries to be a bit more intelligent. We wish that there were a “go dumb” feature, whereby you could instruct DRAW to follow your every move—that way, you could make interface changes without having to face the specter of traversing Options.


NOTE Many actions that used to be unrecordable are now allowed. For instance, most file operations can now be scripted—you can open, save, print, import, and export.

The Corel SCRIPT language, as it’s called, supports the creation of custom dialog boxes, so you can turn your scripts into mini applications that run within DRAW. There is also a standalone application called the Corel SCRIPT Editor that helps you with some of the arcanery of scripting without recording. It is beyond the scope of this chapter (and 95 percent of its readers), but you can get a complete rundown of its capabilities from the online Help. From within DRAW, go to Tools Ø Corel SCRIPT Ø Corel SCRIPT Editor, and access the online Help for reference about the Corel SCRIPT programming language, syntax, and command set.

And what’s more, DRAW 9 supports the Visual Basic scripting language. Essentially, anyone who can program in VBA can now automate procedures in DRAW. Access to it is at Tools Ø Visual Basic.

Playing Back Your Scripts

If you followed the steps above, you have already played back (or run) a script. There are several ways you can run scripts. Coming up shortly is a set of strategies for managing your scripts, but suffice it to say at this point that playing back a script is as simple as finding it and double-clicking on it. You can do this in one of two ways:

  You can open the Script Manager, find the script in the window, and run it.
  You can go to Tools Ø Corel SCRIPT Ø Run Script, and then navigate your way to the desired script.

To continue the VCR analogy, this is akin to walking up to the machine and pushing the Play button. You can also use the remote control, and we’ll talk about that later in this chapter. Before running a script, make sure to think about anything you would need to do to set the stage, like opening the desired drawing, moving to the right page, or selecting a critical object. Scripts are smart, but they can’t read minds.

Working with Text

The Script Manager is quite adept at handling text, both creating and formatting it. When you record a script in which you format artistic or paragraph text, DRAW tracks the font, its attributes (bold, italic), line attributes (underline, overline, and strikeout), placement (superscript and subscript), and spacing between characters, words, lines, and paragraphs. Try the following exercise to create a script for formatting text:

1.  Create a line of artistic text and select it.
2.  Click on the Record button in the Script Manager.
3.  Using the Text property bar or the Character dialog, change the face, the style, and the size. It doesn’t matter what you change them to, as long as you make some kind of change to all three.
4.  Click on OK or Apply, stop the recording, and assign a name to your script.

Because you selected a new face, style, and size, this script will apply those attributes to any string of artistic text. If you had only changed the point size, the script would have recorded just that change. For example, suppose the text you are using when you create the script is in 24-point AvantGarde. While recording, you leave the face at AvantGarde but change the color to red and the size to 100 points. When this script is applied to text in Century Gothic, the text will be sized to 100 points and filled with red, but the font will stay Century Gothic. Since you did not select a font while recording, it did not become part of the script.

In other words, the script recording function does not take note of the current settings; it only pays attention to what you specifically change. So if you want to create a script that changes text to 14-point Century Italic, left-aligned, you’ll have to make sure to click on each of those controls in the dialog or property bar, even if they are already set that way. If the dialog already displays Century Italic as the face, click on it anyway. Incidentally, this applies to graphic scripts as well. If you’re creating a script for a blue fill and a red outline, make sure you select the blue fill and red outline during recording, even if they are already the current settings.

One other point concerning text and scripts: you can only apply a script to an entire string of text, not a few characters selected with the Text tool. If you have characters selected with the Text tool when you run a script, the entire string or frame of text will be changed. DRAW will issue a message to this effect during the recording process.


Previous Table of Contents Next
 
Rambler's Top100