Re: Indirection
Jim McKay <[email protected]> Wed, 16 Jan 2019 16:03:24 +0000 (UTC)
| Newsgroups | gmane.comp.lang.realbasic.user |
|---|---|
| Message-ID | <[email protected]> |
------------=_1547654603-16404-1335 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Have you thought about storing the arrays in a dictionary? Since the keys/v= alues are variants, you can assign/get an array value. dim myArray1(1) as string dim d as new dictionary dim Name1 as string=3D"myArray1" d.value(name1)=3D myArray1() dim resultarray() as string resultarray=3Dd.value(name1) result=3Dresultarray(0) You also might look at introspection to find the array property by name. Or if you need to select the array based on an index, use an array of varia= nts or even a 2-dimensional array if they're all the same size. -Jim > 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. > --=20 > Jean-Luc Arnaud >=20 > ------------------------- >=20 >=20 > Hi all,=20 > Is there a way to use a kind of indirection, just like Dynamic strings an= d #, but for other type of variable, in particular with arrays?=20 > Let say I have 3 arrays named "MyArray1", "MyArray2" and "MyArray3".=20 > I need to use them with indirection, something like:=20 >=20 > Dim Name1 As String=3D"MyArray1"=20 > Dim Name2 As String=3D"MyArray2"=20 > Dim Name3 As String=3D"MyArray3"=20 > If Value=3D1=20 > Result=3D#Name1(0)=20 > End If=20 >=20 >=20 > TIA for any help=20 >=20 > -- Jean-Luc Arnaud=20 ------------=_1547654603-16404-1335 Content-Type: text/html; charset="us-ascii" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable <html><body> <p>Have you thought about storing the arrays in a dictionary? Since the key= s/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> <blockquote><p>On Jan 16, 2019, at 3:48 AM, Jean-Luc Arnaud <jean-luc@cd= multimedia.fr> 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. — 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 “MyArray1”, “MyArray2” = and “MyArray3”. 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>— Jean-Luc Arnaud</p></blockquote> <img src=3D"https://u9098352.ct.sendgrid.net/wf/open?upn=3DW5IIOHYh8Ix-2Flm= NrgtTomW8ATk7pXvOSwl3ev5ZofJfs1Jur6X7wo1Y1jDFc6xukd5xYwY8PFGMHWki07-2Fz3cpl= deWHKnX0YjQad80JSDM0TOlphFgaykMNBnil2CBS-2B8WGvEJavUlsqFGPZo-2FVY9-2BoCZXjI= KJJllwN-2FtoyaXjlbLUwmkWQVrNCJjb-2FPFbdvGKAhjm2i7OXM1FZcLo-2BDh2Ax-2BFFSYVP= 6VR5VgnqdCXI-3D" alt=3D"" width=3D"1" height=3D"1" border=3D"0" style=3D"he= ight:1px !important;width:1px !important;border-width:0 !important;margin-t= op:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin= -left:0 !important;padding-top:0 !important;padding-bottom:0 !important;pad= ding-right:0 !important;padding-left:0 !important;"/> </body></html> ------------=_1547654603-16404-1335--