Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.vbscript > #12342
| From | "Mayayana" <mayayana@invalid.nospam> |
|---|---|
| Newsgroups | microsoft.public.scripting.vbscript |
| Subject | Re: Modifying array elements in a dictionary is ineffective? |
| Date | 2021-04-09 23:05 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <s4r4na$rlf$1@dont-email.me> (permalink) |
| References | <s8ls3gg24yv1$.flt0oavzanef$.dlg@40tude.net> |
"JJ" <jj4public@gmail.com> wrote
| There is no exception or error message. It doesn't matter whether the
array
| is fixed or variable length.
|
| How could it happen?
|
| Here's the code to reproduce the problem.
|
| set dic = createobject("scripting.dictionary")
| dic.add "key", array(1)
| msgbox "initial = " & dic("key")(0)
| dic("key")(0) = 5
| msgbox "result = " & dic("key")(0) & " (should be 5)"
Set dic = createobject("scripting.dictionary")
dic.add "key", Array(1)
MsgBox "initial = " & dic("key")(0)
A = dic("key")
A(0) = 5
dic("key") = A
MsgBox "result = " & dic("key")(0) & " (should be 5)"
I don't know the exact mechanics of this phenomenon,
but I've noticed in the past that in some or all cases, you
can't abstract multiple levels from an array. You have to access
the variable. I've never systematically tried to figure it out.
I just noticed over time that in some cases the pointers don't
seem to get through a multiple reference. In those cases I
add the extra step to access the variable directly before using it.
Back to microsoft.public.scripting.vbscript | Previous | Next — Previous in thread | Next in thread | Find similar
Modifying array elements in a dictionary is ineffective? JJ <jj4public@gmail.com> - 2021-04-10 07:46 +0700
Re: Modifying array elements in a dictionary is ineffective? "Mayayana" <mayayana@invalid.nospam> - 2021-04-09 23:05 -0400
Re: Modifying array elements in a dictionary is ineffective? JJ <jj4public@gmail.com> - 2021-04-10 17:08 +0700
Re: Modifying array elements in a dictionary is ineffective? "Mayayana" <mayayana@invalid.nospam> - 2021-04-10 08:04 -0400
Re: Modifying array elements in a dictionary is ineffective? "R.Wieser" <address@not.available> - 2021-04-10 10:39 +0200
Re: Modifying array elements in a dictionary is ineffective? "Mayayana" <mayayana@invalid.nospam> - 2021-04-11 15:41 -0400
Re: Modifying array elements in a dictionary is ineffective? JJ <jj4public@gmail.com> - 2021-04-12 09:13 +0700
Re: Modifying array elements in a dictionary is ineffective? "Mayayana" <mayayana@invalid.nospam> - 2021-04-12 09:51 -0400
Re: Modifying array elements in a dictionary is ineffective? JJ <jj4public@gmail.com> - 2021-04-13 00:08 +0700
csiph-web