Brad
I tried to send you mail directly but it bounced.  Below is a bit of code that is one 
way of doing this.  I am sure there would be others.

Regards
Steve Ware

Does anyone know how to create a Listbox populated with all the names of open
tables in a MapInfo session?

Brad
SuperValu GIS

START CODE

'To obtain a list of open tables and place them in a Table Picker list box
' by Steve Ware

'Make sure this file is in the same directory as this TabList.mb file

Include "MapBasic.def"

Declare sub Main
Declare sub Get_Tab_Name

Sub Main
call Get_Tab_Name
End sub

sub Get_Tab_Name

        Dim Tab_List(1), Selected_Table as string, m, i, j, k as smallint

'Get the number of tables that are open and redimension the string Tab_List
        Redim Tab_List(numtables())
'Put table names into the Tab_List array
        j = 1
        k = numtables()
        m = k
        i = 1
        Do
                Tab_List(j) = UCase$(TableInfo(i,Tab_Info_Name))
                j = j + 1
                i = i + 1
        Loop Until i-1 = m 
        Redim Tab_List(k)

'Create the dialog box to obtain the table name

        Dialog
                Title "Choose table"
                Width 160
                Height 90
                Control Statictext
                        Title "Choose Table "
                        Position 5,10
                Control ListBox
                        Title From Variable Tab_List
                        Position 54,10
                        Height 40
                        Value 1
                        Into i  'Only gets the number of the table in the list
                
                Control OKButton
                        Position 56, 59
                Control CancelButton
                        Position 106, 59
        

' If the OK button was not pressed then bail out 
        If not commandinfo(cmd_info_dlg_ok) then
         exit sub
        End If

        Selected_Table = Tab_List(i)  'Transfer name into a simpler variable
        note "You chose the table " & Selected_Table

End Sub '(Get_Tab_Name)

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

Reply via email to