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

Previous Table of Contents Next


Case Study: Debbie Does CorelSCRIPT

While most of us won’t go anywhere near the stuff, one member of our writing team, Debbie Cook, has gotten up close and personal with the scripting language for a series of PHOTO-PAINT plug-in effects that have become very popular among those who have used them (see instructions at the end of this chapter for downloading a trial version). Here is her story...

I’m not a programmer, and I never had any intention or expectations of becoming one. And make no mistake, to a real programmer, I’m no programmer. But I do know DRAW and PAINT, and if programming a script is simply a way to operate those programs more efficiently, then it’s worth a bit of code hell to get there.

Because Corel SCRIPT commands were my first introduction to any kind of programming, I’m probably lucky that I first tried recording little scripts in PHOTO-PAINT rather than in DRAW because I might never have explored Corel SCRIPT any further. The difference is that the PAINT recorder returns an immediate list of every recordable action performed, while in DRAW recording is “invisible” right up through when you save the recording. At that point, if you have included a command that is not recordable, DRAW informs you rather unceremoniously.

I slowly became familiar with the Corel SCRIPT commands while watching them as they were being recorded. OK, “familiar” might be stretching it, but at least I was starting to recognize the patterns and general syntax of this foreign language.

Armed with my simple recordings, I opened the Script Editor to have a closer look. I remembered someone telling me once that if you highlight a command in a script and press F1, the Help files will open at that particular command. When I first saw these files, they might as well have been Greek. They assume a certain level of understanding of programming in general, and I had none. Nada. Zilch. But I read through this information anyway and actually began to understand some of it. Then I wondered if there was a rogue geek gene in my DNA somewhere. I was hooked.

I moved on to dissecting many of the sample scripts I found in both DRAW and PAINT, as well as various Web sites. It was a slow process of understanding, but it was better than dissecting that frog in my 10th grade biology class (and a lot less messy). As I continued to experiment, I continued to learn, and soon my scripts were growing into miniprograms that offered options and automation. I was quite proud of the first special effect I created in PAINT, but you know what—I was more proud of the script I wrote that automated that special effect.

When you’re ready to try your hand at creating your own scripts, here are some hints and references that I wish I had known when I began.

Read the Help files Open the Script Editor Help file (F1), go to the Contents tab, and read the sections in order. The documentation for version 9 has been improved, and most of it now can be understood by nonprogrammers. As you begin to experiment with your own recordings and scripts, go back and read the Help files again. You’ll be surprised by how much more you’ll understand, and you’ll probably learn something new with every review.

Ask for help Corel’s support newsgroups are a wonderful resource for every aspect of DRAW, and there is a separate newsgroup area devoted entirely to scripting: news://cnews.corel.ca/corelsupport.draw-scripting. Chances are you’ll have an answer to your question within 24 hours, and we might even run into each other there.

Walk away When you become frustrated with a script that you just cannot get to work, take a break and clear your head. I used to obsess over uncooperative scripts before I learned to just get up and leave the computer. I was amazed at how much more easily solutions came to me when I returned. Programming is a set of linear and logical expressions, but we humans are not. Double that when you are frustrated and out of patience.

Read the Help files again This time, though, read through the index portion to learn about commands you might not know even existed. When you see something interesting, read about it and try it out. Many commands have sample syntax that you can cut and paste into your own script files.

Debug Don’t overlook the Script Editor’s debugging tools. It’s very helpful to execute your first scripts line by line so you can watch them in action. The Script Editor will also check your scripts and return error messages if it finds something wrong. While the error messages may be cryptic, you’ll at least be pointed to the line number of the problem.

Use the recorder There’s no need to reinvent the wheel. Record the actual commands, save the snippets, and then cut and paste them into your scripts. You’ll save yourself a lot of typing and the error checking that goes with the inevitable typos.

Think modularly Scripts are executed top to bottom, and the more you can break up what you want to accomplish into separate pieces, the more successful and efficient scripts you’ll write. Begin by creating a formal linear outline of what you want to accomplish with your script and then try to write it in that order. And don’t forget to save particularly good pieces of code into separate files to copy into new scripts later. The best programmers write code once and use it forever!

Take notes Don’t try to remember what every block of code does. Placing REM at the beginning of a line means that whatever follows on the same line is a remark and will not be executed. This is a great tool for visually separating blocks of code or to simply add notes and reminders to yourself.

Start small and don’t give up Don’t overwhelm yourself with complicated syntax and functions. Start by adding simple options to your recordings with a message box or a simple OK/Cancel static dialog. As your knowledge and experience grows, so will your script functionality.

Get online Visit the experts’ Web sites listed below. Many of these did not exist when I was learning Corel SCRIPT and I would have given my eye teeth for Alex Vakulenko’s tutorials! Download the free scripts and open them in Script Editor to see how others organize their scripts and execute various commands and options.

http://www.vakcer.com/oberon/script

http://tfts.i-us.com

http://www.tld.net/users/mcdesign/downloads.htm

http://www.richz.com/scr-utl/c-script.html

http://www.cedesign.com/html/scripts.html

http://www.cedesign.com/cefx (to download demo of Cutting Edge F/X)

If I can do it, anyone can. This isn’t false modesty—I know what I’m good at and what doesn’t come naturally to me. Scripts definitely do not come naturally to me, but in that regard scripting skills are unlike actual design and illustration skills. Without some natural design sense, there is only so much you can achieve in the arts. But with scripting, effort, practice, reverse engineering, and a bit of sweat and toil really can spell success.


Previous Table of Contents Next
 
Rambler's Top100