Array to Rectangle / at runtime

Hello to all out there,
this is a “reopening” of another channel…
P416837
I hope it is correct, but I think my other problem is solve, so I decide to make a new conversation.
Last thing was to create class and array from SQL statement… working good so far.

To continue my problem is to get content out of array to create a flexible number of Realbasic.Rect’s - based on the number of instances of the class (numbers of class objects in the array (hope this sounds correct)?
I remember years ago for desktop app I could create “Globals” at runtime… looking for something similar now…

My Example with 3 boxes, but should be flexible (done “spaghetti coded” with a fixed number of “boxes”).
The array is a session property, but I leave “Session…” out for better reading…

Dim counter As Integer
counter = ClsBoxAll.Ubound     // the array with properties of the boxes like Length, width, coordinates X and Y

For i As Integer = 0 To counter
  
  Select Case counter
  Case 0
    Box1 = New REALbasic.Rect(ClsBoxAll(0).boxLTopX, ClsBoxAll(0).boxLTopY, ClsBoxAll(0).boxLengthDraw, ClsBoxAll(0).boxWidthDraw)
  Case 1
    Box1 = New REALbasic.Rect(ClsBoxAll(0).boxLTopX, ClsBoxAll(0).boxLTopY, ClsBoxAll(0).boxLengthDraw, ClsBoxAll(0).boxWidthDraw)
    Box2 = New REALbasic.Rect(ClsBoxAll(1).boxLTopX, ClsBoxAll(1).boxLTopY, ClsBoxAll(1).boxLengthDraw, ClsBoxAll(1).boxWidthDraw)
  Case 2
    Box1 = New REALbasic.Rect(ClsBoxAll(0).boxLTopX, ClsBoxAll(0).boxLTopY, ClsBoxAll(0).boxLengthDraw, ClsBoxAll(0).boxWidthDraw)
    Box2 = New REALbasic.Rect(ClsBoxAll(1).boxLTopX, ClsBoxAll(1).boxLTopY, ClsBoxAll(1).boxLengthDraw, ClsBoxAll(1).boxWidthDraw)
    Box3 = New REALbasic.Rect(ClsBoxAll(2).boxLTopX, ClsBoxAll(2).boxLTopY, ClsBoxAll(2).boxLengthDraw, ClsBoxAll(2).boxWidthDraw)

   //  ... and so on...     :-(

  End Select
Next

I thought I could do it like …

Box(i) = New REALbasic.Rect(ClsBoxAll(0).boxLTopX, ClsBoxAll(0).boxLTopY, ClsBoxAll(0).boxLengthDraw, ClsBoxAll(0).boxWidthDraw)

… but do not know how.
The reason is that I want to have the “boxes” as Rect’s to do further things like “Realbasic.Rect.Intersects”

Maybe someone can shove me to the right direction?

Thanks to all for your time and help up to here…
Thomas

dim box() as Realbasic.rec
Dim counter As Integer
counter = ClsBoxAll.Ubound     // the array with properties of the boxes like Length, width, coordinates X and Y
For i As Integer = 0 To counter
  dim tempBox = New REALbasic.Rect(ClsBoxAll(i).boxLTopX, ClsBoxAll(i).boxLTopY, ClsBoxAll(i).boxLengthDraw, ClsBoxAll(i).boxWidthDraw)
box.append(tempBox)
Next i

To Dave: Thanks again!
That’s the way I want it… :slight_smile:
Had problem with “New REALbasic.Rect”… now it should be ok! There’s so much to learn and practise, but I learn a lot here from searching the forum… Great people out there…!