Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
A safearray is a kind of reference?
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: A safearray is a kind of reference? (Read 1243 times)
0 Members and 1 Guest are viewing this topic.
highflyingbird
Bull Frog
Posts: 415
Later equals never.
A safearray is a kind of reference?
«
on:
June 27, 2012, 09:03:08 AM »
A safearray is a kind of reference?
It means ,when we copy a safearray , if the element in origin has been changed,the copy one changed also.
Let's see this test:
Code - Auto/Visual Lisp:
[Select]
(
defun
c:test
(
/
lst oArray rArray value1 value2 List
->
SafeArray
)
(
defun
List
->
SafeArray
(
L DataType
)
(
vlax-safearray-fill
(
vlax
-
make
-
safearray
DataType
(
cons
0
(
1-
(
length
L
)
)
)
)
L
)
)
(
setq
lst '
(
1
2
3
4
5
6
)
)
(
setq
oArray
(
list
->
safearray
lst
vlax-vbInteger
)
)
;Make a new safearray
(
setq
rArray oArray
)
;->just a kind of reference
(
vlax
-
safearray-put-element
oArray
0
7
)
;Change the first element to a new value
(
setq
value1
(
vlax
-
safearray-get-element
oArray
0
)
)
;Get the 1st element value from origin
(
setq
value2
(
vlax
-
safearray-get-element
rArray
0
)
)
;The copy one has been changed at the same time!!!
(
=
value1 value2
)
;they are equal. --> T
(
vlax
-
safearray-put-element
rArray
5
8
)
;do another test
(
setq
value1
(
vlax
-
safearray-get-element
rArray
5
)
)
;Get the 1st element value from the copy
(
setq
value2
(
vlax
-
safearray-get-element
oArray
5
)
)
;The origin has been changed at the same time!!!
(
=
value1 value2
)
;they are equal. --> T
(
princ
)
)
«
Last Edit: June 27, 2012, 09:08:26 AM by HighflyingBird
»
Logged
I am a bilingualist,Chinese and Chinglish.
irneb
Water Moccasin
Posts: 1794
ACad R9-2016, Revit Arch 6-2016
WWW
Re: A safearray is a kind of reference?
«
Reply #1 on:
June 27, 2012, 09:43:02 AM »
It does seem so yes. I'm guessing it's implemented along the same lines as a selection set (e.g. using ssadd / ssdel modifies the original).
Logged
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
A safearray is a kind of reference?