Re: Indirection
Jim McKay <[email protected]> Thu, 17 Jan 2019 15:26:11 +0000 (UTC)
| Newsgroups | gmane.comp.lang.realbasic.user |
|---|---|
| Message-ID | <[email protected]> |
------------=_1547738770-14635-1732 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable And they're incredibly fast, even when populated with a ton of data. > On Jan 17, 2019, at 5:57 AM, Jon Ogden <[email protected]> wrote: >=20 > Oh once you start working with dictionaries you won=E2=80=99t want to sto= p. You=E2=80=99ll wonder why you never used them in the past. They are one = of the most useful constructs in Xojo.=20 >=20 > Sent from my iPhone >=20 > On Jan 17, 2019, at 3:01 AM, Jean-Luc Arnaud <jean-luc-E/[email protected]> w= rote: >=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 >>=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 ke= ys/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=3Dresul= tarray(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 v= ariants 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]>= wrote: >>>=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 Delega= te 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 = strings and #, but for other type of variable, in particular with arrays? L= et say 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 indirecti= on, something 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 >>>=20 >>> TIA for any help >>>=20 >>> =E2=80=94 Jean-Luc Arnaud >>>=20 >>>=20 >>=20 ------------=_1547738770-14635-1732 Content-Type: text/html; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable <html><body> <p>And they're incredibly fast, even when populated with a ton of data.</p> <blockquote><p>On Jan 17, 2019, at 5:57 AM, Jon Ogden <[email protected]>= ; wrote:</p> <p>Oh once you start working with dictionaries you won=E2=80=99t want to st= op. You=E2=80=99ll wonder why you never used them in the past. They are one= of the most useful constructs in Xojo.</p> <p>Sent from my iPhone</p> <p>On Jan 17, 2019, at 3:01 AM, Jean-Luc Arnaud <[email protected]= r> wrote:</p> <blockquote><p>Thanks a lot for your help, Jim. I'm not used to working wit= h dictionary, but will look at this solution. Thanks for code sample, it wi= ll be be of great help!!</p> <p>Jean-Luc Arnaud</p> <p>Le 16/01/2019 =C3=A0 17:03, Jim McKay a =C3=A9crit :</p> <blockquote><p>Have you thought about storing the arrays in a dictionary? S= ince 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=3Dresult= array(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 va= riants or even a 2-dimensional array if they're all the same size.</p> <p>-Jim</p> <p>On Jan 16, 2019, at 3:48 AM, Jean-Luc Arnaud <[email protected]= r> 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 Delegat= e 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 s= trings and #, but for other type of variable, in particular with arrays? Le= t say 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 indirecti= on, something like:</p> <p>Dim Name1 As String=3D"MyArray1" Dim Name2 As String=3D"M= yArray2" Dim Name3 As String=3D"MyArray3" If Value=3D1</p> <pre>Result=3D#Name1(0)</pre> <p>End If</p> <p>TIA for any help</p> <p>=E2=80=94 Jean-Luc Arnaud</p></blockquote></blockquote></blockquote> <img src=3D"https://u9098352.ct.sendgrid.net/wf/open?upn=3DW5IIOHYh8Ix-2Flm= NrgtTomW8ATk7pXvOSwl3ev5ZofJePw04DAqXQfYRNIF2J4RPlUyZ9HpbPr03NOU6uVygwooWaD= Pw91r7vA8yfcqG4kNu0XFX-2FH4Jo6wVHUraHvQu3M13fupvlULTFFy5PgrvMfhEGjPTXDagqQB= rwWq4uyfqBUNXxHidc0KfR5-2FNi29in3iYqtpgmGL43y5-2Bbnyd04IHlgS8IyumzKfIQe6N5h= 3A-3D" alt=3D"" width=3D"1" height=3D"1" border=3D"0" style=3D"height:1px != important;width:1px !important;border-width:0 !important;margin-top:0 !impo= rtant;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !i= mportant;padding-top:0 !important;padding-bottom:0 !important;padding-right= :0 !important;padding-left:0 !important;"/> </body></html> ------------=_1547738770-14635-1732--