Hi Frank,

You sure push the Run Command to the limit... ;-)

I guess the problem here is a matter of scope. When you run the command
string it is actually
executed in the scope of MapInfo, and not in the scope of your MapBasic
application.

And this also leads to the error message you are recieving: MapInfo doesn't
know of any variable
called "myVar2".

Why don't do this using a procedure insted ?

*************************************************************
Declare Sub Main
Declare Sub NoteArrayValue(arrValues() As String, ByVal nItem As Integer)

Sub Main

Dim  arrVal1(5), arrVal2(5) As String

     arrVal1(1) = "Value 1 in array 1"
     arrVal1(2) = "Value 2 in array 1"
     arrVal1(3) = "Value 3 in array 1"
     arrVal1(4) = "Value 4 in array 1"
     arrVal1(5) = "Value 5 in array 1"

     arrVal2(1) = "Value 1 in array 2"
     arrVal2(2) = "Value 2 in array 2"
     arrVal2(3) = "Value 3 in array 2"
     arrVal2(4) = "Value 4 in array 2"
     arrVal2(5) = "Value 5 in array 2"

     Call NoteArrayValue(arrVal2, 5)
     Call NoteArrayValue(arrVal1, 1)
     'etc...

End Sub

Sub NoteArrayValue(arrValues() As String, ByVal nItem As Integer)

     Note arrValues(nItem)

End Sub

*************************************************************

And even this is more or less overkill:

Note ArrVal2(5)

will also do the job, but of course it all comes down to what exactly you
are trying to
achive ?

HTH,
Peter
------------------------------------------------------------------------------------------------
Peter Horsb�ll M�ller, GIS Udviklingskonsulent / GIS-Developer
Kampsax A/S - GIS Software & Solutions
Rugaardsvej 55, 5000 Odense, DK
tel: +45 6313 5013,  dir:+45 6313 5008,  fax: +45 6313 5090
mailto:[EMAIL PROTECTED]
www.kampsax-gis.dk and www.kampsax.dk
Authorized MapInfo Partner & Distributor in Denmark and Norway.
------------------------------------------------------------------------------------------------
Se mere om Dansk MapInfo Brugerkonference p� 
http://www.kampsax-gis.dk/Default.asp?ID=296

Klik ind p� http://www.kortal.dk og se det hele lidt fra oven!
Check http://www.kortal.dk and have a look at Denmark from above!
----- Videresendt af Peter M�ller/Kampsax - 05-09-2002 15:01 -----
                                                                                       
                            
                    frank hebbert                                                      
                            
                    <frank@hebber        Til:    [EMAIL PROTECTED]     
                            
                    t.com>               cc:                                           
                            
                                         Vedr.:  MI-L passing variable names           
                            
                    05-09-2002                                                         
                            
                    13:19                                                              
                            
                                                                                       
                            
                                                                                       
                            



I have a set of array variables, let's call them myVar1, myVar2 etc.

I want to extract a value from one of my arrays, based on an integer that
gets passed, along with the name of the array to get it from.

ie:

I want to get myVar2(10) and note it.

so...

passedInteger = 10
varName = myVar2

myCommand = "note " +  varname + "(" + passedInteger + ")"

run command myCommand

which should resolve to myVar2(10) which in turn resolves to give the value

contained in the array. However, I get an error telling my that the
variable isn't defined - it is.

Any comments? Hope I've made myself clear...

Thanks a lot, as always

Frank


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 2839





---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 2844

Reply via email to