Business Books

Books for Publishers/Writers

Garage Sales

Contact us

Media info

Search this site

Online Store

Free Stuff

Format: Scripting tips

These are extracts from the FORMAT NEWSLETTER.

Image Info 0.8b1 is an AppleScript library which returns information about image files without loading the whole image into memory. It returns the info very quickly and gives resolution, width, height and color mode of a dozen common image file types, including TIFF, JPEG, PICT and GIF. Scripts can be written using Image Info to quickly find images which have a color mode of RGB, or list images which have a low resolution, and more. It's 52kb. From Kanzu. <http://www.versiontracker.com/moreinfo.fcgi?id=12265&db=mac>

-----


Macscripter.net is a great resource for applescripters: <http://macscripter.net>

-----

User of Applescript on Macs are finding a few problems in the transition from OS 9 to OS X. It works both ways, some things can be done in X which can't be done in previous versions. There's a very useful report on the new AppleScript 1.6 in Mac OS X on Bill Cheeseman's AppleScript Sourcebook <http://www.applescriptsourcebook.com/applescript/applescript160.html>
with links to available handlers for some of the problems.

-----

Walton Harris at the University of Georgia reported a problem with the "Blob" PageMaker script on our website <http://www.worsleypress.com/pubprod/scripts.html>. The cause turned out to be the slight difference in naming conventions for fonts: "Zapf Dingbats" against "ZapfDingbats". The script works in some circumstances where the inbuilt Bullets plugin is not appropriate, such as where the author has used asterisks to indicate the need for a bullet. Place the cursor at the beginning of the line and it takes the first two characters and replaces them with the bullet and an en-space, then moves on to sit at the beginning of the next para. The script can easily be edited to substitute any other dingbat, and any other character such as a tab.

-----

On the Mac, OSA Menu at <http://www.lazerware.com> allows you to have a permanent Scripts menu at the top of the screen which has AppleScripts for the application you are currently in. The "lite" version is included with Mac OS from 8.5 onwards but there's also an updated lite version.

Some thoughts on PageMaker scripting

We have been working on a PageMaker scripting job which has been a considerable challenge, but which, so far, PM Scripting's language has been able to meet...though we've come close to giving up a couple of times. The challenge was to take a couple of specially written QXP extensions and achieve the same in PageMaker. These thoughts may help not only in PM but with other programs.

Manipulating a string: there are some limited script ways of doing this, but my general answer now is to write the string to the pasteboard of the open file and manipulate it there, using TextCursor, TextSelect and GetStoryText. If you get its object number you can return to it or delete it at will. There are several references in PageMaker scripting documentation to a Lenlist() function. This should be LenLen().

Achieving the equivalent of QXP's inline boxes: With a PM script you can draw a box, cut it and paste it into position in a text block. Then, to equate to the content (in our case the details and name of the classified ad which will be copied in later to replace the box), we put that info in a para to follow the box, make it paper colour and 4pt with zero leading, and it can just be seen as a few marks on the bottom edge of the box. Click on the script and it identifies that you've clicked on an inline box and that you either want to know what the filename is of the ad you are looking for or go and get it.

Making objects chase the text: We've also thought of putting the single column boxes on a separate layer and hiding the object number in the text block. Then, if the text block is rerun, a script could find the object numbers and move the objects to the new position. A trial ran into all kinds of problems but I still think the idea should work.

Making scripts do multiple things: We've replaced a whole series of scripts with one visible script that calls a mass of hidden scripts by identifying the state of PM, the type of object the user has clicked on and even some aspects of the PM file name.

Hidden scripts: this works in Windows, but I'd like to know if the same can be done on a Mac. If you give a script an extension other than txt or spt, it doesn't appear in the Script palette, yet can be called by name from another script.

Setting defaults: by writing to a log file, you can create a script from a script, and then "Include" that script in the same script (you start with a script which just has one line ("return") to make this work first time). So a dialog box, for example, can come up next time with the defaults being what you entered last time.

Varying dialog boxes according to what you've already done: The Static items in dialog boxes can also contain variables, so you can change the wording in dialog boxes according to the state of the file.

Help files: You can create an About... or Help... pushbutton which will bring up a dialog box comprised entirely of Static lines and a single pushbutton. For complex things we're thinking of having a pushbutton which will create a new PM file (from a script) that contains the advice complete with graphics. Running the script again could identify that the help file is open and will close it...maybe deleting everything in it so it can't be too easily corrupted or changed.

Both the strongest and weakest aspect of scripts is their openness. Like a web page, if you see a script doing something you like, you can open it and look at the code. However, that makes it difficult to control something you've written. There is a growing culture of sharing ideas, which I hope will continue, even though that makes it harder to gain a direct financial return. I recently went into a newspaper office to run a training session and found they were already using one of my scripts...it still had my copyright line at the top... but as they are now a paying client I have no reason to complain.

Return to main Format page

Copyright Worsley Press 2003