# Creating array names in a loop?

Hi Xojo coders!

I want to create a series of curves to be shown in a graph.
The way that it works is by defining an x- and an y- array for each curve and filling them with “.Apend”. Below is shown how the curves x0/y0, x1/y1, x2/y2, x3/y3 and x4/y4 are filled with data.

R=0
if R<N then
For i=0 to NE(R)
x0.Append YY(R,i)
y0.Append ZZ(R,i)
next
R=R+1
end
if R<N then
For i=0 to NE(R)
x1.Append YY(R,i)
y1.Append ZZ(R,i)
next
R=R+1
end
if R<N then
For i=0 to NE(R)
x2.Append YY(R,i)
y2.Append ZZ(R,i)
next
R=R+1
end
if R<N then
For i=0 to NE(R)
x3.Append YY(R,i)
y3.Append ZZ(R,i)
next
R=R+1
end
if R<N then
For i=0 to NE(R)
x4.Append YY(R,i)
y4.Append ZZ(R,i)
next
R=R+1
end

Works fine, but the issue is that I do not have only 5 curves, but 30! So a lot of repetitive program lines. Is there a way to generate the array names in a loop like:

For R=0 to N-1
For i=0 to NE(R)
(generated array name, existing of “x” and R-value).Append YY(R,i)
(generated array name, existing of “y” and R-value).Append ZZ(R,i)
next i
next N

Cheers,
Jaap Gelling

you could use a point that have x,y or create a class with x,y,z propertie.
object array.
in a class you can also define a method to create special curves as a list of data.

static method
= Curves.Create(some arguments)

Method
in a Paint event where you get the g Graphics context call a sub method
PaintCurves(g, curves)

iterate the list with for each.

Thanks Markus - I’ll try that!