Stores data in the elements of a safearray
(vlax-safearray-fill var 'element-values)
Arguments
A variable whose data type is a safearray.
A list of values to be stored in the array. You can specify as many values as there are elements in the array. If you specify fewer values than there are elements, the remaining elements retain their current value.
For multi-dimension arrays, element-values must be a list of lists, with each list corresponding to a dimension of the array.
Return Values
var
Examples
Create a single-dimension array of doubles:
_$ (setq sa (vlax-make-safearray vlax-vbdouble '(0 . 2)))
#<safearray...>
vlax-safearray-fill to populate the array:
Use_$ (vlax-safearray-fill sa '(1 2 3))
#<safearray...>
List the contents of the array:
_$ (vlax-safearray->list sa)
(1.0 2.0 3.0)
vlax-safearray-fill to set the first element in the array:
Use_$ (vlax-safearray-fill sa '(-66))
#<safearray...>
List the contents of the array:
_$ (vlax-safearray->list sa)
(-66.0 2.0 3.0)
vlax-put-element.
Notice that only the first element in the array has been changed; the remaining elements are unaffected and retain the value you previously set them to. If you need to change the second or third element and leave the first element unaffected, usevlax-safearray-fill to set four elements in an array that contains only three elements:
Instruct_$ (vlax-safearray-fill sa '(1 2 3 4))
Error: Assertion failed: safearray-fill failed. Too many elements.
vlax-safearray-fill function returns an error if you specify more elements than the array contains.
Thevlax-safearray-fill, with each list corresponding to a dimension. The following command creates a two-dimension array of strings containing three elements in each dimension:
To assign values to a multi-dimensional array, specify a list of lists to_$ (setq mat2 (vlax-make-safearray vlax-vbString '(0 . 1) '(1 . 3)))
#<safearray...>
vlax-safearray-fill to populate the array:
Use_$ (vlax-safearray-fill mat2 '(("a" "b" "c") ("d" "e" "f")))
#<safearray...>
vlax-safearray->list function to confirm the contents of mat2:
Call the_$ (vlax-safearray->list mat2)
(("a" "b" "c") ("d" "e" "f"))