>What's the best way to insert values into an array all at once?
>
>I have _array(3) and want to insert 1,2,3.
>
>I thought there was a way like _array(3) = (1,2,3) in another language so was wondering if there is something similar in Fox that I can't find.
>
>Thanks,
>Sunshine
Sunshine,
In VFP unfortunately it's not supported. You have to assign elements individually. Shortcuts comes to mind when elements fit. In your sample you're using sequential numbers like an enumeration. In that case you could use a for loop. ie:
for ix=1 to alen(_array)
_array[ix] = ix
endfor
Another shortcut is when majority of elemnents would be the same. ie: You have an array of 100,20 and all would be initialized to 0 except [1,3] and [20,5] :
_array = 0 && Initialize all to 0
_array[1,3] = 5
_array[20,5] = 15
If your data is somewhat in a cursor, table already dont forget :
copy to array ...
select ... into array ...
Cetin