Quantcast
Viewing all articles
Browse latest Browse all 3791

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

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 3791

Trending Articles