Re: Indirection question
Markus Winter <drmarkuswinter-gM/[email protected]> Sun, 9 Dec 2018 16:28:14 +0100
| Newsgroups | gmane.comp.lang.realbasic.user |
|---|---|
| Message-ID | <[email protected]> |
> 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 "MyArray1", "MyArray2" and "MyArray3". > I need to use them with indirection, something like: >=20 > Dim Name1 As String=3D"MyArray1" > Dim Name2 As String=3D"MyArray2" > Dim Name3 As String=3D"MyArray3" This makes no sense. You talk of =E2=80=9CArrays=E2=80=9D but in your code "= MyArray1" is a string, NOT an array.=20 > If Value=3D1 > Result=3D#Name1(0) > End If And this is complete nonsense. Where does =E2=80=9Cvalue=E2=80=9D come from?= What does it refer to? An array? An element in an array=E2=80=9D? What is =E2=80=9CResult=E2=80=9D supposed to be? A string you try to get? An= array you try to get? The name of the array (in which case why do you refer= to an array element???)? Based on what criteria? The =E2=80=9Cvalue=E2=80=9D= of which we know nothing? Please put a bit more effort into writing clear questions. Most of the time I= have the feeling you are smoking something not quite legal =E2=80=A6=20 =46rom what I THINK you mean I would probably use a dictionary with the arra= y name as key and the arrays as value. Dim myArray1() as String Dim myArray2() as String Dim myArray3() as String Dim dictArray as dictionary=20 dictArray.Value( =E2=80=9CName1=E2=80=9D ) =3D myArray1 dictArray.Value( =E2=80=9CName2=E2=80=9D ) =3D myArray2 dictArray.Value( =E2=80=9CName3=E2=80=9D ) =3D myArray3 Dim Result() as String =3D dictArray.Value( =E2=80=9CName2=E2=80=9D ) // Result() is myArray2 Best Regards Markus