Sunday, January 01, 2006

 

LocationOptions Enumeration

Values

  1650812527      LocationOptions.before

  1634104421      LocationOptions.after

  1650945639      LocationOptions.atBeginning

  1701733408      LocationOptions.atEnd

  1433299822      LocationOptions.unknown

Discussion

As is implicit in the names of the enumerated values (the first four, anyway), this value is relative to some object or to the members of a collection of objects. The purpose of the fifth value, the "unknown" location option, is not at all clear. You certainly would never use it when calling a method that takes a location as an argument (e.g., a move method).

There are times when InDesign loses track of the location of various items. For example, in order to speed the progress of scripts, they generally run with window updating and story composing switched off. In these circumstances, I could see a method returning the unknown location value, except that a careful check of the reference guide reveals that not a single method returns this information. Perhaps it's there for future expansion.

Because this enumeration is only ever used as an argument when calling a method, the numerical values above have little more than academic interest. You could use them if you wished, but the result would be a more obscure script -- of course, there are times when obscurity has value, but most of the time you're better off writing "in the clear" by using the named variants.

Usage Examples

Many variants of the move() method have a to argument that takes a member of this enumeration as a parameter. Similarly, some add() methods have an at argument to indicate where a new object should be added, and some duplicate() methods have the to argument.

To move the first paragraph of text frame myTF to the end of story myStory:
  myTF.paragraphs[0].move(LocationOptions.atEnd, myStory);
To move a range of paragraphs in a story to before another paragraph in the same story (as you might do if you received a Word document with sections in the wrong order):
  myStory.paragraphs.itemByRange(ObjStart,i-1).move(LocationOptions.before,myStory.paragraphs[IntroStart]);
To add a new row to the end of table myTable:
  myTable.rows.add(LocationOptions.atEnd,myTable);
To add a new page to a document immediately after page myPage, updating the reference contained in myPage to refer to the newly added page:
  myPage = myDocument.pages.add(LocationOptions.after, myPage);
To duplicate page n of document myFdoc after the last page of document myDoc:
  myFdoc.pages[n].duplicate(LocationOptions.after,myDoc.pages[-1]);
  This is equivalent to:
  myFdoc.pages[n].duplicate(LocationOptions.atEnd,myDoc);
Sometimes, the form you use for an operation like this depends on the way you happen to think about the maneuver.

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?