Neil Sandbach <[EMAIL PROTECTED]> wrote:
> repeat with i = 1 to 8
>   member("canvas").image.draw(getAt(glistOfPointsCatA, i),
>   getAt(glistOfPointsCatA, i+1),
>  [#shapeType:#line, #lineSize:2, #color: rgb(150, 0, 0)])
> end repeat

Hi Neil,

If your glistOfPointsCatA has only 8 items, i+1 will be 9 when i is 8, so
getAt(glistOfPointsCatA, i+1) will be out of range.  Try:


  tImage   = member("canvas").image.duplicate()
  tOptions = [#shapeType: #line, #lineSize: 2, #color: rgb( 150, 0, 0 )]
  repeat with i = 1 to 8
    tStartPoint = gListOfPointsCatA[i]
    if i = 8 then
      tEndPoint = gListOfPointsCatA[1]
    else
      tEndPoint = gListOfPointsCatA[i + 1]
    end if
    tImage.draw(tStartPoint, tEndPoint, tOptions)
  end repeat
  member("canvas").image = tImage


Or (generic solution using mod):


  tImage   = member("canvas").image.duplicate()
  tOptions = [#shapeType: #line, #lineSize: 2, #color: rgb( 150, 0, 0 )]
  tCount   = gListOfPointsCatA.count
  repeat with i = 1 to tCount
    tStartPoint = gListOfPointsCatA[i]
    tEndPoint   = gListOfPointsCatA[(i mod tCount) + 1]
    tImage.draw(tStartPoint, tEndPoint, tOptions)
  end repeat
  member("canvas").image = tImage


Cheers,

James

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to