Control Arrays

Hello,
I am running on an old version of realBasic (2011 R3) & I am trying to work with control arrays, mainly with lines.

So i have made an array of lines & positioned them nicely but when I try to adjust the color of an individual line (with l(13).LineColor=&cFF0000) but i get;

“An exception of class NilObjectException was not handled. The application must shut down.”

Am I able to do things like change the color of the individual lines?

This indicates that L(13) does not exist, or was never instantiated…

Control Sets (not arrays) are not required to have consequtive and sequential indexs…

You may have perhaps skipped 13 when you created them… after all that is an “UNLUCKY NUMBER” :slight_smile:

:slight_smile: thanks I just found out that was the issue as well :slight_smile: was just writing a reply :slight_smile:

You should post your findings, in order to help others in the future that may stumble across the same/similar issue

The issue was down to a stupid mistake on my part,

I am reading in data on the location of each of these lines, I have ran through the text file (counting the lines in the text file) and stored this in a variable

then I have run a For loop to setup each instance of the line and its location. due to tweaking the code and deleting bits i ended up with;

For a=1 to lines-1

which is why it didn’t reach 13 (lines was equal to 13 in this instance)

On a slightly side note… am I able to use the original item cloned? If i try to use l(0) i get the same issue as above stating it does not exist, but when i put;

msgbox(str(me.index)) in the mouse down event on the line & select the original line i get a message back stating “0”. I have also tried using Line1 but still I am unable to move or re-color the line through code?

Not a big issue if i can, I can just push it off the side & use an other cloned line :slight_smile: