Documenting your Scripts

Excerpted from my book FrameScript for Newbies Copyright [7/17/2007] by Paul Schnall

As you write scripts you should always document them. Anything that is relevant to the creation and use of the script can be put in the script as a comment. It is always advisable to put a section at the top of the script to give you and other readers pertinent information. This information can include:

  • a short description of what the script does
  • what input files are needed
  • what parameters in the script need to be specified, and include the line of code where to specify them (unless you are using dialog boxes to input parameters into the script)

I also include:

  • the date the script was written
  • last date the script was modified
  • Author

You can include any other information you like, just remember if you give out the script, other people will be able to read the comments.

It is also a good idea to use a comment to explain a subroutine or a few lines of code, especially when you start writing scripts. For example, you wrote a script that loops through all the tables of a document. It would be wise to write a comment about the script, so you can find this loop later on, in order to copy and paste it into another script if the need arises.

Commenting out lines in a script

Commenting out lines is a way to hide the line from the compiler so the line of text is not interpreted as a command or a line of code.

To comment out a line in FrameScript there are two methods.

The first method uses // two backslashes one after the other. This must be at the beginning of each line. If a comment wraps around to the next line two backslashes must also be placed at the start of that line and every line that wraps around.

// This script finds all empty paragraphs and checks for
// any table anchors, frame anchors, or marker
// anchors. If There are any anchors this script will
// not delete the Paragraph.

I find that when I am writing a script I use this function instead of deleting a line of code. This way it still remains in the script if I want to add it back later or add it somewhere else in the script. This is of great use when debugging a script.

For example I insert the command

Display 'I got to Here';

When the script reaches this line of code a message window pops up with the message
I got to Here. Now I know that the script ran at least to this line.

Then I can add // to the beginning of this line of code and it effectively erases it. I can always copy and paste this Display command anywhere in the script to see if the script reaches that line.

This is especially useful for displaying variables in order to see how far the code progressed when it stopped or crashed. For Example the Display command can be used to display the text within the current paragraph being manipulated by the script.

Display vPgf.text;

When the script reaches this line of code the text within the current paragraph will be displayed. Thus, you can see how far into the document the script has progressed before it crashed.

Once the script is finished you can go through the script and delete any extraneous Display commands.

The second method for hiding comments uses /* to open a commenting area and */ to close a commenting area.

// This double backslash indicates a comment.

/* This indicates the start of a

section to be understood by the FrameScript

Compiler as comments. To end the comment

section use */

 

Useful Information

  • Job Listings (visible to only members)

  • Employee Benefits

  • Other Sites and Resources

    Survey Reporting

    Q2 2010 Survey Results

    Requires access rights

    Employee Salaries (18 pp)

    Freelance Writer Rates (11 pp)

    Q4/09 Copy Editor Rates (9 pp)


    Columns on Elephant

    Translatable but Debatable

    Each month, Mark L. Levinson presents one hard-to-translate Hebrew word at a time for discussion.

    Of Mice and Keyboard Shortcuts

    Michael Cohen will teach us practical shortcuts that save us time and make our lives easier.

    The Why of Style

    Mark L. Levinson examines the big and little factors that make writing effective.

    Broken Bell Education in Israel

    David Siegel looks at the problems in education in Israel and discusses what can be done.

    Jonathan's Tool Bar & Grill

    Jonathan Plutchok identifies free or inexpensive utilities or plug-ins that save time, increase productivity, improve your computing environment, perform a task you otherwise couldn't do... or is just too much fun to ignore. This column has grown into its own blog at http://jonathanstoolbar.blogspot.com where you can find new issues every week.

    It's in The Script

    Paul Schnall teaches us about the power of FrameScript and how to use it.

    Do it Yourself

    Did you ever wonder what was inside a PC, laptop, or other microcomputer system? Michael Cohen teaches us what's inside and how to configure and build our own.

    Coaching for Success

    Dr. Tal discusses the principles of professional coaching, focusing on resiliency.

    Hunters and Gatherers

    Eric Gluch looks at modern marketing.

    Moving to Chelm

    Esther Shira Stepansky takes us on a humorous adventure in the modern day land of Chelm as we look at some of the challenges of making aliyah and finding work in Israel. Making aliyah is supposed to be the fulfillment of my of your Jewish identity, so why does Israel make it so difficult?

    Why am I a Tech Writer?

    By Michael Altman

    Life as a Tech Writer

    By Mumpy

    Building Bridges (in Hebrew)

    Dr. Zaidel discusses another aspect of mediation within the framework of Israel's court-approved Alternative Dispute Resolution (ADR) process.

    Don't Forget

    Hezy Asher teaches us how to improve our memory.

    World of Podcasting

    Tom Johnson's podcast episodes, provide tips on recording presentations, and other podcasting related news and events.

    Effective Management ניהול אפקטיבי

    By Eitan Reuveni

    Scribblin' With Steph

    By Stephanie Freid

    Life in Northern Israel

    By multiple authors

    Life on the Southern Front of Israel

    By Israel Ivri

    Event Summaries

    Summaries of events held by Elephant and other organizations throughout the Israeli technical/marcom community.