PDA

View Full Version : Freaky Array issue? Or my error?


Gibbz
11-16-2005, 10:18 AM
Ok i getting bizzare issues with max tonight

i have problems with bitarrays it seems
i have say an bitarray

mybitarray #{1,2,3}
for example
now if i go

mybitarray[1] i get "false" instead of the value 1 or #{1}(which ever its supposed to output)

Is this something im doing? Am i expecting it to behave other than it should?

Light
11-16-2005, 10:31 AM
Bronson,

You need to use arrays to access elements. As in arr = #(); arr[1]

You can also use this method for bitArrays, but it will only return whether there is an element there or not, true if selected.




Light

prettyPixel
11-16-2005, 10:48 AM
Indeed an bitarray is very different to an array.

Usually, you do not need to know the value of the elements which are "false".
Then you can use a loop like this :
mybitarray=#{2..5,7,9..10,24}
for currentValue in mybitarray do format "%\n" currentValue
And you will know the value of the elements which are true (but not the others)

It is the normal usage of an bitarray...

Gibbz
11-16-2005, 11:39 AM
Ok thanks guys clears things up a bit more.

Was wondering what the difrence between an array and a bitarray was. Now i know i should be able to get it right.

Thanks :)

CGTalk Moderation
11-16-2005, 11:39 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.