Beginning Scripting Webinar – Functions – January 22, 2013

Thank you very much to all who attended the webinar. Download or view the webinar slides. FrameScript users download this PDF.

You can download the ExtendScript sample scripts here.

For more information on the Unstructured FrameMaker 11 book, go to http://www.scriptorium.com/books/unstructured-framemaker-11/.

For the webinar replay in wmv format, click here.

Beginning FrameMaker Scripting Webinar – January 15, 2013

Thank you very much to all who attended the webinar. Download or view the webinar slides.

Download the webinar code in both ExtendScript and FrameScript versions. Download the sample FrameMaker document that we used during the webinar.

Download the FrameMaker 10 Object Reference chm file. The zip archive includes a screenshot that shows you how to disable the security warning.

For more information on the Unstructured FrameMaker 11 book, go to http://www.scriptorium.com/books/unstructured-framemaker-11/.

For the webinar replay in wmv format, click here.

Bypass: Surgery

With the bike trip out of the question, we turned our attention to getting my heart fixed. I went for an angiogram on Monday, which was to give the precise location of the blockage. If they find the blockage, and it is a candidate for a stent, they basically leave you on the table and put in the stent. You spend the night in the hospital and go home the next morning. I spoke to a friend that had a stent put in 12 years ago, and he is still doing fine. I was pretty optimistic that this is probably what would happen.

The angiogram showed two bad blockages in areas that couldn’t be opened with a stent. I would definitely need bypass surgery. But the chief heart surgeon at Strong Memorial Hospital had an opening for Wednesday afternoon. This would have to work because he was scheduled for vacation the following week. One of my nurses, a twenty-five year veteran, told me that Dr. Knight is the one you want to do this surgery. I was very blessed that he was available when he was.

After all of the annoying pre-op testing Tuesday, I was admitted Wednesday for surgery scheduled for around 12:45 pm. I was pretty calm because I knew that a lot of people were praying for me and because of my relationship with Jesus Christ. However, I got a little spooked just before the operation and fainted in pre-op while getting an IV line inserted. Then my poor wife got a call from the surgeon just after I went into the operating room. “Your husband’s heart stopped on the operating table, but we got it going. We are going to proceed with the surgery.”

The operation was done in about two and a half hours. Amazingly, Dr. Knight did the procedure “off pump,” which means that my heart was beating as they did the surgery. Normally they hook you up to a machine that circulates your blood while they work on the heart. I was told that he is one of the few doctors that sometimes uses the off pump technique. One of the reasons to do it this way is to speed recovery time because the body does not take on as much fluid.

After spending the night in the coronary intensive care, they sent me to a step-down unit for recovery. Actually, they make you walk. It is amazing how soon they get you out of bed and moving around. They put me in a chair the night of the operation and walked me around the unit 3 separate times.

I had a remarkable experience concerning my roommate in the step-down unit. I could hear some of his visitors talking about the “old neighborhood,” referring to streets in my childhood neighborhood. Gary is 10 years older than me, but he was born and raised in the same neighborhood and went to the same schools, etc. It was amazing to discover common families, restaurants, and shops that we both knew as children, in spite of our age difference. I prayed with him that night and thanked the Lord for putting us together.

I was shocked Friday morning when the surgeon told me I could go home if I wanted to. My wife was horrified and said it was too soon. I agreed with her, but I still felt relief that he was that positive about my recovery so far. That night, though, I got a mixture of homesickness and worry about getting an infection in the hospital. I went home on Saturday afternoon, leaving my new friend Gary behind.

Bypass: Part 1

This post is for those that may be interested in the events of the last couple of weeks. Thank you very much for all of the prayers, love, and words of encouragement. I thank God for such good friends and an amazing family.

A little background: I am 53 years old and have been fairly active over my lifetime. I was an avid cyclist in my late teens and early twenties. Over the years, I have struggled a bit with my weight, fluctuating from my wedding day weight of 155 (in 1984) to 198 when my 8th son was born (in 2002). Shortly after I hit my high, I lost 40 pounds and eventually settled in the low 160s (I am 5′ 6″).

In early 2010, I bought a nice bicycle and started riding again. I really enjoy aerobic exercise and there are some great roads here in Orleans County (New York). My main riding partner is my 14-year-old son Jason. That first year, I rode 2,300 miles on the bike and finished with a 108 mile ride the length of NYS Route 19. I hadn’t been in such good shape in over 25 years. The next year, I rode 1,900 miles on the bike.

I have struggled to maintain fitness during the winters. You stop riding, but the cycling appetite doesn’t stop right away, so it’s easy to keep eating. This past winter my weight crept up to a high of 188. But we had big plans for 2012: I was to help lead a bunch of young men on a 380 mile ride across NYS along the Erie Canal. We had a great spring here, so by June 14, two days before the trip, I had 794 miles on the bike and had cut back to 176 lbs.

A week or so before the trip, things got a bit interesting. In spite of being in good cycling shape, I started having some lousy rides where I just didn’t feel right. To put things in perspective, here is an entry from my cycling log, one month previous:

5/17/2012 39 miles. Rode with Jason and Jonathan to Batavia library and back. Had a 16.1 mph pace to beat the darkness. Ate up the hills on NY 98. Felt terrific. Rated 9/10.

I was still having rides like this in early June:

6/6/2012 6:30 PM 23 miles. Rode solo to church via Barre, Clarendon, and Byron. Beautiful ride on a beautiful evening. Saw a nice rainbow.

Look at the contrast just 3 days later:

6/9/2012 8:26 PM 16 miles. Rode with Timothy to Albion then to Morriseys. Met Bill’s sister Joan. Suffered through the whole ride chasing Timothy. If all rides were like this, I wouldn’t be a cyclist.

6/11/2012 8:53 PM 16 miles. Rode with Jason west on 31 to Phipps Road to Eagle Harbor to 31 to Allen Road. Then rode around Albion and back home via Butts Road and 31. Felt lousy with tightness in chest for much of the way.

By now, I am sure you can see the warning signs for some real problems. I told my wife Sherry how I was feeling on the bike and she scheduled an appointment with my primary care physician for Wednesday. I had a normal EKG so she scheduled me for a stress-test on Friday, the day before the trip. I really wanted to go on the trip, so I wanted a least one more ride to see if the others were a fluke. Here is my log entry for my last ride that Thursday evening:

6/14/2012 8:00 PM 21 miles. Rode from Bike Zone with Joe Lodice and Jason. Felt lousy with chest discomfort and fatigue. Probably the worse ride of the year. I am going for my stress test tomorrow :-(.

Sure enough, the stress test on Friday showed an 80% chance of blockage in at least one of my coronary arteries. So I was officially grounded. But thankfully, my two sons and the rest of the group successfully finished the ride on Saturday, June 23rd. (If you are interested in learning about the trip, take a look at bike300.wordpress.com.)

Lord willing, I am going to add one or two more posts regarding what happened next. But I want to finish this post with a bit of advice. The cardiologist told me that had I been sedentary, this problem may not have surfaced for 10 or more years, and that I may have just dropped dead from a heart attack. It was the aerobic exercise that manifested the problem early. If you are mainly sedentary or don’t often stress your heart during exercise, I would strongly suggest that you have a stress test. It was really not bad at all as far as the process and it is apparently a good diagnostic tool.

Let me say it one more time. Perhaps your weight is under control, your cholesterol is good (like mine is), and you “work out” or exercise regularly. But if your heart-rate is never elevated for sustained periods of time, a heart problem may not show up. Get a stress test.

Using a regular expression to convert an image name to a path

Mike and I started an interesting discussion about using ExtendScript to import images from a base file name that the user enters. One of the key tasks is to figure out how to take a base file name that uses their syntax and derive a full path from it. Based on Mike’s examples, I came up with the following ExtendScript function:

This function illustrates the power of regular expressions. The basic regular expression is this:

Find 3 uppercase letters: [A-Z]{3}

followed by four digits: \d\d\d\d

The parentheses “capture” parts of the match and put them into special variables in the form of $#, where # is a number from 1 to 9. To figure out what number goes with what set of parentheses, you start counting from the left. So, in our regular expression

([A-Z]{3}) will be $1. In our example, this will be MSP.

((\d)\d) will be $2. In our example, this will be 43.

(\d) nested in $2 will be $3. In our example, this will be 4.

and (\d\d) will be $4. In our example, this will be 21.

We can use these variables to build up our path. Notice the $# variables in the replacement string (color-coded for clarity):

This will become

The backslash in JavaScript is an escape character, so to get the literal backslash character, we have to use 2 where we want 1.

Copy the function into the ExtendScript Toolkit and try a few filenames that use this format, and you will get the correct path every time. Regular expressions are a deep topic, but as you can see, they are very powerful for parsing tasks like this.

-Rick

FrameMaker 10 ExtendScript: The Object Model

Thank you to all that attended this webinar. I will post the link to the recording as soon as it is available. In the meantime, here is a link to the FrameMaker Object Model chm file and webinar slides:

http://www.rickquatro.com/resources/FM10_ObjectReference.zip

Here is a link to the FrameMaker 10 FDK:

http://www.adobe.com/devnet/framemaker.html

After you install it, the documentation will be in the docs folder.

Arnis asked about dumping a list of properties for an object. In FrameScript it is easy:

With ExtendScript, you can use a function; in this case, I am writing to the JavaScript Console instead of the FrameMaker Console:

Please let me know if you have suggestions for future webinars. Thanks again for all your support.

-Rick

ExtendScript Webinars: What Do You Want to Learn?

I just finished my second FrameMaker 10 ExtendScript webinar, which I enjoyed immensely. The first one was done in conjunction with Adobe, the second was sponsored by Carmen Publishing Inc. I would like to do more ExtendScript webinars and want to know what topics people are interested in. Please leave comments with suggestions for ExtendScript topics. Thank you very much.

-Rick

In Memory of Bruce Foster

Bruce Foster, creator of many fine FrameMaker plugins, passed away suddenly on Saturday, June 11, 2011. Although Bruce had been diagnosed with multiple myeloma in September 2010, his death still came earlier than was expected. Bruce’s plugins for FrameMaker were BookInfo, ImpGraph, MifSave, MifToFM, RtfSave, and his most famous, Archive.

Bruce’s website is now offline and, as far as I know, his plugins are no longer available  for sale.

Adobe Engineering has just released a free ExtendScript script for archiving FrameMaker 10 books:

http://blogs.adobe.com/techcomm/2011/07/create-a-book-packager-using-extendscript.html

I haven’t tested the script yet, so I can’t necessarily recommend it, but it is certainly worth looking at.

– Rick

FrameMaker 10 and ExtendScript Automation Slides and Samples

Last week’s FrameMaker 10 and ExtendScript Automation eSeminar went well in spite of a few glitches. Thank you to Adobe and Tom Aldous for graciously hosting and promoting the seminar. Thank you especially to all that attended and submitted questions.

As promised, we are making the slides and sample scripts available for download. You can download the slides from:

http://www.rickquatro.com/resources/ExtendScriptSeminar.pdf

The samples are at:

http://www.rickquatro.com/resources/SampleScripts.zip

The sample scripts may not meet your current requirements, but there are portions of each script that you can reuse in your own scripts. You can also use them to learn good scripting practices and how to approach similar problems. In future posts, we will dissect one of the scripts so you can learn solid techniques for writing your own.

Here is a link to the eSeminar recording:

https://www.adobe.com/cfusion/event/index.cfm?event=register%5Fno%5Fsession&loc=en%5Fus&id=1808717

-Rick

Autonumber Problems

Here is part of a recent post on the Framers list:

Single-file doc with four Sections. Sections and sub-sections numbered 1, 1.1, 1.1.1 etc.

Pgf numbering formats:

Heading1 S:<n+>.< =0>< =0>< =0>
Heading2 S:<n>.<n+>< =0>< =0>
Heading3 S:<n>.<n>.<n+>< =0>

But I’m getting Sections 1 and 2 (with subsections), then 5 and 6 (which should be 3 and 4)….Pix and tables are numbered with F:<n+> and T:<n+> respectively so shouldn’t be affecting anything.

Autonumbering in FrameMaker is one feature that is rock-solid. So these problems are always caused by intervening paragraphs that have unintended autonumber counters. The trick is finding the offending paragraphs. I use a FrameScript script to make an “autonumber report” of a document or book. With this report, the cause of autonumber problems can be quickly found.

The author of the Framers post sent me the problem document and in seconds I generated the following spreadsheet (click the image to see it full size):

It’s pretty easy to see the problem paragraphs, which I have highlighted. The key to finding them is to look for the last good number, which is in row 13. Next, look for the first bad number, which is in row 20. Now we know that the problem paragraph or paragraphs is between these two rows in the spreadsheet. At this point, it’s best to scan the Autonumber String column, and look for the S: series label, which brings us to rows 15 and 17.

As it turns out, in this document the two offending paragraphs were very small and at the top of the page, which is why they were difficult to find. But like many other tasks, FrameScript makes it easy. If you are interested in purchasing this script, please let me know. Thank you very much.

– Rick