Wednesday, January 03, 2007


Multi-column Text Frames

Suddenly, I've found myself doing a lot of work with multi-column text frames, so when the issue came up on the U2U forum of which column within a text frame contained some text, it was fairly short work to bang out this function:
function getColumnNum(mysearch) {
  myFrame = mysearch.parentTextFrames[0];
  myColumnStarts = myFrame.textColumns.everyItem().index;
  mySpot = mysearch.index;
  for (var j = myColumnStarts.length - 1; j >= 0; j--) {
    if (mySpot >= myColumnStarts[j]) { return j }
  throw "What a revolting development this is"
I wasn't quite sure what to do if the loop dropped through. It's one of those theoretically impossible happenings that nonetheless is syntactically possible. In theory, if myFrame is the parent text frame of the text reference contained in mysearch then the loop will never terminate. The error will never be thrown.

So, I borrowed a leaf from the immortal William Bendix (start of "A Life of Riley") and threw an amusing, albeit unhelpful, error message.

Comments: Post a Comment

<< Home

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