PDA

View Full Version : quick question


vergil
03-22-2001, 05:45 AM
If I assign an array 5 values then I do a blah=thisarray will blah still have all the values that thisarray did?

Example:

myarray=1;
myarray[0]=1;
myarray[1]=5;
myarray[2]=67;

mything=myarray;


Will mything have all of the [] values also?

kyle0654
03-22-2001, 06:47 AM
myarray=1;
myarray[0]=1;
myarray[1]=5;
myarray[2]=67;

mything=myarray;


mything would equal 1 after this code. It reads myarray and a variable, but will read myarray[#] as a position in the array myarray. If you want to copy an array to another array, do this:


myarray = {1, 5, 67};
setarray myarray2, arraylen(myarray);
for (this.z = 0; this.z < arraylen(myarray); this.z++) {
myarray2[this.z] = myarray[this.z];
}


That should work. I haven't actually used setarray in a while though...I'm used to doing it the quick way like I did in the first line of that.

vergil
03-22-2001, 12:12 PM
thanks a bunch :)