Author Topic: [SOLVED] hiccup with with finding tallest box in a group of boxes  (Read 1130 times)

0 Members and 1 Guest are viewing this topic.

Offline AutoFetishist

  • Sr. Member
  • ****
  • Posts: 397
  • Karma: 2
  • Gender: Male
I'm trying to loop through a text chain, and figure out which box is the tallest.
I want the repeat to continue until there isn't a next text box (ie the last box in the chain)

(TB is the object ref of the current box)


     tell TB
      set boxheight to 0
      set boxheight to (height of bounds of TB) as real
      repeat while next text box of TB is not null
         set TB to next text box of TB
         if (height of bounds of TB as real) > boxheight then
            set boxheight to height of bounds of TB
         else
            if next text box of TB is not null then
               set TB to next text box of TB
            end if
         end if
      end repeat
      return boxheight
   end tell


Thus code, unfortunately, is returning the height of the first box, regardless of whether that is the tallest of the boxes in the chain.

Can anyone see why?

Offline AutoFetishist

  • Sr. Member
  • ****
  • Posts: 397
  • Karma: 2
  • Gender: Male
Re: hiccup with with finding tallest box in a group of boxes
« Reply #1 on: February 10, 2009, 11:10:05 AM »
Figured it out.

I had to remove this:

            if next text box of TB is not null then
               set TB to next text box of TB
            end if