Hi Tom,

One of the ways I do it, is through Global variables (I know programmers
should not use Globals).  With a global array you can resize it inside on of
the handler routines.  This may not work as written, as I re-hashed some of
my current code to make it easier to read, but the basic concept is the
same.

This is what I do for a ListBox:

1)  Make a selection, put it into a temporary table, pull out the required
column into a Global Array (gaszPickSiteName)

        Select SiteName from DCCMatches where SiteName > "" Group by
SiteName Order by SiteName into TT
        ReDim gaszPickSiteName(TableInfo(TT, TAB_INFO_NROWS))
        For snLoop = 1 to TableInfo(TT, TAB_INFO_NROWS)
                Fetch Rec snLoop From TT
                gaszPickSiteName(snLoop) = Str$(TT.SiteName)
        Next

2)  ListBox Control
        Control ListBox
        Width 50  Height 70
        Position 5, 35
        ID PICKSECTORLISTBOX
        Calling UpdateSectorListBox

3)  Handler Routine

        Sub UpdateListBox()
        Dim snReadSelValue, snLoop, snCounter As SmallInt
        Dim szSiteName As String

'       *** Only 1 item at once, sorry
'       *** (returns 0 if no items selected).
'       *** Value returned is the same as ROWn from TT
        snReadSelValue = ReadControlValue(PICKSECTORLISTBOX)

        snCounter = 0
        If (snReadSelValue > 0) Then
                Fetch Rec snReadSelValue from TT
                szSiteName = TT.SiteName
                
                For snLoop = 1 to TableInfo(TT, TAB_INFO_NROWS)
                        Fetch Rec snLoop From TT
                        If Str$(TT.SiteName) <> szSiteName Then
                                snCounter = snCounter + 1
                                gaszPickSiteName(snLoop) = Str$(TT.SiteName)
                        End If
                Next

                ReDim gaszPickSiteName(snCounter)
                Alter Control PICKSECTORLISTBOX Title From Variable
gaszPickSiteName
                Close Table TMP
        End If
End Sub

Hope that this helps,
Mark

-----Original Message-----
From: Tom Manson [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 13, 2000 9:00 AM
To: 'MapInfo-L'
Subject: MI - MapBasic lists


Mappers,

I'm having a problem with MapBasic. Is it possible to create a drop-down
list within a dialog box of files currently open. From what I gather,
drop-down boxes (popupmenu) seem to be pretty static, and I can't seem to
find a way of making it list files 'on the fly'. If anyone could help me
with the code on this I'd be very appreciative. On a similar line, how can I
list what columns a file has?

Many thanks in advance,


Tom
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

Reply via email to