Re: Indirection

Jon Ogden <[email protected]> Thu, 17 Jan 2019 06:57:43 -0600
Newsgroups gmane.comp.lang.realbasic.user
Message-ID <[email protected]>
--Apple-Mail-BB1F7B85-98D7-45AF-A4BF-BF5D26DCB008
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable

Oh once you start working with dictionaries you won=E2=80=99t want to stop. Y=
ou=E2=80=99ll wonder why you never used them in the past. They are one of th=
e most useful constructs in Xojo.=20

Sent from my iPhone

> On Jan 17, 2019, at 3:01 AM, Jean-Luc Arnaud <jean-luc-E/[email protected]> wr=
ote:
>=20
> Thanks a lot for your help, Jim.
> I'm not used to working with dictionary, but will look at this solution.
> Thanks for code sample, it will be be of great help!!
>=20
> Jean-Luc Arnaud
>=20
>> Le 16/01/2019 =C3=A0 17:03, Jim McKay a =C3=A9crit :
>> Have you thought about storing the arrays in a dictionary? Since the keys=
/values are variants, you can assign/get an array value.
>>=20
>> dim myArray1(1) as string dim d as new dictionary dim Name1 as string=3D"=
myArray1"
>>=20
>> d.value(name1)=3D myArray1()
>>=20
>> dim resultarray() as string resultarray=3Dd.value(name1) result=3Dresulta=
rray(0)
>>=20
>> You also might look at introspection to find the array property by name.
>>=20
>> Or if you need to select the array based on an index, use an array of var=
iants or even a 2-dimensional array if they're all the same size.
>>=20
>> -Jim
>>=20
>> On Jan 16, 2019, at 3:48 AM, Jean-Luc Arnaud <jean-luc-E/[email protected]> w=
rote:
>>=20
>> Hi,
>>=20
>> On the 7th of December, I sent the below message, and got no reply.
>>=20
>> After seeking in Language Reference, forum and Internet, I think Delegate=
 could be a solution. What's your opinion?
>>=20
>> TIA for any help. =E2=80=94 Jean-Luc Arnaud
>>=20
>> -------------------------
>>=20
>> Hi all, Is there a way to use a kind of indirection, just like Dynamic st=
rings and #, but for other type of variable, in particular with arrays? Let s=
ay I have 3 arrays named =E2=80=9CMyArray1=E2=80=9D, =E2=80=9CMyArray2=E2=80=
=9D and =E2=80=9CMyArray3=E2=80=9D. I need to use them with indirection, som=
ething like:
>>=20
>> Dim Name1 As String=3D"MyArray1"
>> Dim Name2 As String=3D"MyArray2"
>> Dim Name3 As String=3D"MyArray3"
>> If Value=3D1
>>     Result=3D#Name1(0)
>> End If
>> TIA for any help
>>=20
>> =E2=80=94 Jean-Luc Arnaud
>>=20
>>=20
>=20

--Apple-Mail-BB1F7B85-98D7-45AF-A4BF-BF5D26DCB008
Content-Type: text/html;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D=
utf-8"></head><body dir=3D"auto">Oh once you start working with dictionaries=
 you won=E2=80=99t want to stop. You=E2=80=99ll wonder why you never used th=
em in the past. They are one of the most useful constructs in Xojo.&nbsp;<br=
><br><div id=3D"AppleMailSignature" dir=3D"ltr">Sent from my iPhone</div><di=
v dir=3D"ltr"><br>On Jan 17, 2019, at 3:01 AM, Jean-Luc Arnaud &lt;<a href=3D=
"mailto:jean-luc-E/[email protected]">jean-luc-E/[email protected]</a>&gt; wrote:<br=
><br></div><blockquote type=3D"cite"><div dir=3D"ltr">
 =20
    <meta http-equiv=3D"Content-Type" content=3D"text/html;
      charset=3Dwindows-1252">
 =20
 =20
    Thanks a lot for your help, Jim.<br>
    I'm not used to working with dictionary, but will look at this
    solution.<br>
    Thanks for code sample, it will be be of great help!!<br>
    <br>
    <pre class=3D"moz-signature" cols=3D"72">Jean-Luc Arnaud

</pre>
    <div class=3D"moz-cite-prefix">Le 16/01/2019 =C3=A0 17:03, Jim McKay a
      =C3=A9crit&nbsp;:<br>
    </div>
    <blockquote type=3D"cite" cite=3D"mid:DF38BA22-0994-4310-B588-0CB8CFCB57=
[email protected]">
      <meta http-equiv=3D"content-type" content=3D"text/html;
        charset=3Dwindows-1252">
      <p>Have you thought about storing the arrays in a dictionary?
        Since the keys/values are variants, you can assign/get an array
        value.</p>
      <p>dim myArray1(1) as string dim d as new dictionary dim Name1 as
        string=3D"myArray1"</p>
      <p>d.value(name1)=3D myArray1()</p>
      <p>dim resultarray() as string resultarray=3Dd.value(name1)
        result=3Dresultarray(0)</p>
      <p>You also might look at introspection to find the array property
        by name.</p>
      <p>Or if you need to select the array based on an index, use an
        array of variants or even a 2-dimensional array if they're all
        the same size.</p>
      <p>-Jim</p>
      <blockquote>
        <p>On Jan 16, 2019, at 3:48 AM, Jean-Luc Arnaud
          <a class=3D"moz-txt-link-rfc2396E" href=3D"mailto:jean-luc@cdmulti=
media.fr">&lt;jean-luc-E/[email protected]&gt;</a> wrote:</p>
        <p>Hi,</p>
        <p>On the 7th of December, I sent the below message, and got no
          reply.</p>
        <p>After seeking in Language Reference, forum and Internet, I
          think Delegate could be a solution. What's your opinion?</p>
        <p>TIA for any help. =E2=80=94 Jean-Luc Arnaud</p>
        <p>-------------------------</p>
        <p>Hi all, Is there a way to use a kind of indirection, just
          like Dynamic strings and #, but for other type of variable, in
          particular with arrays? Let say I have 3 arrays named
          =E2=80=9CMyArray1=E2=80=9D, =E2=80=9CMyArray2=E2=80=9D and =E2=80=9C=
MyArray3=E2=80=9D. I need to use them with
          indirection, something like:</p>
        <pre>Dim Name1 As String=3D"MyArray1"
Dim Name2 As String=3D"MyArray2"
Dim Name3 As String=3D"MyArray3"
If Value=3D1
    Result=3D#Name1(0)
End If</pre>
        <p>TIA for any help</p>
        <p>=E2=80=94 Jean-Luc Arnaud</p>
      </blockquote>
      <img src=3D"https://u9098352.ct.sendgrid.net/wf/open?upn=3DW5IIOHYh8Ix=
-2FlmNrgtTomW8ATk7pXvOSwl3ev5ZofJfs1Jur6X7wo1Y1jDFc6xukd5xYwY8PFGMHWki07-2Fz=
3cpldeWHKnX0YjQad80JSDM0TOlphFgaykMNBnil2CBS-2B8WGvEJavUlsqFGPZo-2FVY9-2BoCZ=
XjIKJJllwN-2FtoyaXjlbLUwmkWQVrNCJjb-2FPFbdvGKAhjm2i7OXM1FZcLo-2BDh2Ax-2BFFSY=
VP6VR5VgnqdCXI-3D" alt=3D"" style=3D"height:1px !important;width:1px
        !important;border-width:0 !important;margin-top:0
        !important;margin-bottom:0 !important;margin-right:0
        !important;margin-left:0 !important;padding-top:0
        !important;padding-bottom:0 !important;padding-right:0
        !important;padding-left:0 !important;" moz-do-not-send=3D"true" widt=
h=3D"1" height=3D"1" border=3D"0">
    </blockquote>
    <br>
 =20

</div></blockquote></body></html>=

--Apple-Mail-BB1F7B85-98D7-45AF-A4BF-BF5D26DCB008--