vlax-safearray-put-element
 
 
 

Adds an element to an array

(vlax-safearray-put-element var index... value)

Arguments

var

A variable whose data type is a safearray.

index...

A set of index values pointing to the element you are assigning a value to. For a single-dimension array, specify one index value; for a two-dimension array, specify two index values, and so on.

value

The value to assign the safearray element.

Return Values

The value assigned to the element.

Examples

Create a single-dimension array consisting of doubles:

_$ (setq point (vlax-make-safearray
vlax-vbDouble '(0 . 2)))
#<safearray...>

Use vlax-safearray-put-element to populate the array:

_$ (vlax-safearray-put-element
point 0 100)
100
_$ (vlax-safearray-put-element
point 1 100)
100
_$ (vlax-safearray-put-element
point 2 0)
0

Create a two-dimension array consisting of strings:

_$ (setq matrix (vlax-make-safearray
vlax-vbString '(1 . 2) '(1 . 2) ))
#<safearray...>

Use vlax-safearray-put-element to populate the array:

_$ (vlax-safearray-put-element
matrix 1 1 "a")
"a"
_$ (vlax-safearray-put-element
matrix 1 2 "b")
"b"
_$ (vlax-safearray-put-element
matrix 2 1 "c")
"c"
_$ (vlax-safearray-put-element
matrix 2 2 "d")
"d"

Note that you can also populate arrays using the vlax-safearray-fill function. The following function call accomplishes the same task as three vlax-safearray-put-element calls:

(vlax-safearray-fill matrix '(("a" "b") ("c" "d")))
See Also